Skip to content

Commit

Permalink
Set Executor attributes in super class constructor
Browse files Browse the repository at this point in the history
Setting these attributes in the constructor makes reasoning about later use
less complicated.  If an Executor is instantiated these exist.  Whether or not
they've been set to a non-default value is another question.
  • Loading branch information
khk-globus committed Apr 18, 2024
1 parent 04ca656 commit eabed74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 0 additions & 2 deletions parsl/dataflow/dflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,8 +1140,6 @@ def add_executors(self, executors: Sequence[ParslExecutor]) -> None:
executor.hub_port = self.hub_zmq_port
if self.monitoring:
executor.monitoring_radio = self.monitoring.radio
else:
executor.monitoring_radio = None
if hasattr(executor, 'provider'):
if hasattr(executor.provider, 'script_dir'):
executor.provider.script_dir = os.path.join(self.run_dir, 'submit_scripts')
Expand Down
16 changes: 16 additions & 0 deletions parsl/executors/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from abc import ABCMeta, abstractmethod
from concurrent.futures import Future
from typing import Any, Callable, Dict, Optional
Expand Down Expand Up @@ -45,6 +46,21 @@ class ParslExecutor(metaclass=ABCMeta):
label: str = "undefined"
radio_mode: str = "udp"

def __init__(
self,
*,
hub_address: Optional[str] = None,
hub_port: Optional[int] = None,
monitoring_radio: Optional[MonitoringRadio] = None,
run_dir: str = ".",
run_id: Optional[str] = None,
):
self.hub_address = hub_address
self.hub_port = hub_port
self.monitoring_radio = monitoring_radio
self.run_dir = os.path.abspath(run_dir)
self.run_id = run_id

def __enter__(self) -> Self:
return self

Expand Down

0 comments on commit eabed74

Please sign in to comment.