-
Notifications
You must be signed in to change notification settings - Fork 6
SlurmClusterExecutor - create a separate working directory for each job #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
981b77e
cab77e3
9535958
da6f689
0d9ce2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,20 @@ def test_executor(self): | |
| cloudpickle_register(ind=1) | ||
| fs1 = exe.submit(mpi_funct, 1) | ||
| self.assertFalse(fs1.done()) | ||
| self.assertEqual(len(os.listdir("executorlib_cache")), 2) | ||
| self.assertEqual(fs1.result(), [(1, 2, 0), (1, 2, 1)]) | ||
| self.assertTrue(fs1.done()) | ||
|
|
||
| def test_executor_no_cwd(self): | ||
| with FluxClusterExecutor( | ||
| resource_dict={"cores": 2}, | ||
| block_allocation=False, | ||
| cache_directory="executorlib_cache", | ||
| ) as exe: | ||
| cloudpickle_register(ind=1) | ||
| fs1 = exe.submit(mpi_funct, 1) | ||
| self.assertFalse(fs1.done()) | ||
| self.assertEqual(len(os.listdir("executorlib_cache")), 2) | ||
| self.assertEqual(fs1.result(), [(1, 2, 0), (1, 2, 1)]) | ||
| self.assertTrue(fs1.done()) | ||
|
Comment on lines
+47
to
58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainTest may not correctly validate the separate working directory behavior. The new test method is good but has a few concerns:
Let me verify the expected behavior by checking the implementation: Consider adding a test that submits multiple jobs to better validate the separate directory functionality: + def test_executor_multiple_jobs_no_cwd(self):
+ with FluxClusterExecutor(
+ resource_dict={"cores": 2},
+ block_allocation=False,
+ cache_directory="executorlib_cache",
+ ) as exe:
+ cloudpickle_register(ind=1)
+ fs1 = exe.submit(mpi_funct, 1)
+ fs2 = exe.submit(mpi_funct, 2)
+
+ # Verify both jobs complete successfully
+ self.assertEqual(fs1.result(), [(1, 2, 0), (1, 2, 1)])
+ self.assertEqual(fs2.result(), [(2, 2, 0), (2, 2, 1)])
+
+ # Verify separate directories were created
+ cache_contents = os.listdir("executorlib_cache")
+ self.assertGreater(len(cache_contents), 2, "Expected separate directories for each job")🏁 Script executed: #!/bin/bash
# Description: Check how the working directory logic works when cwd is not specified
# Expected: Find the logic that creates subdirectories based on command arguments
ast-grep --pattern 'def execute_with_pysqa($$$) {
$$$
}'
# Also check for any directory creation logic
rg -A 10 -B 5 "cache_directory.*cwd|cwd.*cache_directory"Length of output: 2974 Enhance directory‐structure assertions and add multi‐job coverage The Please update • In entries = os.listdir("executorlib_cache")
self.assertEqual(len(entries), 2)
for e in entries:
self.assertTrue(
os.path.isdir(os.path.join("executorlib_cache", e)),
f"Expected '{e}' to be a subdirectory for a task"
)• In the corresponding “with cwd” test, assert that entries are files, not directories: entries = os.listdir("executorlib_cache")
self.assertEqual(len(entries), 2)
for e in entries:
self.assertTrue(
os.path.isfile(os.path.join("executorlib_cache", e)),
f"Expected '{e}' to be a file in the shared cwd"
)• Add a new test to submit two separate jobs and verify each gets its own subdirectory: + def test_executor_multiple_jobs_no_cwd(self):
+ with FluxClusterExecutor(
+ resource_dict={"cores": 2},
+ block_allocation=False,
+ cache_directory="executorlib_cache",
+ ) as exe:
+ cloudpickle_register(ind=1)
+ # Submit two distinct jobs
+ fs1 = exe.submit(mpi_funct, 1)
+ fs2 = exe.submit(mpi_funct, 2)
+
+ # Ensure both complete correctly
+ self.assertEqual(fs1.result(), [(1, 2, 0), (1, 2, 1)])
+ self.assertEqual(fs2.result(), [(2, 2, 0), (2, 2, 1)])
+
+ # Verify separate subdirectories for each task of each job
+ entries = os.listdir("executorlib_cache")
+ # Expect 4 subdirectories: 2 tasks × 2 jobs
+ self.assertEqual(len(entries), 4)
+ for e in entries:
+ path = os.path.join("executorlib_cache", e)
+ self.assertTrue(os.path.isdir(path), f"{path} should be a directory")This will ensure both the per‐task directory logic and multi‐job isolation are properly validated. 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add input validation and improve robustness of folder name extraction.
The current implementation has several potential issues:
commandis empty, which would causeIndexErroroncommand[-1]command[-1]contains "_i.h5", but if it doesn't, the entire string becomes the folder nameConsider this more robust implementation:
📝 Committable suggestion
🤖 Prompt for AI Agents