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

plumpy.ProcessListener made persistent support/0.21.x #277

Merged
merged 4 commits into from
Nov 10, 2023

Conversation

rikigigi
Copy link
Member

@rikigigi rikigigi commented Nov 10, 2023

Fixes #273

We implement the persistence of ProcessListener by deriving the class ProcessListener and EventHelper from persistence.Savable. The class EventHelper is moved to a new file because of a circular import with utils and persistence

There was a circular reference issue in the test listener that was storing a reference to the process inside it, making its serialization impossible. To fix the tests an ugly hack was used: storing the reference to the process outside the class in a global dict using id as keys. Some more ugly hacks are needed to check correctly the equality of two processes. We must ignore the fact that the instances if the listener are different.

We call del on dict items of the ProcessListener's global implemented in the test suite to clean the golbal variables

addressed issues in #274

solves aiidateam#273

We implement the persistence of ProcessListener by deriving the class
ProcessListener and EventHelper from persistence.Savable.
The class EventHelper is moved to a new file because of a circular
import with utils and persistence

Fixing the test

There was a circular reference issue in the test listener that was
storing a reference to the process inside it, making its serialization
impossible. To fix the tests an ugly hack was used: storing the
reference to the process outside the class in a global dict using id as
keys. Some more ugly hacks are needed to check correctly the equality of
two processes. We must ignore the fact that the instances if the
listener are different.

We call del on dict items of the ProcessListener's global implemented in the test suite
to clean the golbal variables

addressed issues in aiidateam#274
@rikigigi rikigigi changed the title plumpy.ProcessListener made persistent plumpy.ProcessListener made persistent support/0.21.x Nov 10, 2023
src/plumpy/event_helper.py Outdated Show resolved Hide resolved
src/plumpy/base/utils.py Outdated Show resolved Hide resolved
test/test_processes.py Outdated Show resolved Hide resolved
test/test_processes.py Outdated Show resolved Hide resolved
test/test_processes.py Outdated Show resolved Hide resolved
test/test_workchains.py Outdated Show resolved Hide resolved
test/test_workchains.py Outdated Show resolved Hide resolved
test/test_workchains.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (31f85c7) 90.82% compared to head (303685a) 90.72%.

Additional details and impacted files
@@                Coverage Diff                 @@
##           support/0.21.x     #277      +/-   ##
==================================================
- Coverage           90.82%   90.72%   -0.09%     
==================================================
  Files                  21       22       +1     
  Lines                2973     2995      +22     
==================================================
+ Hits                 2700     2717      +17     
- Misses                273      278       +5     
Files Coverage Δ
src/plumpy/base/utils.py 100.00% <100.00%> (ø)
src/plumpy/utils.py 82.12% <ø> (+0.61%) ⬆️
src/plumpy/processes.py 92.47% <87.50%> (+0.02%) ⬆️
src/plumpy/process_listener.py 85.19% <78.58%> (-8.14%) ⬇️
src/plumpy/event_helper.py 77.42% <77.42%> (ø)

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

src/plumpy/event_helper.py Show resolved Hide resolved
src/plumpy/event_helper.py Outdated Show resolved Hide resolved
@sphuber sphuber self-requested a review November 10, 2023 14:20
Copy link
Collaborator

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks a lot @rikigigi for the nice work and patience during the review process. I will soon make a release with these changes

@sphuber sphuber merged commit 98a375f into aiidateam:support/0.21.x Nov 10, 2023
7 of 9 checks passed
sphuber pushed a commit that referenced this pull request Nov 13, 2023
The `ProcessListener` is made persistable by deriving it, as well as the
`EventHelper` class from `persistence.Savable`. The class `EventHelper`
is moved to a new file because of a circular import that would result
between the `utils` and `persistence` modules.

There was a circular reference issue in the test listener that was
storing a reference to the process inside it, making its serialization
impossible. To fix the tests an ugly hack was used: storing the reference
to the process outside the class in a global dict using id as keys. Some
more ugly hacks were needed to correctly check the equality of two
processes. Instances having different listeners should be ignored.

Cherry-pick: 98a375f
sphuber pushed a commit that referenced this pull request Nov 13, 2023
The `ProcessListener` is made persistable by deriving it, as well as the
`EventHelper` class from `persistence.Savable`. The class `EventHelper`
is moved to a new file because of a circular import that would result
between the `utils` and `persistence` modules.

There was a circular reference issue in the test listener that was
storing a reference to the process inside it, making its serialization
impossible. To fix the tests an ugly hack was used: storing the reference
to the process outside the class in a global dict using id as keys. Some
more ugly hacks were needed to correctly check the equality of two
processes. Instances having different listeners should be ignored.

Cherry-pick: 98a375f
sphuber pushed a commit that referenced this pull request Nov 13, 2023
The `ProcessListener` is made persistable by deriving it, as well as the
`EventHelper` class from `persistence.Savable`. The class `EventHelper`
is moved to a new file because of a circular import that would result
between the `utils` and `persistence` modules.

There was a circular reference issue in the test listener that was
storing a reference to the process inside it, making its serialization
impossible. To fix the tests an ugly hack was used: storing the reference
to the process outside the class in a global dict using id as keys. Some
more ugly hacks were needed to correctly check the equality of two
processes. Instances having different listeners should be ignored.

Cherry-pick: 98a375f
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