Skip to content

Commit 37e8e18

Browse files
committed
new way to detect monitoring code
1 parent ce2eced commit 37e8e18

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

parsl/dataflow/dflow.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -752,13 +752,6 @@ def launch_task(self, task_record: TaskRecord) -> Future:
752752
monitor_resources=executor.monitor_resources(),
753753
run_dir=self.run_dir)
754754

755-
# hint executors that this function will be monitored
756-
if task_record['resource_specification']:
757-
task_record['resource_specification'].update({'_is_monitoring_enabled': True})
758-
else:
759-
if task_record['resource_specification']:
760-
task_record['resource_specification'].update({'_is_monitoring_enabled': False})
761-
762755
with self.submitter_lock:
763756
exec_fu = executor.submit(function, task_record['resource_specification'], *args, **kwargs)
764757
self.update_task_state(task_record, States.launched)

parsl/executors/taskvine/executor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,15 @@ def submit(self, func, resource_specification, *args, **kwargs):
341341

342342
logger.debug(f'Got resource specification: {resource_specification}')
343343

344-
is_monitoring_enabled = resource_specification.get('_is_monitoring_enabled', False)
344+
# If `_parsl_monitoring_task_id` is in kwargs, Parsl monitoring code is enabled.
345+
is_monitoring_enabled = '_parsl_monitoring_task_id' in kwargs
345346

346347
# Default execution mode of apps is regular
347348
exec_mode = resource_specification.get('exec_mode', self.function_exec_mode)
348349

350+
# Fall back to regular execution if a function is Parsl-monitored as a monitored function is invocation-specific.
351+
# Note that it is possible to get the wrapped function by calling the `__wrapped__` attribute when monitoring is enabled.
352+
# It will disable the monitoring wrapper code however.
349353
if exec_mode == 'serverless' and is_monitoring_enabled:
350354
logger.warning("A serverless task cannot run with Parsl monitoring enabled. Falling back to execute this task as a regular task.")
351355
exec_mode = 'regular'

0 commit comments

Comments
 (0)