Skip to content

[Fix] Rename resource_dict to executor_kwargs#936

Merged
jan-janssen merged 10 commits intomainfrom
executor_kwargs
Feb 22, 2026
Merged

[Fix] Rename resource_dict to executor_kwargs#936
jan-janssen merged 10 commits intomainfrom
executor_kwargs

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Feb 22, 2026

Summary by CodeRabbit

  • Refactor
    • Standardized how executor options are provided and propagated across execution modes; consistent defaults, improved handling of runtime limits, PMI/nesting, logging, host/cache settings, and log-size behavior.
  • Tests
    • Unit tests updated to reflect the standardized executor configuration handling and ensure continued compatibility.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

Warning

Rate limit exceeded

@jan-janssen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Renames resource_dictexecutor_kwargs across executor factories, task schedulers, file-based task utilities, and tests; updates signatures, docstrings, merging/propagation logic, and key lookups to source from executor_kwargs. Adds run_time_limit to FluxClusterExecutor defaults.

Changes

Cohort / File(s) Summary
Executor factories
src/executorlib/executor/flux.py, src/executorlib/executor/single.py, src/executorlib/executor/slurm.py
Factory signatures and docstrings renamed resource_dictexecutor_kwargs; defaults merged into executor_kwargs; validations and keys (cores, threads_per_core, gpus_per_core, oversubscribe/slurm args, pmi_mode, log options) now read from and cleaned on executor_kwargs; schedulers receive executor_kwargs.
Interactive spawner (pysqa)
src/executorlib/task_scheduler/interactive/spawner_pysqa.py
Parameter rename to executor_kwargs; initialize/augment cwd, cache_directory, hostname_localhost, pmi_mode, init_function, backend, config_directory in executor_kwargs; pass executor_kwargs into BlockAllocationTaskScheduler.
File task scheduler & helpers
src/executorlib/task_scheduler/file/task_scheduler.py, src/executorlib/task_scheduler/file/shared.py
Public APIs (FileTaskScheduler.__init__, create_file_executor, execute_tasks_h5, _get_task_input) renamed to accept executor_kwargs; per-task inputs merge executor_kwargs and source cache/log keys from it.
Tests updated
tests/unit/executor/test_single_dependencies.py, tests/unit/task_scheduler/file/test_serial.py, tests/unit/task_scheduler/file/test_mpi.py
Calls and fixtures updated to pass executor_kwargs keyword and dictionaries; assertions/configs updated to match renamed parameter.
Defaults update
src/executorlib/executor/flux.py
FluxClusterExecutor default resources include new run_time_limit; core-related defaults still sourced from executor_kwargs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • liamhuber

Poem

🐰 I hopped through functions, nimble and quick,
I swapped a name — made the kwargs stick,
From flux to slurm, single-node too,
executor_kwargs carries each cue,
A tiny hop, a tidy trick!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.31% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary change: a systematic rename of the resource_dict parameter to executor_kwargs across multiple executor and scheduler modules.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch executor_kwargs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/executorlib/executor/flux.py (3)

183-224: ⚠️ Potential issue | 🔴 Critical

FluxJobExecutor passes stale resource_dict= keyword to create_flux_executor, causing TypeError at runtime.

Both call paths in FluxJobExecutor.__init__ (the dependency-enabled path at Line 187 and the disable_dependencies path at Line 213) still use resource_dict=resource_dict when calling create_flux_executor. Since create_flux_executor's parameter was renamed to executor_kwargs (Line 455), these calls will immediately raise:

TypeError: create_flux_executor() got an unexpected keyword argument 'resource_dict'
🐛 Proposed fix
         executor=create_flux_executor(
             max_workers=max_workers,
             cache_directory=cache_directory,
             max_cores=max_cores,
-            resource_dict=resource_dict,
+            executor_kwargs=resource_dict,
             pmi_mode=pmi_mode,
             flux_executor=flux_executor,
             flux_executor_nesting=flux_executor_nesting,
             flux_log_files=flux_log_files,
             hostname_localhost=hostname_localhost,
             block_allocation=block_allocation,
             init_function=init_function,
             log_obj_size=log_obj_size,
             wait=wait,
         ),

