Skip to content

ENH: Support for specific node caching - #127

Open
Carwyn Pelley (cpelley) wants to merge 7 commits into
mainfrom
controllable_pickle
Open

Carwyn Pelley (cpelley) wants to merge 7 commits into
mainfrom
controllable_pickle

Conversation

@cpelley

@cpelley Carwyn Pelley (cpelley) commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Utilises existing DAGrunner cache support to provide:

  • Per-node cache control, extending the previously supported global on/off behaviour.
  • Atomic cache writes to improve robustness and prevent partial cache files.
  • Cache filenames now incorporate a tokenised extract value to guarantee uniqueness and avoid collisions.
  • Additional unit test coverage.
  • Dependency updates, including correcting an overly restrictive Python version upper bound that inadvertently limited support to Python 3.9 Needed updating now so as not to unnecessarily handle differences in tokenization with dask.

This change may be relevant to EPP, based on my current understanding of the caching-related issue they are investigating.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. Tests pass as required.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

There are correctness/security issues in the cache file path construction and the cache “atomic” write behavior, plus a dry-run caching bug and a test isolation issue that should be fixed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

This PR enhances DAGrunner’s caching capabilities by allowing per-node opt-in caching, improving cache file naming uniqueness, and adding/adjusting tests around cache utilization.

Changes:

  • Added cache_result to plugin_executor to enable caching on a per-node basis (in addition to the existing global cache toggle).
  • Updated _PickleCache pickle filename scheme to include a tokenized component and changed the write path intended to be more atomic.
  • Added a unit test for single-node caching and updated existing cache-related test naming/docs.
File Description
dagrunner/​utils/​_cache.py Adjusts cache file naming and cache write behavior.
dagrunner/​execute_graph.py Adds per-node caching control via cache_result and documents it.
dagrunner/​tests/​execute_graph/​test_plugin_executor.py Renames global cache test and adds a single-node cache test + fixture.
dagrunner/​tests/​execute_graph/​test_integration.py Updates cache utilization test docstring to reflect graph filtering behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread dagrunner/execute_graph.py Outdated
Comment thread dagrunner/utils/_cache.py Outdated
Comment thread dagrunner/tests/execute_graph/test_plugin_executor.py Outdated
Comment thread .github/workflows/tests.yml Outdated
Comment thread dagrunner/utils/_cache.py
Comment thread dagrunner/utils/_cache.py
Comment on lines +57 to +58
except FileExistsError:
print(f"pickle file already exists for {self._node_id}, skipping dump")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be configurable? Do we want this to always be the behavior that occurs when a file exists already?

@cpelley Carwyn Pelley (cpelley) Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is an edge-case scenario.

Under normal operation, if a cache entry already exists, plugin_executor does not execute the node. Instead, it loads and returns the cached result (i.e. it wouldn't get to this exception).

This particular test covers the case where two identical nodes, called with the same input arguments, are executed concurrently from different graphs and neither finds an existing cache entry when execution begins.

In this situation, both executions proceed independently. By the time the second execution completes, the first may already have written the cache file. There is no meaningful distinction between the two results, as they are produced by the same node with the same inputs. The only difference is that they do not finish at exactly the same time.

In other words, this scenario only arises when two identical node executions, with identical input data, are running concurrently. Users who expect this pattern should likely configure a dedicated cache directory as described in the global configuration documentation so that cache doesn't collide.

Comment thread dagrunner/execute_graph.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants