Refactor the function process decorator#2246
Merged
sphuber merged 1 commit intoNov 29, 2018
Merged
Conversation
|
Coverage decreased (-6.9%) to 62.066% when pulling 1aabfeea92428122a240e396324b563169161081 on sphuber:fix_2171_refactor_workfunction_decorator into 3956299 on aiidateam:provenance_redesign. |
1aabfee to
2147654
Compare
The `calcfunction` and `workfunction` decorator are essentially running the same code, with the only difference being the type of node they use to represent their execution in the provenance graph. The code has been refactored to a generic `process_function` decorator which takes a node class as an argument. The `calcfunction` and `workfunction` decorators are then simply defined by wrapping the `process_function` with the correct node class, `CalcFunctionNode` and `WorkFunctionNode` respectively. The difference in link rules between the two concrete decorators is also completely defined by those node classes, so the logic of the `FunctionProcess` class that is dynamically generated by the process function decorator can be implemented once. The common functionality of defining and overriding inputs is tested in `test_process_functions`. A `process_function` should never actually be run, but for testing purposes we defined a dummy ORM class. Functionality that is specific to the two concrete decorators, such as which type of links can be created, is tested individually.
2147654 to
08cee66
Compare
muhrin
approved these changes
Nov 29, 2018
Contributor
|
I like |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #2171
Note: I have not updated the documentation as that will require more
work in any case and I leave it for the coding week.
The
calcfunctionandworkfunctiondecorator are essentiallyrunning the same code, with the only difference being the type of
node they use to represent their execution in the provenance graph.
The code has been refactored to a generic
process_functiondecoratorwhich takes a node class as an argument. The
calcfunctionandworkfunctiondecorators are then simply defined by wrapping theprocess_functionwith the correct node class,CalcFunctionNodeandWorkFunctionNoderespectively.The difference in link rules between the two concrete decorators is
also completely defined by those node classes, so the logic of the
FunctionProcessclass that is dynamically generated by the processfunction decorator can be implemented once. The common functionality of
defining and overriding inputs is tested in
test_process_functions.A
process_functionshould never actually be run, but for testingpurposes we defined a dummy ORM class.
Functionality that is specific to the two concrete decorators, such as
which type of links can be created, is tested individually.