-
Notifications
You must be signed in to change notification settings - Fork 3
Extend the features supported by get_cache_execute_command() #783
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 all commits
8f761fc
d28b0ab
88a5fd4
a36c238
99f8eec
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,8 @@ def get_cache_execute_command( | |||||||||||||||||
| file_name: str, | ||||||||||||||||||
| cores: int = 1, | ||||||||||||||||||
| backend: Optional[str] = None, | ||||||||||||||||||
| exclusive: bool = False, | ||||||||||||||||||
| openmpi_oversubscribe: bool = False, | ||||||||||||||||||
| pmi_mode: Optional[str] = None, | ||||||||||||||||||
| ) -> list: | ||||||||||||||||||
| """ | ||||||||||||||||||
|
|
@@ -30,7 +32,9 @@ def get_cache_execute_command( | |||||||||||||||||
| file_name (str): The name of the file. | ||||||||||||||||||
| cores (int, optional): Number of cores used to execute the task. Defaults to 1. | ||||||||||||||||||
| backend (str, optional): name of the backend used to spawn tasks ["slurm", "flux"]. | ||||||||||||||||||
| pmi_mode (str): PMI interface to use (OpenMPI v5 requires pmix) default is None (Flux only) | ||||||||||||||||||
| exclusive (bool): Whether to exclusively reserve the compute nodes, or allow sharing compute notes. Defaults to False. | ||||||||||||||||||
| openmpi_oversubscribe (bool, optional): Whether to oversubscribe the cores. Defaults to False. | ||||||||||||||||||
| pmi_mode (str): PMI interface to use (OpenMPI v5 requires pmix) default is None | ||||||||||||||||||
|
Comment on lines
+35
to
+37
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. Docstring fixes: correct typo and reflect backend limitations
Apply this diff: - exclusive (bool): Whether to exclusively reserve the compute nodes, or allow sharing compute notes. Defaults to False.
- openmpi_oversubscribe (bool, optional): Whether to oversubscribe the cores. Defaults to False.
- pmi_mode (str): PMI interface to use (OpenMPI v5 requires pmix) default is None
+ pmi_mode (str): PMI interface to use (OpenMPI v5 requires pmix). Default is None.
+ exclusive (bool): Whether to exclusively reserve the compute nodes (no node sharing). Default: False.
+ Note: Not supported with the "flux" backend.
+ openmpi_oversubscribe (bool): Whether to oversubscribe the cores. Default: False.
+ Note: Not supported with the "flux" backend.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| Returns: | ||||||||||||||||||
| list[str]: List of strings containing the python executable path and the backend script to execute | ||||||||||||||||||
|
|
@@ -47,6 +51,10 @@ def get_cache_execute_command( | |||||||||||||||||
| command_prepend = ["srun", "-n", str(cores)] | ||||||||||||||||||
| if pmi_mode is not None: | ||||||||||||||||||
| command_prepend += ["--mpi=" + pmi_mode] | ||||||||||||||||||
| if openmpi_oversubscribe: | ||||||||||||||||||
| command_prepend += ["--oversubscribe"] | ||||||||||||||||||
| if exclusive: | ||||||||||||||||||
| command_prepend += ["--exact"] | ||||||||||||||||||
|
Comment on lines
+56
to
+57
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. Wrong Slurm flag for exclusive allocation — use
Apply this diff: - if exclusive:
- command_prepend += ["--exact"]
+ if exclusive:
+ command_prepend += ["--exclusive"]📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| command_lst = ( | ||||||||||||||||||
| command_prepend | ||||||||||||||||||
| + command_lst | ||||||||||||||||||
|
|
@@ -56,6 +64,14 @@ def get_cache_execute_command( | |||||||||||||||||
| flux_command = ["flux", "run"] | ||||||||||||||||||
| if pmi_mode is not None: | ||||||||||||||||||
| flux_command += ["-o", "pmi=" + pmi_mode] | ||||||||||||||||||
| if openmpi_oversubscribe: | ||||||||||||||||||
| raise ValueError( | ||||||||||||||||||
| "The option openmpi_oversubscribe is not available with the flux backend." | ||||||||||||||||||
| ) | ||||||||||||||||||
| if exclusive: | ||||||||||||||||||
| raise ValueError( | ||||||||||||||||||
| "The option exclusive is not available with the flux backend." | ||||||||||||||||||
| ) | ||||||||||||||||||
| command_lst = ( | ||||||||||||||||||
| flux_command | ||||||||||||||||||
| + ["-n", str(cores)] | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,14 +51,16 @@ def test_get_cache_execute_command_parallel(self): | ||||||||||
| self.assertEqual(output[3], sys.executable) | |||||||||||
| self.assertEqual(output[4].split(os.sep)[-1], "cache_parallel.py") | |||||||||||
| self.assertEqual(output[5], file_name) | |||||||||||
| output = get_cache_execute_command(cores=2, file_name=file_name, backend="slurm", pmi_mode="pmi2") | |||||||||||
| output = get_cache_execute_command(cores=2, file_name=file_name, backend="slurm", pmi_mode="pmi2", openmpi_oversubscribe=True, exclusive=True) | |||||||||||
| self.assertEqual(output[0], "srun") | |||||||||||
| self.assertEqual(output[1], "-n") | |||||||||||
| self.assertEqual(output[2], str(2)) | |||||||||||
| self.assertEqual(output[3], "--mpi=pmi2") | |||||||||||
| self.assertEqual(output[4], sys.executable) | |||||||||||
| self.assertEqual(output[5].split(os.sep)[-1], "cache_parallel.py") | |||||||||||
| self.assertEqual(output[6], file_name) | |||||||||||
| self.assertEqual(output[4], "--oversubscribe") | |||||||||||
| self.assertEqual(output[5], "--exact") | |||||||||||
| self.assertEqual(output[6], sys.executable) | |||||||||||
| self.assertEqual(output[7].split(os.sep)[-1], "cache_parallel.py") | |||||||||||
| self.assertEqual(output[8], file_name) | |||||||||||
|
Comment on lines
+54
to
+63
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 chainConfirm intent: Docstring semantics (“exclusively reserve the compute nodes”) map to Slurm’s Apply this test-only diff if exclusive nodes are intended: - self.assertEqual(output[5], "--exact")
+ self.assertEqual(output[5], "--exclusive")And update the Slurm path in executorlib/standalone/command.py accordingly: # Replace the --exact flag with --exclusive for 'exclusive=True'
if exclusive:
command_prepend += ["--exclusive"]To verify the correct Slurm flag for exclusive node allocation: 🌐 Web query: 💡 Result: The correct option in Slurm's srun to enforce exclusive node allocation is Option purposes:
Summary Table
References for option meanings:
In summary: Citations:
Replace Slurm’s • tests/test_standalone_command.py (around line 60): - self.assertEqual(output[5], "--exact")
+ self.assertEqual(output[5], "--exclusive")• executorlib/standalone/command.py (where - if exclusive:
- command_prepend += ["--exact"]
+ if exclusive:
+ command_prepend += ["--exclusive"]🤖 Prompt for AI Agents |
|||||||||||
| output = get_cache_execute_command(cores=2, file_name=file_name, backend="slurm") | |||||||||||
| self.assertEqual(output[0], "srun") | |||||||||||
| self.assertEqual(output[1], "-n") | |||||||||||
|
|
@@ -86,3 +88,7 @@ def test_get_cache_execute_command_parallel(self): | ||||||||||
| self.assertEqual(output[8], file_name) | |||||||||||
| with self.assertRaises(ValueError): | |||||||||||
| get_cache_execute_command(cores=2, file_name=file_name, backend="test") | |||||||||||
| with self.assertRaises(ValueError): | |||||||||||
| get_cache_execute_command(cores=2, file_name=file_name, backend="flux", openmpi_oversubscribe=True) | |||||||||||
| with self.assertRaises(ValueError): | |||||||||||
| get_cache_execute_command(cores=2, file_name=file_name, backend="flux", exclusive=True) | |||||||||||
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.
💡 Verification agent
🧩 Analysis chain
Avoid breaking API: keep
pmi_modepositional slot and make new flags keyword-onlyInserting
exclusiveandopenmpi_oversubscribebeforepmi_modechanges the positional argument order and will break callers that passedpmi_modepositionally. Preserve backward compatibility by keepingpmi_modeas the 4th parameter and making the new flags keyword-only.Apply this diff to the function signature:
To locate potential breakages (calls with four positional args), run:
🏁 Script executed:
Length of output: 915
Avoid breaking API: keep
pmi_modeas the 4th positional argument and make new flags keyword-onlyI ran an AST search—every existing call uses keyword arguments, so there’s no internal breakage. However, to preserve the public API for callers who may pass
pmi_modepositionally, update the signature in executorlib/standalone/command.py as follows:This keeps
pmi_modein its original (4th) slot and forcesexclusiveandopenmpi_oversubscribeto be keyword-only.📝 Committable suggestion
🤖 Prompt for AI Agents