-
Notifications
You must be signed in to change notification settings - Fork 210
Support for GlobusComputeExecutor #3607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: GlobusComputeExecutor tests | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
env: | ||
PYTHON_VERSION: 3.11 | ||
|
||
jobs: | ||
main-test-suite: | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: 60 | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Set up Python Environment | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Collect Job Information | ||
id: job-info | ||
run: | | ||
echo "Python Version: ${{ env.PYTHON_VERSION }} " >> ci_job_info.txt | ||
echo "CI Triggering Event: ${{ github.event_name }}" >> ci_job_info.txt | ||
echo "Triggering Git Ref: ${{ github.ref }}" >> ci_job_info.txt | ||
echo "Triggering Git SHA: ${{ github.sha }}" >> ci_job_info.txt | ||
echo "Workflow Run: ${{ github.run_number }}" >> ci_job_info.txt | ||
echo "Workflow Attempt: ${{ github.run_attempt }}" >> ci_job_info.txt | ||
as_ascii="$(echo "${{ github.ref_name }}" | perl -pe "s/[^A-z0-9-]+/-/g; s/^-+|-+\$//g; s/--+/-/g;")" | ||
echo "as-ascii=$as_ascii" >> $GITHUB_OUTPUT | ||
|
||
- name: setup virtual env | ||
run: | | ||
make virtualenv | ||
source .venv/bin/activate | ||
|
||
- name: Non-requirements based install | ||
run: | | ||
# mpich: required by mpi4py which is in test-requirements for radical-pilot | ||
sudo apt-get update -q | ||
sudo apt-get install -qy mpich | ||
|
||
- name: make deps clean_coverage | ||
run: | | ||
source .venv/bin/activate | ||
make deps | ||
make clean_coverage | ||
|
||
# Temporary fix until fixes make it to a release | ||
git clone -b main https://github.com/globus/globus-compute.git | ||
pip3 install globus-compute/compute_sdk globus-compute/compute_endpoint | ||
|
||
- name: start globus_compute_endpoint | ||
env: | ||
GLOBUS_COMPUTE_CLIENT_ID: ${{ secrets.GLOBUS_COMPUTE_CLIENT_ID }} | ||
GLOBUS_COMPUTE_CLIENT_SECRET: ${{ secrets.GLOBUS_COMPUTE_SECRET_KEY }} | ||
run: | | ||
source /home/runner/work/parsl/parsl/.venv/bin/activate | ||
globus-compute-endpoint configure default | ||
which globus-compute-endpoint | ||
python3 -c "import globus_compute_sdk; print(globus_compute_sdk.__version__)" | ||
python3 -c "import globus_compute_endpoint; print(globus_compute_endpoint.__version__)" | ||
cat << EOF > /home/runner/.globus_compute/default/config.yaml | ||
engine: | ||
type: ThreadPoolEngine | ||
benclifford marked this conversation as resolved.
Show resolved
Hide resolved
|
||
max_workers: 4 | ||
EOF | ||
cat /home/runner/.globus_compute/default/config.yaml | ||
mkdir ~/.globus_compute/default/tasks_working_dir | ||
globus-compute-endpoint start default | ||
globus-compute-endpoint list | ||
khk-globus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: make test | ||
env: | ||
GLOBUS_COMPUTE_CLIENT_ID: ${{ secrets.GLOBUS_COMPUTE_CLIENT_ID }} | ||
GLOBUS_COMPUTE_CLIENT_SECRET: ${{ secrets.GLOBUS_COMPUTE_SECRET_KEY }} | ||
run: | | ||
source .venv/bin/activate | ||
export GLOBUS_COMPUTE_ENDPOINT=$(jq -r .endpoint_id < ~/.globus_compute/default/endpoint.json) | ||
echo "GLOBUS_COMPUTE_ENDPOINT = $GLOBUS_COMPUTE_ENDPOINT" | ||
|
||
export PARSL_TEST_PRESERVE_NUM_RUNS=7 | ||
|
||
make gce_test | ||
ln -s pytest-parsl/parsltest-current test_runinfo | ||
|
||
khk-globus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: stop globus_compute_endpoint | ||
env: | ||
GLOBUS_COMPUTE_CLIENT_ID: ${{ secrets.GLOBUS_COMPUTE_CLIENT_ID }} | ||
GLOBUS_COMPUTE_CLIENT_SECRET: ${{ secrets.GLOBUS_COMPUTE_SECRET_KEY }} | ||
run: | | ||
source /home/runner/work/parsl/parsl/.venv/bin/activate | ||
globus-compute-endpoint stop default | ||
|
||
- name: Archive runinfo logs | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: runinfo-${{ env.PYTHON_VERSION }}-${{ steps.job-info.outputs.as-ascii }}-${{ github.sha }} | ||
path: | | ||
runinfo/ | ||
pytest-parsl/ | ||
ci_job_info.txt | ||
compression-level: 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from globus_compute_sdk import Executor | ||
|
||
from parsl.config import Config | ||
from parsl.executors import GlobusComputeExecutor | ||
from parsl.usage_tracking.levels import LEVEL_1 | ||
|
||
# Please start your own endpoint on perlmutter following instructions below to use this config: | ||
# https://globus-compute.readthedocs.io/en/stable/endpoints/endpoint_examples.html#perlmutter-nersc | ||
perlmutter_endpoint = 'YOUR_PERLMUTTER_ENDPOINT_UUID' | ||
|
||
# Please start your own endpoint on expanse following instructions below to use this config: | ||
# https://globus-compute.readthedocs.io/en/stable/endpoints/endpoint_examples.html#expanse-sdsc | ||
expanse_endpoint = 'YOUR_EXPANSE_ENDPOINT_UUID' | ||
|
||
config = Config( | ||
executors=[ | ||
GlobusComputeExecutor( | ||
executor=Executor(endpoint_id=perlmutter_endpoint), | ||
label="Perlmutter", | ||
), | ||
GlobusComputeExecutor( | ||
executor=Executor(endpoint_id=expanse_endpoint), | ||
label="Expanse", | ||
), | ||
], | ||
usage_tracking=LEVEL_1, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from globus_compute_sdk import Executor | ||
|
||
from parsl.config import Config | ||
from parsl.executors import GlobusComputeExecutor | ||
from parsl.usage_tracking.levels import LEVEL_1 | ||
|
||
# Public tutorial endpoint | ||
tutorial_endpoint = '4b116d3c-1703-4f8f-9f6f-39921e5864df' | ||
|
||
config = Config( | ||
executors=[ | ||
GlobusComputeExecutor( | ||
executor=Executor(endpoint_id=tutorial_endpoint), | ||
label="Tutorial_Endpoint_py3.11", | ||
) | ||
], | ||
usage_tracking=LEVEL_1, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
from __future__ import annotations | ||
|
||
import copy | ||
from concurrent.futures import Future | ||
from typing import Any, Callable, Dict | ||
|
||
import typeguard | ||
|
||
from parsl.errors import OptionalModuleMissing | ||
from parsl.executors.base import ParslExecutor | ||
from parsl.utils import RepresentationMixin | ||
|
||
try: | ||
from globus_compute_sdk import Executor | ||
_globus_compute_enabled = True | ||
except ImportError: | ||
_globus_compute_enabled = False | ||
|
||
|
||
class GlobusComputeExecutor(ParslExecutor, RepresentationMixin): | ||
""" GlobusComputeExecutor enables remote execution on Globus Compute endpoints | ||
|
||
GlobusComputeExecutor is a thin wrapper over globus_compute_sdk.Executor | ||
Refer to `globus-compute user documentation <https://globus-compute.readthedocs.io/en/latest/executor.html>`_ | ||
and `reference documentation <https://globus-compute.readthedocs.io/en/latest/reference/executor.html>`_ | ||
for more details. | ||
|
||
.. note:: | ||
As a remote execution system, Globus Compute relies on serialization to ship | ||
tasks and results between the Parsl client side and the remote Globus Compute | ||
Endpoint side. Serialization is unreliable across python versions, and | ||
wrappers used by Parsl assume identical Parsl versions across on both sides. | ||
We recommend using matching Python, Parsl and Globus Compute version on both | ||
the client side and the endpoint side for stable behavior. | ||
|
||
""" | ||
|
||
@typeguard.typechecked | ||
def __init__( | ||
self, | ||
executor: Executor, | ||
label: str = 'GlobusComputeExecutor', | ||
): | ||
""" | ||
Parameters | ||
---------- | ||
|
||
executor: globus_compute_sdk.Executor | ||
Pass a globus_compute_sdk Executor that will be used to execute | ||
tasks on a globus_compute endpoint. Refer to `globus-compute docs | ||
<https://globus-compute.readthedocs.io/en/latest/reference/executor.html#globus-compute-executor>`_ | ||
|
||
label: | ||
a label to name the executor | ||
""" | ||
if not _globus_compute_enabled: | ||
raise OptionalModuleMissing( | ||
['globus-compute-sdk'], | ||
"GlobusComputeExecutor requires globus-compute-sdk installed" | ||
) | ||
yadudoc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
super().__init__() | ||
self.executor: Executor = executor | ||
self.resource_specification = self.executor.resource_specification | ||
self.user_endpoint_config = self.executor.user_endpoint_config | ||
self.label = label | ||
|
||
def start(self) -> None: | ||
""" Start the Globus Compute Executor """ | ||
pass | ||
yadudoc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def submit(self, func: Callable, resource_specification: Dict[str, Any], *args: Any, **kwargs: Any) -> Future: | ||
""" Submit func to globus-compute | ||
|
||
|
||
Parameters | ||
---------- | ||
|
||
func: Callable | ||
Python function to execute remotely | ||
|
||
resource_specification: Dict[str, Any] | ||
Resource specification can be used specify MPI resources required by MPI applications on | ||
Endpoints configured to use globus compute's MPIEngine. GCE also accepts *user_endpoint_config* | ||
to configure endpoints when the endpoint is a `Multi-User Endpoint | ||
<https://globus-compute.readthedocs.io/en/latest/endpoints/endpoints.html#templating-endpoint-configuration>`_ | ||
|
||
args: | ||
Args to pass to the function | ||
|
||
kwargs: | ||
kwargs to pass to the function | ||
|
||
Returns | ||
------- | ||
|
||
Future | ||
""" | ||
res_spec = copy.deepcopy(resource_specification or self.resource_specification) | ||
# Pop user_endpoint_config since it is illegal in resource_spec for globus_compute | ||
if res_spec: | ||
user_endpoint_config = res_spec.pop('user_endpoint_config', self.user_endpoint_config) | ||
else: | ||
user_endpoint_config = self.user_endpoint_config | ||
|
||
try: | ||
self.executor.resource_specification = res_spec | ||
self.executor.user_endpoint_config = user_endpoint_config | ||
return self.executor.submit(func, *args, **kwargs) | ||
finally: | ||
# Reset executor state to defaults set at configuration time | ||
self.executor.resource_specification = self.resource_specification | ||
self.executor.user_endpoint_config = self.user_endpoint_config | ||
|
||
def shutdown(self): | ||
"""Clean-up the resources associated with the Executor. | ||
|
||
GCE.shutdown will cancel all futures that have not yet registered with | ||
Globus Compute and will not wait for the launched futures to complete. | ||
This method explicitly shutsdown the result_watcher thread to avoid | ||
it waiting for outstanding futures at thread exit. | ||
""" | ||
self.executor.shutdown(wait=False, cancel_futures=True) | ||
result_watcher = self.executor._get_result_watcher() | ||
result_watcher.shutdown(wait=False, cancel_futures=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import os | ||
|
||
from globus_compute_sdk import Executor | ||
|
||
from parsl.config import Config | ||
from parsl.executors import GlobusComputeExecutor | ||
|
||
|
||
def fresh_config(): | ||
|
||
endpoint_id = os.environ["GLOBUS_COMPUTE_ENDPOINT"] | ||
|
||
return Config( | ||
executors=[ | ||
GlobusComputeExecutor( | ||
executor=Executor(endpoint_id=endpoint_id), | ||
label="globus_compute", | ||
) | ||
] | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.