Skip to content

Commit d01a346

Browse files
committed
Fixes to avoid res_spec modification
* GCE now makes a deepcopy of the resource_specification to avoid modifying the user supplied object. * stack of docstring changes
1 parent 75f9c5e commit d01a346

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

docs/userguide/execution.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Parsl currently supports the following executors:
8888
These executors cover a broad range of execution requirements. As with other Parsl components, there is a standard interface (ParslExecutor) that can be implemented to add support for other executors.
8989

9090
5. `parsl.executors.globus_compute.GlobusComputeExecutor`: This executor uses `Globus Compute <https://globus-compute.readthedocs.io/en/latest/index.html>`_
91-
as the execution backend to run functions on remote systems.
91+
as the execution backend to run tasks on remote systems.
9292

9393
.. note::
9494
Refer to :ref:`configuration-section` for information on how to configure these executors.

parsl/executors/globus_compute.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import copy
34
import uuid
45
from concurrent.futures import Future
56
from typing import Any, Callable, Dict, Optional, Union
@@ -60,8 +61,7 @@ def __init__(
6061
for more info.
6162
6263
label:
63-
a label to name the executor; mainly utilized for
64-
logging and advanced needs with multiple executors.
64+
a label to name the executor
6565
6666
batch_size:
6767
the maximum number of tasks to coalesce before
@@ -108,12 +108,10 @@ def __init__(
108108
)
109109

110110
def start(self) -> None:
111-
"""Empty function
112-
"""
113111
pass
114112

115113
def submit(self, func: Callable, resource_specification: Dict[str, Any], *args: Any, **kwargs: Any) -> Future:
116-
""" Submit fn to globus-compute
114+
""" Submit func to globus-compute
117115
118116
119117
Parameters
@@ -139,24 +137,21 @@ def submit(self, func: Callable, resource_specification: Dict[str, Any], *args:
139137
140138
Future
141139
"""
142-
self._executor.resource_specification = resource_specification or self.resource_specification
140+
res_spec = copy.deepcopy(resource_specification or self.resource_specification)
143141
# Pop user_endpoint_config since it is illegal in resource_spec for globus_compute
144-
self._executor.user_endpoint_config = resource_specification.pop('user_endpoint_config', self.user_endpoint_config)
142+
if res_spec:
143+
user_endpoint_config = res_spec.pop('user_endpoint_config', self.user_endpoint_config)
144+
else:
145+
user_endpoint_config = self.user_endpoint_config
146+
147+
self._executor.resource_specification = res_spec
148+
self._executor.user_endpoint_config = user_endpoint_config
145149
return self._executor.submit(func, *args, **kwargs)
146150

147-
def shutdown(self, wait=True, *, cancel_futures=False):
151+
def shutdown(self):
148152
"""Clean-up the resources associated with the Executor.
149153
150-
It is safe to call this method several times. Otherwise, no other methods
151-
can be called after this one.
152-
153-
Parameters
154-
----------
155-
156-
wait: If True, then this method will not return until all pending
157-
futures have received results.
158-
cancel_futures: If True, then this method will cancel all futures
159-
that have not yet registered their tasks with the Compute web services.
160-
Tasks cannot be cancelled once they are registered.
154+
GCE.shutdown will cancel all futures that have not yet registered with
155+
Globus Compute and will not wait for the launched futures to complete.
161156
"""
162-
return self._executor.shutdown()
157+
return self._executor.shutdown(wait=False, cancel_futures=True)

0 commit comments

Comments
 (0)