Skip to content

Commit c66686c

Browse files
authored
[Fix] Fix default working directory for SlurmClusterExecutor with block_allocation (#954)
* [Fix] Fix default working directory for SlurmClusterExecutor with block_allocation * Add tests
1 parent 463c0a3 commit c66686c

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/executorlib/task_scheduler/interactive/spawner_pysqa.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ def create_pysqa_block_allocation_scheduler(
238238
cores_per_worker = executor_kwargs.get("cores", 1)
239239
if "cwd" in executor_kwargs and executor_kwargs["cwd"] is not None:
240240
executor_kwargs["cwd"] = os.path.abspath(executor_kwargs["cwd"])
241+
elif cache_directory is not None:
242+
executor_kwargs["cwd"] = os.path.abspath(cache_directory)
241243
if cache_directory is not None:
242244
executor_kwargs["cache_directory"] = os.path.abspath(cache_directory)
243245
else:

tests/unit/executor/test_flux_cluster.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ def test_executor(self):
7171
self.assertEqual(len(os.listdir("executorlib_cache")), 4)
7272
self.assertTrue(fs1.done())
7373

74+
def test_executor_no_cwd(self):
75+
with FluxClusterExecutor(
76+
resource_dict={"cores": 2},
77+
block_allocation=False,
78+
cache_directory="executorlib_cache",
79+
pmi_mode=pmi,
80+
) as exe:
81+
cloudpickle_register(ind=1)
82+
fs1 = exe.submit(mpi_funct, 1)
83+
self.assertFalse(fs1.done())
84+
self.assertEqual(fs1.result(), [(1, 2, 0), (1, 2, 1)])
85+
self.assertEqual(len(os.listdir("executorlib_cache")), 4)
86+
self.assertTrue(fs1.done())
87+
7488
def test_executor_blockallocation(self):
7589
with FluxClusterExecutor(
7690
resource_dict={"cores": 2, "cwd": "executorlib_cache"},
@@ -86,6 +100,21 @@ def test_executor_blockallocation(self):
86100
self.assertEqual(len(os.listdir("executorlib_cache")), 2)
87101
self.assertTrue(fs1.done())
88102

103+
def test_executor_blockallocation_no_cwd(self):
104+
with FluxClusterExecutor(
105+
resource_dict={"cores": 2},
106+
block_allocation=True,
107+
cache_directory="executorlib_cache",
108+
pmi_mode=pmi,
109+
max_workers=1,
110+
) as exe:
111+
cloudpickle_register(ind=1)
112+
fs1 = exe.submit(mpi_funct, 1)
113+
self.assertFalse(fs1.done())
114+
self.assertEqual(fs1.result(), [(1, 2, 0), (1, 2, 1)])
115+
self.assertEqual(len(os.listdir("executorlib_cache")), 2)
116+
self.assertTrue(fs1.done())
117+
89118
def test_executor_dependencies(self):
90119
with FluxClusterExecutor(
91120
resource_dict={"cores": 1, "cwd": "executorlib_cache"},

0 commit comments

Comments
 (0)