pyiron / pyiron_workflow

Graph-and-node based workflows
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

[patch] Make factory made objects cloudpickleable #305

Closed liamhuber closed 1 month ago

liamhuber commented 1 month ago

The innovation of snippets.factory is to make dynamically generated classes pickleable. However, this is only meant to overcome the unpickleability from the fact they are dynamic -- issues like being defined in the ` of some other function still exist.

This PR handles the situation of decorated factories having <locals> involved in its qualname. Previously, the factories from a decorator always tried to go the re-import route necessary for pickle, but this (a) still didn't work when <locals> was there, and (b) broke cloudpickle's ability to get past <locals>. So now we just give up on the fancy importability in the presence of <locals>. This has no impact on pickle, which would have failed anyway, but lets cloudpickle push through.

As a nice side effect, this lifts a constraint we had on cloudpickle-dependent operations like the NodeOutputJob, which can now work on nodes defined anywhere again.

github-actions[bot] commented 1 month ago

Binder :point_left: Launch a binder notebook on branch _pyiron/pyiron_workflow/pickleerrors

codacy-production[bot] commented 1 month ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
:white_check_mark: +0.01% (target: -1.00%) :white_check_mark: 100.00%
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (9f230e49cc0ad1e1354a8753adc5c3a73dd9ded7) | 3713 | 3292 | 88.66% | | | Head commit (e978186b80ebf4678425abcc1898e8bf325a18db) | 3716 (+3) | 3295 (+3) | 88.67% (**+0.01%**) | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#305) | 5 | 5 | **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: `/ * 100%`

See your quality gate settings    Change summary preferences

Codacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 8976734170

Details


Files with Coverage Reduction New Missed Lines %
snippets/factory.py 3 97.81%
<!-- Total: 3 -->
Totals Coverage Status
Change from base Build 8976724881: 0.01%
Covered Lines: 3295
Relevant Lines: 3716

💛 - Coveralls