-
Notifications
You must be signed in to change notification settings - Fork 3
Change Backend Names #500
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
Change Backend Names #500
Changes from all commits
7dfe655
0e56890
9ad5619
1769ab4
7c5ccab
661f756
93bd0be
5cce4fc
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 |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ def __init__( | |
|
|
||
| def create_file_executor( | ||
| max_workers: int = 1, | ||
| backend: str = "pysqa_flux", | ||
| backend: str = "flux_submission", | ||
|
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. 💡 Codebase verification Update test and error messages for backend naming convention change The verification reveals several issues that need to be addressed:
Required changes:
🔗 Analysis chainBreaking change: Verify impact of backend name change The default backend value has changed from "pysqa_flux" to "flux_submission", which could break existing code. Additionally, the error messages still reference "pysqa based backend" which is inconsistent with the new naming convention. Let's verify the impact and consistency: Consider:
🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check for direct usage of the old backend name
rg "pysqa_flux"
# Check for references to pysqa in error messages and comments
rg -l "pysqa.*backend"
# Check for consistency in backend naming across the codebase
rg "_submission[\"']|\.[\"']submission"
Length of output: 517 Script: #!/bin/bash
# Let's check the content of the test file to understand the test context
cat tests/test_cache_executor_pysqa_flux.py
# Check the actual error messages containing pysqa references
rg -A 2 "pysqa.*backend" executorlib/cache/executor.py
rg -A 2 "pysqa.*backend" executorlib/cache/shared.py
rg -A 2 "pysqa.*backend" executorlib/standalone/inputcheck.py
rg -A 2 "pysqa.*backend" executorlib/__init__.py
# Check if there are any other backend types being used
rg "backend\s*=\s*[\"'][^\"']*[\"']"
Length of output: 6194 |
||
| max_cores: int = 1, | ||
| cache_directory: Optional[str] = None, | ||
| resource_dict: Optional[dict] = None, | ||
|
|
@@ -113,6 +113,6 @@ def create_file_executor( | |
| cache_directory=cache_directory, | ||
| resource_dict=resource_dict, | ||
| pysqa_config_directory=pysqa_config_directory, | ||
| backend=backend.split("pysqa_")[-1], | ||
| backend=backend.split("_submission")[0], | ||
|
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. 🛠️ Refactor suggestion Add validation for backend name format The current implementation assumes all backend names will contain "_submission" without validation. This could lead to unexpected behavior if an invalid backend name is provided. Consider adding validation and proper error handling: - backend=backend.split("_submission")[0],
+ backend=backend.split("_submission")[0] if "_submission" in backend else
+ raise ValueError(f"Invalid backend format: {backend}. Expected format: <backend>_submission")This ensures that:
|
||
| disable_dependencies=disable_dependencies, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -198,13 +198,13 @@ def create_executor( | |||||||||||||||||
| init_function (None): optional function to preset arguments for functions which are submitted later | ||||||||||||||||||
| """ | ||||||||||||||||||
| check_init_function(block_allocation=block_allocation, init_function=init_function) | ||||||||||||||||||
| if flux_executor is not None and backend != "flux": | ||||||||||||||||||
| backend = "flux" | ||||||||||||||||||
| if flux_executor is not None and backend != "flux_allocation": | ||||||||||||||||||
| backend = "flux_allocation" | ||||||||||||||||||
| check_pmi(backend=backend, pmi=flux_executor_pmi_mode) | ||||||||||||||||||
| cores_per_worker = resource_dict["cores"] | ||||||||||||||||||
| resource_dict["cache_directory"] = cache_directory | ||||||||||||||||||
| resource_dict["hostname_localhost"] = hostname_localhost | ||||||||||||||||||
| if backend == "flux": | ||||||||||||||||||
| if backend == "flux_allocation": | ||||||||||||||||||
| check_oversubscribe(oversubscribe=resource_dict["openmpi_oversubscribe"]) | ||||||||||||||||||
| check_command_line_argument_lst( | ||||||||||||||||||
| command_line_argument_lst=resource_dict["slurm_cmd_args"] | ||||||||||||||||||
|
|
@@ -233,7 +233,7 @@ def create_executor( | |||||||||||||||||
| executor_kwargs=resource_dict, | ||||||||||||||||||
| spawner=FluxPythonSpawner, | ||||||||||||||||||
| ) | ||||||||||||||||||
| elif backend == "slurm": | ||||||||||||||||||
| elif backend == "slurm_allocation": | ||||||||||||||||||
| check_executor(executor=flux_executor) | ||||||||||||||||||
| check_nested_flux_executor(nested_flux_executor=flux_executor_nesting) | ||||||||||||||||||
| if block_allocation: | ||||||||||||||||||
|
|
@@ -255,7 +255,7 @@ def create_executor( | |||||||||||||||||
| executor_kwargs=resource_dict, | ||||||||||||||||||
| spawner=SrunSpawner, | ||||||||||||||||||
| ) | ||||||||||||||||||
| else: # backend="local" | ||||||||||||||||||
| elif backend == "local": | ||||||||||||||||||
| check_executor(executor=flux_executor) | ||||||||||||||||||
| check_nested_flux_executor(nested_flux_executor=flux_executor_nesting) | ||||||||||||||||||
| check_threads_per_core(threads_per_core=resource_dict["threads_per_core"]) | ||||||||||||||||||
|
|
@@ -285,3 +285,7 @@ def create_executor( | |||||||||||||||||
| executor_kwargs=resource_dict, | ||||||||||||||||||
| spawner=MpiExecSpawner, | ||||||||||||||||||
| ) | ||||||||||||||||||
| else: | ||||||||||||||||||
| raise ValueError( | ||||||||||||||||||
| "The supported backends are slurm_allocation, slurm_submission, flux_allocation, flux_submission and local." | ||||||||||||||||||
| ) | ||||||||||||||||||
|
Comment on lines
+288
to
+291
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. Unsupported backends mentioned in error message The error message lists Either implement handling for Apply this diff to update the error message: raise ValueError(
- "The supported backends are slurm_allocation, slurm_submission, flux_allocation, flux_submission and local."
+ "The supported backends are slurm_allocation, flux_allocation, and local."
)📝 Committable suggestion
Suggested change
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,9 +117,9 @@ def check_pmi(backend: str, pmi: Optional[str]) -> None: | |
| """ | ||
| Check if pmi is valid for the selected backend and raise a ValueError if it is not. | ||
| """ | ||
| if backend != "flux" and pmi is not None: | ||
| if backend != "flux_allocation" and pmi is not None: | ||
| raise ValueError("The pmi parameter is currently only implemented for flux.") | ||
| elif backend == "flux" and pmi not in ["pmix", "pmi1", "pmi2", None]: | ||
| elif backend == "flux_allocation" and pmi not in ["pmix", "pmi1", "pmi2", None]: | ||
|
Comment on lines
+120
to
+122
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. 💡 Codebase verification Backend name inconsistency detected - update required Several files still use the old "flux" backend name instead of "flux_allocation":
These instances need to be updated to use "flux_allocation" for consistency with the new implementation. 🔗 Analysis chainVerify consistent usage of new backend name. Let's ensure the new backend name "flux_allocation" is used consistently across the codebase. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for any remaining instances of the old "flux" backend name
# and verify consistent usage of "flux_allocation"
echo "Checking for old 'flux' backend references..."
rg --type python '"flux"' -C 2 | grep -v "flux_allocation" | grep -v "flux_submission"
echo "Verifying usage of new 'flux_allocation' backend..."
rg --type python '"flux_allocation"' -C 2
Length of output: 416 Script: #!/bin/bash
# Let's try without specifying file type since Python extension isn't recognized
echo "Checking for old 'flux' backend references..."
rg '"flux"' -C 2 | grep -v "flux_allocation" | grep -v "flux_submission"
echo -e "\nVerifying usage of new 'flux_allocation' backend..."
rg '"flux_allocation"' -C 2
Length of output: 7580 |
||
| raise ValueError( | ||
| "The pmi parameter supports [pmix, pmi1, pmi2], but not: " + pmi | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,7 +69,7 @@ | |||||||||||||
| "source": [ | ||||||||||||||
| "from executorlib import Executor\n", | ||||||||||||||
| "\n", | ||||||||||||||
| "with Executor(max_cores=1, backend=\"flux\") as exe:\n", | ||||||||||||||
| "with Executor(max_cores=1, backend=\"flux_allocation\") as exe:\n", | ||||||||||||||
| " future = exe.submit(sum, [1, 1])\n", | ||||||||||||||
| " print(future.result())" | ||||||||||||||
| ] | ||||||||||||||
|
|
@@ -103,7 +103,7 @@ | |||||||||||||
| " return sum(*args)\n", | ||||||||||||||
| "\n", | ||||||||||||||
| "\n", | ||||||||||||||
| "with Executor(max_cores=2, backend=\"flux\") as exe:\n", | ||||||||||||||
| "with Executor(max_cores=2, backend=\"flux_allocation\") as exe:\n", | ||||||||||||||
| " fs_1 = exe.submit(calc, [2, 1])\n", | ||||||||||||||
| " fs_2 = exe.submit(calc, [2, 2])\n", | ||||||||||||||
| " fs_3 = exe.submit(calc, [2, 3])\n", | ||||||||||||||
|
|
@@ -159,7 +159,7 @@ | |||||||||||||
| " return sum(*args)\n", | ||||||||||||||
| "\n", | ||||||||||||||
| "\n", | ||||||||||||||
| "with Executor(max_cores=2, backend=\"flux\") as exe:\n", | ||||||||||||||
| "with Executor(max_cores=2, backend=\"flux_allocation\") as exe:\n", | ||||||||||||||
| " print(list(exe.map(calc, [[2, 1], [2, 2], [2, 3], [2, 4]])))" | ||||||||||||||
| ] | ||||||||||||||
| }, | ||||||||||||||
|
|
@@ -205,7 +205,7 @@ | |||||||||||||
| " with Executor(\n", | ||||||||||||||
| " # Resource definition on the executor level\n", | ||||||||||||||
| " max_workers=2, # total number of cores available to the Executor\n", | ||||||||||||||
| " backend=\"flux\", # optional in case the backend is not recognized\n", | ||||||||||||||
| " backend=\"flux_allocation\", # optional in case the backend is not recognized\n", | ||||||||||||||
| " # Optional resource definition\n", | ||||||||||||||
| " resource_dict={\n", | ||||||||||||||
| " \"cores\": 1,\n", | ||||||||||||||
|
|
@@ -277,7 +277,7 @@ | |||||||||||||
| " # Resource definition on the executor level\n", | ||||||||||||||
| " max_cores=2, # total number of cores available to the Executor\n", | ||||||||||||||
| " block_allocation=True, # reuse python processes\n", | ||||||||||||||
| " backend=\"flux\",\n", | ||||||||||||||
| " backend=\"flux_allocation\",\n", | ||||||||||||||
| ") as exe:\n", | ||||||||||||||
| " future_obj = exe.submit(\n", | ||||||||||||||
| " calc_function,\n", | ||||||||||||||
|
|
@@ -332,7 +332,7 @@ | |||||||||||||
| "with Executor(\n", | ||||||||||||||
| " max_cores=1,\n", | ||||||||||||||
| " init_function=init_function,\n", | ||||||||||||||
| " backend=\"flux\",\n", | ||||||||||||||
| " backend=\"flux_allocation\",\n", | ||||||||||||||
| " block_allocation=True,\n", | ||||||||||||||
| ") as exe:\n", | ||||||||||||||
| " fs = exe.submit(calc, 2, j=5)\n", | ||||||||||||||
|
|
@@ -462,7 +462,7 @@ | |||||||||||||
| "with Executor(\n", | ||||||||||||||
| " max_cores=2,\n", | ||||||||||||||
| " resource_dict={\"cores\": 2},\n", | ||||||||||||||
| " backend=\"flux\",\n", | ||||||||||||||
| " backend=\"flux_allocation\",\n", | ||||||||||||||
| " flux_executor_pmi_mode=\"pmix\",\n", | ||||||||||||||
| ") as exe:\n", | ||||||||||||||
| " fs = exe.submit(calc, 3)\n", | ||||||||||||||
|
|
@@ -519,7 +519,7 @@ | |||||||||||||
| "with Executor(\n", | ||||||||||||||
| " max_workers=2, \n", | ||||||||||||||
| " gpus_per_worker=1,\n", | ||||||||||||||
| " backend=\"flux\",\n", | ||||||||||||||
| " backend=\"flux_allocation\",\n", | ||||||||||||||
| ") as exe:\n", | ||||||||||||||
| " fs_1 = exe.submit(get_available_gpus)\n", | ||||||||||||||
| " fs_2 = exe.submit(get_available_gpus)\n", | ||||||||||||||
|
|
@@ -627,7 +627,7 @@ | |||||||||||||
| " return parameter_a + parameter_b\n", | ||||||||||||||
| "\n", | ||||||||||||||
| "\n", | ||||||||||||||
| "with Executor(max_cores=2, backend=\"flux\") as exe:\n", | ||||||||||||||
| "with Executor(max_cores=2, backend=\"flux_allocation\") as exe:\n", | ||||||||||||||
| " future_1 = exe.submit(\n", | ||||||||||||||
| " calc_function,\n", | ||||||||||||||
| " 1,\n", | ||||||||||||||
|
|
@@ -672,7 +672,7 @@ | |||||||||||||
| "```\n", | ||||||||||||||
| "from executorlib import Executor\n", | ||||||||||||||
| "\n", | ||||||||||||||
| "with Executor(max_cores=1, backend=\"slurm\") as exe:\n", | ||||||||||||||
| "with Executor(max_cores=1, backend=\"slurm_allocation\") as exe:\n", | ||||||||||||||
| " future = exe.submit(sum, [1,1])\n", | ||||||||||||||
| " print(future.result())\n", | ||||||||||||||
| "```" | ||||||||||||||
|
|
@@ -683,7 +683,7 @@ | |||||||||||||
| "id": "ae8dd860-f90f-47b4-b3e5-664f5c949350", | ||||||||||||||
| "metadata": {}, | ||||||||||||||
| "source": [ | ||||||||||||||
| "The `backend=\"slurm\"` parameter is optional as `executorlib` automatically recognizes if [flux framework](https://flux-framework.org)\n", | ||||||||||||||
| "The `backend=\"slurm_allocation\"` parameter is optional as `executorlib` automatically recognizes if [flux framework](https://flux-framework.org)\n", | ||||||||||||||
| "or SLURM are available. \n", | ||||||||||||||
| "\n", | ||||||||||||||
|
Comment on lines
+686
to
688
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. Fix documentation inconsistency with backend name The documentation mentions Apply this diff to fix the inconsistency: -The `backend="slurm_allocation"` parameter is optional as `executorlib` automatically recognizes if [flux framework](https://flux-framework.org)
+The `backend="flux_allocation"` parameter is optional as `executorlib` automatically recognizes if [flux framework](https://flux-framework.org)📝 Committable suggestion
Suggested change
|
||||||||||||||
| "In addition, the SLURM backend introduces the `command_line_argument_lst=[]` parameter, which allows the user to provide\n", | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,7 @@ def test_check_pmi(self): | |
| with self.assertRaises(ValueError): | ||
| check_pmi(backend="test", pmi="test") | ||
| with self.assertRaises(ValueError): | ||
| check_pmi(backend="flux", pmi="test") | ||
| check_pmi(backend="flux_allocation", pmi="test") | ||
|
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. 💡 Codebase verification Backend name "flux" still exists in some test files and needs to be updated Found inconsistent backend naming that needs attention:
These files should be updated to use 🔗 Analysis chainVerify consistent backend name updates across the codebase. Let's ensure the backend name change from "flux" to "flux_allocation" is consistently applied. Let me try another search strategy without relying on file type detection. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for any remaining instances of the old "flux" backend name
# and verify the new "flux_allocation" name is used consistently
# Search for any remaining standalone "flux" backend references
echo "Checking for old 'flux' backend references:"
rg --type python 'backend="flux"' || rg --type python "backend='flux'"
# Search for the new "flux_allocation" backend references to confirm consistent usage
echo -e "\nVerifying new 'flux_allocation' backend usage:"
rg --type python 'backend="flux_allocation"' || rg --type python "backend='flux_allocation'"
# Search for any flux-related configuration or backend definitions
echo -e "\nChecking backend definitions and configurations:"
ast-grep --pattern 'backend = "flux"' || ast-grep --pattern "backend = 'flux'"
Length of output: 672 Script: #!/bin/bash
# Search for any remaining standalone "flux" backend references
echo "Checking for old 'flux' backend references:"
rg 'backend="flux"' || rg "backend='flux'"
# Search for the new "flux_allocation" backend references
echo -e "\nVerifying new 'flux_allocation' backend usage:"
rg 'backend="flux_allocation"' || rg "backend='flux_allocation'"
# Search for flux-related imports or configurations
echo -e "\nChecking flux-related imports and configurations:"
rg -A 2 'from.*flux' || rg -A 2 'import.*flux'
Length of output: 2478 |
||
|
|
||
| def test_check_nested_flux_executor(self): | ||
| with self.assertRaises(ValueError): | ||
|
|
||
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.
💡 Codebase verification
Based on the shell script results, I can now generate the final response:
Backend naming convention changes are partially implemented
The codebase shows an inconsistent state of backend naming conventions:
_submissionand_allocationsuffixes are used in the core implementationpysqa_prefix, particularly in:executorlib/cache/queue_spawner.py(_pysqa_execute_command)executorlib/standalone/inputcheck.py(check_pysqa_config_directory)🔗 Analysis chain
Verify backend naming convention changes across the codebase
The change from checking "pysqa_" to "_submission" in the backend string represents a significant change in naming conventions. Let's verify this change is consistently applied across the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 9620