Skip to content

Commit d9b7edc

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 d19e521 commit d9b7edc

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
@@ -69,8 +70,7 @@ def __init__(
6970
for more info.
7071
7172
label:
72-
a label to name the executor; mainly utilized for
73-
logging and advanced needs with multiple executors.
73+
a label to name the executor
7474
7575
batch_size:
7676
the maximum number of tasks to coalesce before
@@ -117,12 +117,10 @@ def __init__(
117117
)
118118

119119
def start(self) -> None:
120-
"""Empty function
121-
"""
122120
pass
123121

124122
def submit(self, func: Callable, resource_specification: Dict[str, Any], *args: Any, **kwargs: Any) -> Future:
125-
""" Submit fn to globus-compute
123+
""" Submit func to globus-compute
126124
127125
128126
Parameters
@@ -148,24 +146,21 @@ def submit(self, func: Callable, resource_specification: Dict[str, Any], *args:
148146
149147
Future
150148
"""
151-
self._executor.resource_specification = resource_specification or self.resource_specification
149+
res_spec = copy.deepcopy(resource_specification or self.resource_specification)
152150
# Pop user_endpoint_config since it is illegal in resource_spec for globus_compute
153-
self._executor.user_endpoint_config = resource_specification.pop('user_endpoint_config', self.user_endpoint_config)
151+
if res_spec:
152+
user_endpoint_config = res_spec.pop('user_endpoint_config', self.user_endpoint_config)
153+
else:
154+
user_endpoint_config = self.user_endpoint_config
155+
156+
self._executor.resource_specification = res_spec
157+
self._executor.user_endpoint_config = user_endpoint_config
154158
return self._executor.submit(func, *args, **kwargs)
155159

156-
def shutdown(self, wait=True, *, cancel_futures=False):
160+
def shutdown(self):
157161
"""Clean-up the resources associated with the Executor.
158162
159-
It is safe to call this method several times. Otherwise, no other methods
160-
can be called after this one.
161-
162-
Parameters
163-
----------
164-
165-
wait: If True, then this method will not return until all pending
166-
futures have received results.
167-
cancel_futures: If True, then this method will cancel all futures
168-
that have not yet registered their tasks with the Compute web services.
169-
Tasks cannot be cancelled once they are registered.
163+
GCE.shutdown will cancel all futures that have not yet registered with
164+
Globus Compute and will not wait for the launched futures to complete.
170165
"""
171-
return self._executor.shutdown()
166+
return self._executor.shutdown(wait=False, cancel_futures=True)

0 commit comments

Comments
 (0)