-
Notifications
You must be signed in to change notification settings - Fork 192
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
Restore proper mutability implementation of Node attributes #1111
Merged
giovannipizzi
merged 9 commits into
aiidateam:release_v0.11.1
from
sphuber:fix_1109_mutable_attributes
Feb 22, 2018
Merged
Restore proper mutability implementation of Node attributes #1111
giovannipizzi
merged 9 commits into
aiidateam:release_v0.11.1
from
sphuber:fix_1109_mutable_attributes
Feb 22, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sphuber
added
type/bug
priority/critical-blocking
must be resolved before next release
topic/provenance
labels
Feb 12, 2018
Suggested additions/changes:
|
sphuber
force-pushed
the
fix_1109_mutable_attributes
branch
6 times, most recently
from
February 22, 2018 11:30
01514a4
to
04270ee
Compare
This was referenced Feb 22, 2018
The check for node attribute immutability, i.e. when a node is stored its attributes are to be immutable, was moved out of the base Node class and moved to the Data class and the SealableWithUpdatableAttributes mixin, in order to allow for Calculation attributes that needed to be mutable even after storing the node, e.g. the calculation state. However, the logic was improperly implemented and not applied everywhere leaving certain nodes with all attributes mutable even after being stored. To prevent this error from happening in the future, we move the check back to the Node class. The calculation classes will have to override this behavior in the future to allow for updatable attributes
The attribues of the Node class become immutable once the node is stored. However, for some Node subclasses one needs to allow for certain attributes to be updatable even after storing. An example is the Calculation class. For it to run, it needs to be stored, however its running state is stored in an attribute which needs to be updated despite the underlying node already being stored. To solve this we introduce the Sealable mixin, which can defined a tuple of updatable attributes that are mutable even when the node is stored. It also provides the 'sealed' attribute which when set even the updatable attributes become immutable
…utes This was already done in PR aiidateam#652 that was merged into develop but needs to be done in this branch as well for consistency, which will be merged into the v0.11.1 patch release
The 'input_plugin', 'append_text' and 'prepend_text' attributes should not really be updatable as they can really alter the behavior of the code. For that reason we remove them from the updatable_attributes. The 'hidden' attribute can be turned into an extra, as it really is more meta-data that is only pertinent to the user that owns the code. That leaves no updatable attributes for this class, which means the Sealable mixin can be removed.
sphuber
force-pushed
the
fix_1109_mutable_attributes
branch
from
February 22, 2018 14:18
04270ee
to
45869f2
Compare
sphuber
force-pushed
the
fix_1109_mutable_attributes
branch
2 times, most recently
from
February 22, 2018 15:54
ce87800
to
1f074c6
Compare
The -a switch for verdi code list was broken because it filtered on the hidden attribute in a hardcoded way and just checked if the hidden property was not True. However if it is not set at all, which is the default, then it should also be ignored.
sphuber
force-pushed
the
fix_1109_mutable_attributes
branch
from
February 22, 2018 16:03
1f074c6
to
03cd3cb
Compare
To make sure that it properly extends the mutable attributes from AbstractCalculation, we subclass from AbstractCalculation instead of just object
giovannipizzi
approved these changes
Feb 22, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1109
The concept of attribute immutability has been properly reinstated. The current conception of node attribute mutability is the following.
Node
is storedSealable
mixin are immutable when the node issealed
or whenstored
and the attribute is not in the_updatable_attributes
tupleTo enforce this behavior, the
is_stored
check is moved back into the_set_attr
and_del_attr
methods of theAbstractNode
class. TheSealable
mixin, allows theAbstractCalculation
,WorkCalculation
andCode
subclasses ofNode
to define a tuple of_updatable_attributes
that can be mutated as long as the node is not sealed.The updatable attributes that were defined for the
Code
class,input_plugin
,prepend_text
,append_text
andhidden
have been removed, allowing theSealable
mixin to be removed. The first three really should be immutable as changing them can really affect the outcome of calculations run with that code. Thehidden
attribute is more a meta data attribute, specific to the user that owns the code and therefore better belongs in the extras of the node