Skip to content

[Feature] Allow cache_directory in resource_dict#945

Merged
jan-janssen merged 5 commits intomainfrom
cache_dir_validation
Mar 3, 2026
Merged

[Feature] Allow cache_directory in resource_dict#945
jan-janssen merged 5 commits intomainfrom
cache_dir_validation

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Mar 2, 2026

Summary by CodeRabbit

  • New Features

    • Added a cache directory option for executors so users can specify where cache files are stored across executor types.
  • Documentation

    • Updated executor and cluster documentation to describe the cache directory configuration and how it is passed to executors.
  • Tests

    • Validation tests updated to accept the new cache directory key in resource configurations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

Warning

Rate limit exceeded

@jan-janssen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 8 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.

📥 Commits

Reviewing files that changed from the base of the PR and between e2a5a34 and 7833ac9.

📒 Files selected for processing (1)
  • docs/trouble_shooting.md
📝 Walkthrough

Walkthrough

Adds a new optional cache_directory parameter across multiple executors and validation: it is accepted in resource validation, surfaced in executor constructors/factories (Flux, SingleNode, Slurm) and propagated into executor_kwargs used to instantiate underlying executors.

Changes

Cohort / File(s) Summary
Flux executor
src/executorlib/executor/flux.py
Add cache_directory to create_flux_executor signature and set executor_kwargs["cache_directory"] = cache_directory; update docstrings. Review propagation into FluxJob/FluxCluster creation.
Single-node & test executors
src/executorlib/executor/single.py
Add cache_directory parameter to SingleNodeExecutor.__init__ and TestClusterExecutor.__init__; propagate through resource_dict and into create_single_node_executor call; update docstrings and validation usage.
Slurm executor
src/executorlib/executor/slurm.py
Ensure create_slurm_executor puts cache_directory into executor_kwargs; document cache_directory in SlurmClusterExecutor/SlurmJobExecutor resource_dict docstrings.
Validation & tests
src/executorlib/standalone/validate.py, tests/unit/standalone/test_validate.py
Add cache_directory: Optional[str]=None to ResourceDictValidation; update unit test expectations to include the new accepted key. Check validation helper that accepts optional keys.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐇 I hopped through functions, left a cozy trail,
A cache folder noted in each executor tale,
Flux, Slurm, SingleNode — now they know the way,
Files safe and tidy for a bright dev day! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: adding support for cache_directory as a parameter in resource_dict across multiple executor implementations.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 cache_dir_validation

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 (1)

578-580: ⚠️ Potential issue | 🟠 Major

Don’t clobber executor_kwargs["cache_directory"] with None.

Line 579 always assigns from the function argument, which drops a value supplied through resource_dict when the top-level cache_directory is unset.

💡 Proposed fix
-    executor_kwargs["cache_directory"] = cache_directory
+    if cache_directory is not None or "cache_directory" not in executor_kwargs:
+        executor_kwargs["cache_directory"] = cache_directory
🤖 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 578 - 580, The code always
overwrites executor_kwargs["cache_directory"] with the local argument
cache_directory (possibly None), which drops a value provided via resource_dict;
change the assignment so you only set executor_kwargs["cache_directory"] when
cache_directory is not None (or when the key is absent), e.g. guard the
assignment with if cache_directory is not None to avoid clobbering an existing
executor_kwargs["cache_directory"] value while leaving cores_per_worker and
hostname_localhost behavior unchanged.
src/executorlib/executor/slurm.py (1)

549-551: ⚠️ Potential issue | 🟠 Major

Preserve resource_dict["cache_directory"] when top-level arg is omitted.

Line 550 unconditionally overwrites the value from executor_kwargs with None when cache_directory isn’t passed explicitly, so resource_dict={"cache_directory": ...} is ignored.

