-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add operation.with_directives decorator #502
Conversation
The new decorator adds the appropriate directives along with registering the function as an operation. To accomplish this, we create a new class operation, that is specific to a ``FlowProject`` class like the preconditions and postconditions. We also use the ``__init__`` method as a decorator function, and only interact with the class and not any instances. In fact, it is impossible with the standard instantiation model to get an ``operation`` object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@b-butler I was curious what this PR did, so I gave it a very quick read-through. I recognize it's early stage, but thought that some design feedback might be helpful.
The overwriting of __init__ does not work
This is necessary since reverting to using an OperationRegister object not class
Codecov Report
@@ Coverage Diff @@
## master #502 +/- ##
==========================================
- Coverage 74.31% 74.31% -0.01%
==========================================
Files 30 30
Lines 2998 3013 +15
Branches 575 577 +2
==========================================
+ Hits 2228 2239 +11
- Misses 621 626 +5
+ Partials 149 148 -1
Continue to review full report at Codecov.
|
This is to make the code coverage tests pass
Here is the documentation PR glotzerlab/signac-docs#128 I also added tests for lines of code that code coverage was failing me for not testing even though I did not write those lines of code, in doing so I fixed a small bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also modify the test files like define_test_project.py
so that they use a mixture of the old and new syntax, at least until we deprecate/remove @directives
.
Also removes @Directives from defined FlowProjects for tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few smaller requests / questions. I approve after those comments are addressed. @lyrivera @kidrahahjo You're both assigned to this PR, could one of you review? Thanks!
Co-authored-by: Bradley Dice <[email protected]>
@b-butler Can you resolve merge conflicts? I think that some nontrivial change may be required. |
@bdice Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kidrahahjo there is a docs PR glotzerlab/signac-docs#128 |
Description
Adds a new decorator which add the appropriate directives along with registering the function as an operation
FlowProject.operation.with_directives
.To accomplish this, we create a new class
OperationRegister
, that is specific to aFlowProject
class like the preconditions and postconditions classes. We use the__call__
magic method for the basic decorator.Motivation and Context
Addresses: #309
Types of Changes
1The change breaks (or has the potential to break) existing functionality.
Checklist:
If necessary: