Skip to content

Refactor the function process decorator#2246

Merged
sphuber merged 1 commit into
aiidateam:provenance_redesignfrom
sphuber:fix_2171_refactor_workfunction_decorator
Nov 29, 2018
Merged

Refactor the function process decorator#2246
sphuber merged 1 commit into
aiidateam:provenance_redesignfrom
sphuber:fix_2171_refactor_workfunction_decorator

Conversation

@sphuber
Copy link
Copy Markdown
Contributor

@sphuber sphuber commented Nov 29, 2018

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 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.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-6.9%) to 62.066% when pulling 1aabfeea92428122a240e396324b563169161081 on sphuber:fix_2171_refactor_workfunction_decorator into 3956299 on aiidateam:provenance_redesign.

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 29, 2018

Coverage Status

Coverage decreased (-0.02%) to 68.994% when pulling 08cee66 on sphuber:fix_2171_refactor_workfunction_decorator into 3956299 on aiidateam:provenance_redesign.

@sphuber sphuber force-pushed the fix_2171_refactor_workfunction_decorator branch from 1aabfee to 2147654 Compare November 29, 2018 08:27
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.
@sphuber sphuber force-pushed the fix_2171_refactor_workfunction_decorator branch from 2147654 to 08cee66 Compare November 29, 2018 08:51
@muhrin
Copy link
Copy Markdown
Contributor

muhrin commented Nov 29, 2018

I like

@sphuber sphuber merged commit fa8f617 into aiidateam:provenance_redesign Nov 29, 2018
@sphuber sphuber deleted the fix_2171_refactor_workfunction_decorator branch November 29, 2018 09:28
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.

3 participants