Skip to content
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

Caching For #613

Merged
merged 4 commits into from
Mar 6, 2025
Merged

Caching For #613

merged 4 commits into from
Mar 6, 2025

Conversation

liamhuber
Copy link
Member

Closes #610

Basically instead of always rebuilding the child graph, we only rebuild it on cache misses. This is still a bit too aggressive of a rebuild, since in principle we only need to rebuild when the lengths of things we're iterating on change. Nonetheless, it's a simple step in the right direction.

@pmrv does the architecture look ok? Also, I'd like to add a test for this, but all I can think of is iterating over standard_nodes.Sleep and making sure it's faster the second time, but I don't really want to make such a slow test -- do you see a more clever route?

@liamhuber liamhuber requested a review from pmrv March 5, 2025 18:22
Copy link

github-actions bot commented Mar 5, 2025

Binder 👈 Launch a binder notebook on branch pyiron/pyiron_workflow/caching_for

Copy link

codacy-production bot commented Mar 5, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.02% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a20262a) 3433 3137 91.38%
Head commit (659c8fb) 3439 (+6) 3143 (+6) 91.39% (+0.02%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#613) 11 11 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@coveralls
Copy link

coveralls commented Mar 5, 2025

Pull Request Test Coverage Report for Build 13689345500

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 17 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 91.393%

Files with Coverage Reduction New Missed Lines %
node.py 17 91.22%
Totals Coverage Status
Change from base Build 13681985530: 0.02%
Covered Lines: 3143
Relevant Lines: 3439

💛 - Coveralls

@pmrv
Copy link
Contributor

pmrv commented Mar 5, 2025

For the tests, what about doing something simple like

counter = 0
@as_function_node('m')
def SideEffectNode(n: int):
  counter += 1
  return n**2

s = SideEffectNode.for_node(iter_on='n')(n=[1,2,3,4])
s.pull()
s.pull()
self.assertEqual(counter, 4)

inside a sub test?

EDIT: I had to edit a few times to get it right, sorry if you're reading on mobile.

Copy link
Contributor

@pmrv pmrv left a comment

Choose a reason for hiding this comment

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

Code itself seems clean enough, and should do what we want so 👍

@liamhuber
Copy link
Member Author

I'll add the test and merge tonight then

liamhuber and others added 2 commits March 5, 2025 17:44
Co-Authored-By: Marvin Poul <[email protected]>
Signed-off-by: liamhuber <[email protected]>
@liamhuber liamhuber merged commit edc4245 into main Mar 6, 2025
19 checks passed
@liamhuber liamhuber deleted the caching_for branch March 6, 2025 01:56
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.

ForNodes don't seem to cache output and have inverse iteration order
3 participants