Apply the same fix to both occurrences (lines 187 and 213).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/executorlib/executor/flux.py` around lines 183 - 224, In
FluxJobExecutor.__init__, both calls to create_flux_executor currently pass the
old keyword resource_dict=resource_dict which no longer exists; update both
occurrences to pass the map under the new parameter name
executor_kwargs=resource_dict (i.e., replace resource_dict=resource_dict with
executor_kwargs=resource_dict) so create_flux_executor receives the renamed
argument; ensure you change this in the dependency-enabled path and the
disable_dependencies path inside FluxJobExecutor.__init__ to avoid the
TypeError.

387-400: ⚠️ Potential issue | 🔴 Critical

FluxClusterExecutor passes stale resource_dict= to create_pysqa_block_allocation_scheduler, causing TypeError at runtime.

Line 396 still uses the old resource_dict=resource_dict keyword argument when calling create_pysqa_block_allocation_scheduler. That function's parameter was renamed to executor_kwargs (spawner_pysqa.py Line 230). The equivalent fix in SlurmClusterExecutor was applied correctly (slurm.py Line 192). This path is broken for every FluxClusterExecutor(block_allocation=True) invocation.

🐛 Proposed fix
                 super().__init__(
                     executor=create_pysqa_block_allocation_scheduler(
                         max_cores=max_cores,
                         cache_directory=cache_directory,
                         hostname_localhost=hostname_localhost,
                         log_obj_size=log_obj_size,
                         pmi_mode=pmi_mode,
                         init_function=init_function,
                         max_workers=max_workers,
-                        resource_dict=resource_dict,
+                        executor_kwargs=resource_dict,
                         pysqa_config_directory=pysqa_config_directory,
                         backend="flux",
                     )
                 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/executorlib/executor/flux.py` around lines 387 - 400, FluxClusterExecutor
is still passing the removed keyword resource_dict= to
create_pysqa_block_allocation_scheduler which now expects executor_kwargs;
update the call inside FluxClusterExecutor (where
create_pysqa_block_allocation_scheduler is invoked) to replace
resource_dict=resource_dict with executor_kwargs=resource_dict (or rename the
variable if needed), matching the fix applied in SlurmClusterExecutor and
ensuring the keyword name aligns with the function signature.

406-425: ⚠️ Potential issue | 🔴 Critical

Fix parameter name at line 412: use resource_dict=resource_dict instead of executor_kwargs=resource_dict.

The create_file_executor function signature expects resource_dict as its first parameter, not executor_kwargs. The call in single.py (line 351) and slurm.py (line 209) both correctly use resource_dict=resource_dict, while this call passes executor_kwargs=resource_dict, which will raise TypeError at runtime because the required resource_dict parameter is missing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/executorlib/executor/flux.py` around lines 406 - 425, The call to
create_file_executor inside the super().__init__ block passes the wrong keyword:
it uses executor_kwargs=resource_dict but the function expects resource_dict;
update the keyword to resource_dict=resource_dict in the create_file_executor
invocation (the surrounding call in the constructor that currently includes
executor_kwargs, flux_executor=None, pmi_mode, etc.) so the required
resource_dict parameter is provided and no TypeError is raised.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/executorlib/executor/flux.py`:
- Around line 183-224: In FluxJobExecutor.__init__, both calls to
create_flux_executor currently pass the old keyword resource_dict=resource_dict
which no longer exists; update both occurrences to pass the map under the new
parameter name executor_kwargs=resource_dict (i.e., replace
resource_dict=resource_dict with executor_kwargs=resource_dict) so
create_flux_executor receives the renamed argument; ensure you change this in
the dependency-enabled path and the disable_dependencies path inside
FluxJobExecutor.__init__ to avoid the TypeError.
- Around line 387-400: FluxClusterExecutor is still passing the removed keyword
resource_dict= to create_pysqa_block_allocation_scheduler which now expects
executor_kwargs; update the call inside FluxClusterExecutor (where
create_pysqa_block_allocation_scheduler is invoked) to replace
resource_dict=resource_dict with executor_kwargs=resource_dict (or rename the
variable if needed), matching the fix applied in SlurmClusterExecutor and
ensuring the keyword name aligns with the function signature.
- Around line 406-425: The call to create_file_executor inside the
super().__init__ block passes the wrong keyword: it uses
executor_kwargs=resource_dict but the function expects resource_dict; update the
keyword to resource_dict=resource_dict in the create_file_executor invocation
(the surrounding call in the constructor that currently includes
executor_kwargs, flux_executor=None, pmi_mode, etc.) so the required
resource_dict parameter is provided and no TypeError is raised.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/unit/task_scheduler/file/test_serial.py (2)

124-131: ⚠️ Potential issue | 🔴 Critical

Incomplete rename: execute_tasks_h5 no longer accepts resource_dict kwarg.

Three test methods pass "resource_dict" as a key in the kwargs dict for execute_tasks_h5, but the function signature was renamed to executor_kwargs. These tests will fail with TypeError.

🐛 Proposed fix
         process = Thread(
             target=execute_tasks_h5,
             kwargs={
                 "future_queue": q,
                 "execute_function": execute_in_subprocess,
-                "resource_dict": {"cores": 1, "cwd": None, "cache_directory": cache_dir},
+                "executor_kwargs": {"cores": 1, "cwd": None, "cache_directory": cache_dir},
                 "terminate_function": terminate_subprocess,
             },
         )

Apply this same change in test_executor_function (line 129), test_executor_function_dependence_kwargs (line 169), and test_executor_function_dependence_args (line 209).

Also applies to: 164-171, 204-211

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/task_scheduler/file/test_serial.py` around lines 124 - 131, Tests
are passing a now-removed kwarg name "resource_dict" into execute_tasks_h5;
update the Thread kwargs to use the new parameter name "executor_kwargs" instead
of "resource_dict" wherever execute_tasks_h5 is invoked in the tests
(specifically in the test methods test_executor_function,
test_executor_function_dependence_kwargs, and
test_executor_function_dependence_args) so the call matches the new
execute_tasks_h5 signature.

78-84: ⚠️ Potential issue | 🔴 Critical

Incomplete rename: FileTaskScheduler no longer accepts resource_dict.

The FileTaskScheduler.__init__ signature was renamed from resource_dict to executor_kwargs, but these three tests still pass resource_dict=.... They will raise TypeError: __init__() got an unexpected keyword argument 'resource_dict' at runtime.

🐛 Proposed fix
     def test_executor_working_directory(self):
         cwd = os.path.join(os.path.dirname(__file__), "..", "..", "..", "static")
         with FileTaskScheduler(
-            resource_dict={"cwd": cwd}, execute_function=execute_in_subprocess
+            executor_kwargs={"cwd": cwd}, execute_function=execute_in_subprocess
         ) as exe:
             fs1 = exe.submit(list_files_in_working_directory)
             self.assertEqual(fs1.result(), os.listdir(cwd))

     def test_executor_error(self):
         cwd = os.path.join(os.path.dirname(__file__), "..", "..", "..", "static")
         with FileTaskScheduler(
-            resource_dict={"cwd": cwd}, execute_function=execute_in_subprocess
+            executor_kwargs={"cwd": cwd}, execute_function=execute_in_subprocess
         ) as exe:
             fs1 = exe.submit(get_error, a=1)
             with self.assertRaises(ValueError):
                 fs1.result()
         self.assertEqual(len(os.listdir(cwd)), 1)

     def test_executor_error_file(self):
         cwd = os.path.join(os.path.dirname(__file__), "..", "..", "..", "static")
         with FileTaskScheduler(
-            resource_dict={"cwd": cwd, "error_log_file": "error.out"},
+            executor_kwargs={"cwd": cwd, "error_log_file": "error.out"},
             execute_function=execute_in_subprocess
         ) as exe:

Also applies to: 86-94, 96-108

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/task_scheduler/file/test_serial.py` around lines 78 - 84, The
tests use the old constructor keyword "resource_dict" for FileTaskScheduler
which no longer accepts it; update the tests (e.g.,
test_executor_working_directory and the other failing tests) to pass the same
dict under the new parameter name executor_kwargs when instantiating
FileTaskScheduler (e.g., FileTaskScheduler(executor_kwargs={"cwd": cwd},
execute_function=execute_in_subprocess)); ensure you update every test site that
currently uses resource_dict to use executor_kwargs so __init__ no longer raises
a TypeError.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/unit/task_scheduler/file/test_serial.py`:
- Around line 124-131: Tests are passing a now-removed kwarg name
"resource_dict" into execute_tasks_h5; update the Thread kwargs to use the new
parameter name "executor_kwargs" instead of "resource_dict" wherever
execute_tasks_h5 is invoked in the tests (specifically in the test methods
test_executor_function, test_executor_function_dependence_kwargs, and
test_executor_function_dependence_args) so the call matches the new
execute_tasks_h5 signature.
- Around line 78-84: The tests use the old constructor keyword "resource_dict"
for FileTaskScheduler which no longer accepts it; update the tests (e.g.,
test_executor_working_directory and the other failing tests) to pass the same
dict under the new parameter name executor_kwargs when instantiating
FileTaskScheduler (e.g., FileTaskScheduler(executor_kwargs={"cwd": cwd},
execute_function=execute_in_subprocess)); ensure you update every test site that
currently uses resource_dict to use executor_kwargs so __init__ no longer raises
a TypeError.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/unit/task_scheduler/file/test_serial.py (1)

47-47: ⚠️ Potential issue | 🟠 Major

Fix constructor calls in lines 81, 89, and 99: use executor_kwargs= instead of resource_dict=.

Lines 81, 89, and 99 pass resource_dict= to FileTaskScheduler(), but the constructor parameter was renamed to executor_kwargs. Update these calls from FileTaskScheduler(resource_dict={"cwd": cwd}, ...) to FileTaskScheduler(executor_kwargs={"cwd": cwd}, ...).

Note: Line 47 is correct—submit() still accepts resource_dict as a parameter.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/task_scheduler/file/test_serial.py` at line 47, Update the
constructor calls to FileTaskScheduler: replace any keyword argument
resource_dict= passed into FileTaskScheduler(...) with executor_kwargs= (e.g.
change FileTaskScheduler(resource_dict={"cwd": cwd}, ...) to
FileTaskScheduler(executor_kwargs={"cwd": cwd}, ...)) so the calls match the
renamed constructor parameter; leave submit(...) calls that use resource_dict
unchanged.
src/executorlib/executor/flux.py (1)

