Skip to content

Commit c912391

Browse files
committed
Merge commit '6dfe717bfc6333a686b16975353604aae6769edf' into nested_executor
2 parents c6d7cd1 + 6dfe717 commit c912391

11 files changed

Lines changed: 44 additions & 44 deletions

File tree

src/executorlib/executor/single.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def __init__(
393393
)
394394
if not plot_dependency_graph:
395395
from executorlib.task_scheduler.file.spawner_subprocess import (
396-
execute_in_subprocess,
396+
subprocess_execute,
397397
)
398398
from executorlib.task_scheduler.file.task_scheduler import (
399399
create_file_executor,
@@ -415,7 +415,7 @@ def __init__(
415415
block_allocation=block_allocation,
416416
init_function=init_function,
417417
disable_dependencies=disable_dependencies,
418-
execute_function=execute_in_subprocess,
418+
execute_function=subprocess_execute,
419419
wait=wait,
420420
refresh_rate=refresh_rate,
421421
validator=validate_resource_dict_with_optional_keys,

src/executorlib/standalone/scheduler.py renamed to src/executorlib/standalone/command_pysqa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pysqa import QueueAdapter
66

77

8-
def terminate_with_pysqa(
8+
def pysqa_terminate(
99
queue_id: int,
1010
config_directory: Optional[str] = None,
1111
backend: Optional[str] = None,

src/executorlib/task_scheduler/file/shared.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from executorlib.standalone.command import get_cache_execute_command
99
from executorlib.standalone.hdf import get_cache_files, get_output, get_queue_id
1010
from executorlib.standalone.serialize import serialize_funct
11-
from executorlib.task_scheduler.file.spawner_subprocess import terminate_subprocess
11+
from executorlib.task_scheduler.file.spawner_subprocess import subprocess_terminate
1212

1313

1414
class FutureItem:
@@ -381,7 +381,7 @@ def _cancel_processes(
381381
pysqa_config_directory (str): path to the pysqa config directory (only for pysqa based backend).
382382
backend (str): name of the backend used to spawn tasks.
383383
"""
384-
if terminate_function is not None and terminate_function == terminate_subprocess:
384+
if terminate_function is not None and terminate_function == subprocess_terminate:
385385
for task in process_dict.values():
386386
terminate_function(task=task)
387387
elif terminate_function is not None and backend is not None:

src/executorlib/task_scheduler/file/spawner_pysqa.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
from pysqa import QueueAdapter
66

7+
from executorlib.standalone.command_pysqa import pysqa_execute_command, pysqa_terminate
78
from executorlib.standalone.hdf import dump, get_queue_id
89
from executorlib.standalone.inputcheck import check_file_exists
910
from executorlib.standalone.interactive.spawner import (
1011
set_current_directory_in_environment,
1112
)
12-
from executorlib.standalone.scheduler import pysqa_execute_command, terminate_with_pysqa
1313

1414

1515
def execute_with_pysqa(
@@ -122,7 +122,7 @@ def terminate_tasks_in_cache(
122122
for f in hdf5_file_lst:
123123
queue_id = get_queue_id(f)
124124
if queue_id is not None:
125-
terminate_with_pysqa(
125+
pysqa_terminate(
126126
queue_id=queue_id,
127127
config_directory=pysqa_config_directory,
128128
backend=backend,
@@ -148,7 +148,7 @@ def terminate_task_in_cache(
148148
file_name = os.path.join(cache_directory, cache_key + "_i.h5")
149149
queue_id = get_queue_id(file_name=file_name)
150150
if queue_id is not None:
151-
terminate_with_pysqa(
151+
pysqa_terminate(
152152
queue_id=queue_id,
153153
config_directory=pysqa_config_directory,
154154
backend=backend,

src/executorlib/task_scheduler/file/spawner_subprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111

1212

13-
def execute_in_subprocess(
13+
def subprocess_execute(
1414
command: list,
1515
file_name: str,
1616
data_dict: dict,
@@ -65,7 +65,7 @@ def execute_in_subprocess(
6565
return subprocess.Popen(command, universal_newlines=True, cwd=cwd)
6666

6767

68-
def terminate_subprocess(task):
68+
def subprocess_terminate(task):
6969
"""
7070
Terminate a subprocess and wait for it to complete.
7171

src/executorlib/task_scheduler/file/task_scheduler.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
from executorlib.task_scheduler.base import TaskSchedulerBase, validate_resource_dict
1313
from executorlib.task_scheduler.file.shared import execute_tasks_h5
1414
from executorlib.task_scheduler.file.spawner_subprocess import (
15-
execute_in_subprocess,
16-
terminate_subprocess,
15+
subprocess_execute,
16+
subprocess_terminate,
1717
)
1818

1919
try:
20-
from executorlib.standalone.scheduler import terminate_with_pysqa
20+
from executorlib.standalone.command_pysqa import pysqa_terminate
2121
from executorlib.task_scheduler.file.spawner_pysqa import execute_with_pysqa
2222
except ImportError:
2323
# If pysqa is not available fall back to executing tasks in a subprocess
24-
execute_with_pysqa = execute_in_subprocess # type: ignore
25-
terminate_with_pysqa = None # type: ignore
24+
execute_with_pysqa = subprocess_execute # type: ignore
25+
pysqa_terminate = None # type: ignore
2626

2727

2828
class FileTaskScheduler(TaskSchedulerBase):
@@ -126,10 +126,10 @@ def create_file_executor(
126126
check_executor(executor=flux_executor)
127127
check_nested_flux_executor(nested_flux_executor=flux_executor_nesting)
128128
check_flux_log_files(flux_log_files=flux_log_files)
129-
if execute_function != execute_in_subprocess:
130-
terminate_function = terminate_with_pysqa # type: ignore
129+
if execute_function != subprocess_execute:
130+
terminate_function = pysqa_terminate # type: ignore
131131
else:
132-
terminate_function = terminate_subprocess # type: ignore
132+
terminate_function = subprocess_terminate # type: ignore
133133
return FileTaskScheduler(
134134
executor_kwargs=executor_kwargs,
135135
pysqa_config_directory=pysqa_config_directory,

src/executorlib/task_scheduler/interactive/spawner_pysqa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
from pysqa import QueueAdapter
77

8+
from executorlib.standalone.command_pysqa import pysqa_execute_command, pysqa_terminate
89
from executorlib.standalone.inputcheck import validate_number_of_cores
910
from executorlib.standalone.interactive.spawner import (
1011
BaseSpawner,
1112
set_current_directory_in_environment,
1213
)
13-
from executorlib.standalone.scheduler import pysqa_execute_command, terminate_with_pysqa
1414
from executorlib.task_scheduler.base import validate_resource_dict
1515
from executorlib.task_scheduler.interactive.blockallocation import (
1616
BlockAllocationTaskScheduler,
@@ -162,7 +162,7 @@ def shutdown(self, wait: bool = True):
162162
wait (bool, optional): Whether to wait for the interface to shutdown. Defaults to True.
163163
"""
164164
if self._process is not None:
165-
terminate_with_pysqa(
165+
pysqa_terminate(
166166
queue_id=self._process,
167167
config_directory=self._config_directory,
168168
backend=self._backend,

tests/unit/executor/test_flux_cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from executorlib import terminate_tasks_in_cache, terminate_task_in_cache
1414
from executorlib.standalone.hdf import dump
1515
from executorlib.task_scheduler.file.spawner_pysqa import execute_with_pysqa
16-
from executorlib.standalone.scheduler import terminate_with_pysqa
16+
from executorlib.standalone.command_pysqa import pysqa_terminate
1717
from executorlib.task_scheduler.interactive.spawner_pysqa import PysqaSpawner
1818

1919
skip_flux_test = "FLUX_URI" not in os.environ
@@ -245,7 +245,7 @@ def test_pysqa_interface(self):
245245
cache_directory="executorlib_cache",
246246
backend="flux"
247247
)
248-
self.assertIsNone(terminate_with_pysqa(queue_id=queue_id, backend="flux"))
248+
self.assertIsNone(pysqa_terminate(queue_id=queue_id, backend="flux"))
249249

250250
def test_executor_existing_files(self):
251251
with FluxClusterExecutor(

tests/unit/standalone/test_slurm_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from executorlib.standalone.command import generate_slurm_command
33

44
try:
5-
from executorlib.standalone.scheduler import pysqa_execute_command
5+
from executorlib.standalone.command_pysqa import pysqa_execute_command
66

77
skip_pysqa_test = False
88
except ImportError:

tests/unit/task_scheduler/file/test_mpi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
try:
77
from executorlib.task_scheduler.file.task_scheduler import FileTaskScheduler
8-
from executorlib.task_scheduler.file.spawner_subprocess import execute_in_subprocess
8+
from executorlib.task_scheduler.file.spawner_subprocess import subprocess_execute
99

1010
skip_h5py_test = False
1111
except ImportError:
@@ -30,7 +30,7 @@ def mpi_funct(i):
3030
class TestCacheExecutorMPI(unittest.TestCase):
3131
def test_executor(self):
3232
with FileTaskScheduler(
33-
executor_kwargs={"cores": 2}, execute_function=execute_in_subprocess
33+
executor_kwargs={"cores": 2}, execute_function=subprocess_execute
3434
) as exe:
3535
fs1 = exe.submit(mpi_funct, 1)
3636
self.assertFalse(fs1.done())

0 commit comments

Comments
 (0)