💡 Proposed fix
-    executor_kwargs["cache_directory"] = cache_directory
+    if cache_directory is not None or "cache_directory" not in executor_kwargs:
+        executor_kwargs["cache_directory"] = cache_directory
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/executorlib/executor/slurm.py` around lines 549 - 551, The current
assignment executor_kwargs["cache_directory"] = cache_directory unconditionally
overwrites any cache_directory present in resource_dict when the top-level
cache_directory arg is omitted; change this to preserve
resource_dict["cache_directory"] by only setting
executor_kwargs["cache_directory"] when the local variable cache_directory is
not None (or use executor_kwargs.setdefault("cache_directory", cache_directory)
/ executor_kwargs["cache_directory"] = executor_kwargs.get("cache_directory",
cache_directory)), leaving executor_kwargs' existing value intact; locate this
near cores_per_worker and hostname_localhost in the slurm executor function to
apply the conditional/setdefault update.
src/executorlib/executor/single.py (1)

508-510: ⚠️ Potential issue | 🟠 Major

Respect cache_directory already present in executor_kwargs.

Line 509 currently overwrites any resource_dict["cache_directory"] with None when the top-level parameter isn’t provided, which breaks the newly documented input path.

💡 Proposed fix
-    executor_kwargs["cache_directory"] = cache_directory
+    if cache_directory is not None or "cache_directory" not in executor_kwargs:
+        executor_kwargs["cache_directory"] = cache_directory
🤖 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 508 - 510, The code
unconditionally overwrites executor_kwargs["cache_directory"], stripping any
caller-provided value; change the assignment so it only sets
executor_kwargs["cache_directory"] when no value is already present (i.e., if
"cache_directory" not in executor_kwargs), using the existing cache_directory
variable, so callers that pass a cache_directory inside executor_kwargs are
respected; keep the hostname_localhost assignment as-is.
🤖 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 578-580: The code always overwrites
executor_kwargs["cache_directory"] with the local argument cache_directory
(possibly None), which drops a value provided via resource_dict; change the
assignment so you only set executor_kwargs["cache_directory"] when
cache_directory is not None (or when the key is absent), e.g. guard the
assignment with if cache_directory is not None to avoid clobbering an existing
executor_kwargs["cache_directory"] value while leaving cores_per_worker and
hostname_localhost behavior unchanged.

In `@src/executorlib/executor/single.py`:
- Around line 508-510: The code unconditionally overwrites
executor_kwargs["cache_directory"], stripping any caller-provided value; change
the assignment so it only sets executor_kwargs["cache_directory"] when no value
is already present (i.e., if "cache_directory" not in executor_kwargs), using
the existing cache_directory variable, so callers that pass a cache_directory
inside executor_kwargs are respected; keep the hostname_localhost assignment
as-is.

In `@src/executorlib/executor/slurm.py`:
- Around line 549-551: The current assignment executor_kwargs["cache_directory"]
= cache_directory unconditionally overwrites any cache_directory present in
resource_dict when the top-level cache_directory arg is omitted; change this to
preserve resource_dict["cache_directory"] by only setting
executor_kwargs["cache_directory"] when the local variable cache_directory is
not None (or use executor_kwargs.setdefault("cache_directory", cache_directory)
/ executor_kwargs["cache_directory"] = executor_kwargs.get("cache_directory",
cache_directory)), leaving executor_kwargs' existing value intact; locate this
near cores_per_worker and hostname_localhost in the slurm executor function to
apply the conditional/setdefault update.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66bce31 and 9ba4724.

📒 Files selected for processing (4)
  • src/executorlib/executor/flux.py
  • src/executorlib/executor/single.py
  • src/executorlib/executor/slurm.py
  • src/executorlib/standalone/validate.py

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.06%. Comparing base (eb8b739) to head (7833ac9).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #945      +/-   ##
==========================================
- Coverage   94.10%   94.06%   -0.05%     
==========================================
  Files          39       39              
  Lines        2053     2054       +1     
==========================================
  Hits         1932     1932              
- Misses        121      122       +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 92f0391 into main Mar 3, 2026
34 of 35 checks passed
@jan-janssen jan-janssen deleted the cache_dir_validation branch March 3, 2026 06:36
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.

2 participants