366-374: ⚠️ Potential issue | 🟡 Minor

Inconsistency: run_time_limit included in FluxClusterExecutor defaults but not in FluxJobExecutor.

FluxClusterExecutor (line 373) sets "run_time_limit": None as a default in default_resource_dict, ensuring the key is always present in executor_kwargs passed downstream. FluxJobExecutor (lines 96–103) does not include run_time_limit in its defaults, so the key is only present if explicitly provided by the caller. While current downstream usage relies on .get() or value-level checks (e.g., resource_dict.get("run_time_limit"), if self._run_time_limit is not None), this inconsistency between the two executors warrants clarification: is the difference intentional, or should both follow the same pattern?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/executorlib/executor/flux.py` around lines 366 - 374, FluxClusterExecutor
defines "run_time_limit" in its default_resource_dict but FluxJobExecutor's
default_resource_dict (in FluxJobExecutor) omits it, causing inconsistent
presence of the key downstream; update FluxJobExecutor's default_resource_dict
to include "run_time_limit": None (matching FluxClusterExecutor) so
executor_kwargs always contains the key, and ensure any code using
resource_dict.get("run_time_limit") or self._run_time_limit continues to work
unchanged.
🧹 Nitpick comments (1)
src/executorlib/executor/single.py (1)

410-421: executor_kwargs docstring omits run_time_limit.

The SingleNodeExecutor class-level docstring (line 43) and its __init__ docstring (line 128) document run_time_limit as a valid key inside resource_dict/executor_kwargs, but the create_single_node_executor docstring does not list it.

📝 Suggested docstring addition
             executor_kwargs (dict): A dictionary of arguments required by the executor. With the following keys:
                               - cores (int): number of MPI cores to be used for each function call
                               - threads_per_core (int): number of OpenMP threads to be used for each function call
                               - gpus_per_core (int): number of GPUs per worker - defaults to 0
                               - cwd (str/None): current working directory where the parallel python task is executed
                               - openmpi_oversubscribe (bool): adds the `--oversubscribe` command line flag (OpenMPI
                                                               and SLURM only) - default False
                               - slurm_cmd_args (list): Additional command line arguments for the srun call (SLURM
                                                        only)
                               - error_log_file (str): Name of the error log file to use for storing exceptions raised
                                                       by the Python functions submitted to the Executor.
+                              - run_time_limit (int): The maximum runtime in seconds for each task. Default: None
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/executorlib/executor/single.py` around lines 410 - 421, Add documentation
for the run_time_limit key to the create_single_node_executor docstring: mention
that executor_kwargs (aka resource_dict in SingleNodeExecutor.__init__) may
include run_time_limit (int/float) to set a per-task runtime cap (seconds) and
briefly describe its behavior and default; update the docstring near the
executor_kwargs listing in create_single_node_executor to mirror the existing
descriptions in SingleNodeExecutor class-level docstring and __init__ so all
three places (SingleNodeExecutor, __init__, create_single_node_executor)
consistently document run_time_limit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/executorlib/executor/flux.py`:
- Around line 366-374: FluxClusterExecutor defines "run_time_limit" in its
default_resource_dict but FluxJobExecutor's default_resource_dict (in
FluxJobExecutor) omits it, causing inconsistent presence of the key downstream;
update FluxJobExecutor's default_resource_dict to include "run_time_limit": None
(matching FluxClusterExecutor) so executor_kwargs always contains the key, and
ensure any code using resource_dict.get("run_time_limit") or
self._run_time_limit continues to work unchanged.

In `@tests/unit/task_scheduler/file/test_serial.py`:
- Line 47: Update the constructor calls to FileTaskScheduler: replace any
keyword argument resource_dict= passed into FileTaskScheduler(...) with
executor_kwargs= (e.g. change FileTaskScheduler(resource_dict={"cwd": cwd}, ...)
to FileTaskScheduler(executor_kwargs={"cwd": cwd}, ...)) so the calls match the
renamed constructor parameter; leave submit(...) calls that use resource_dict
unchanged.

---

Nitpick comments:
In `@src/executorlib/executor/single.py`:
- Around line 410-421: Add documentation for the run_time_limit key to the
create_single_node_executor docstring: mention that executor_kwargs (aka
resource_dict in SingleNodeExecutor.__init__) may include run_time_limit
(int/float) to set a per-task runtime cap (seconds) and briefly describe its
behavior and default; update the docstring near the executor_kwargs listing in
create_single_node_executor to mirror the existing descriptions in
SingleNodeExecutor class-level docstring and __init__ so all three places
(SingleNodeExecutor, __init__, create_single_node_executor) consistently
document run_time_limit.

@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

❌ Patch coverage is 94.54545% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.91%. Comparing base (e38a2d5) to head (56f2f5d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/executorlib/executor/flux.py 93.75% 1 Missing ⚠️
src/executorlib/executor/single.py 92.85% 1 Missing ⚠️
src/executorlib/executor/slurm.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #936      +/-   ##
==========================================
+ Coverage   93.86%   93.91%   +0.05%     
==========================================
  Files          38       38              
  Lines        1988     1988              
==========================================
+ Hits         1866     1867       +1     
+ Misses        122      121       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jan-janssen jan-janssen merged commit 813d6b5 into main Feb 22, 2026
62 of 63 checks passed
@jan-janssen jan-janssen deleted the executor_kwargs branch February 22, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant