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

Add operation.with_directives decorator #502

Merged
merged 24 commits into from
May 21, 2021

Conversation

b-butler
Copy link
Member

@b-butler b-butler commented Apr 20, 2021

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 a FlowProject 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

  • Documentation update
  • Bug fix
  • New feature
  • Breaking change1

1The change breaks (or has the potential to break) existing functionality.

Checklist:

If necessary:

  • I have updated the API documentation as part of the package doc-strings.
  • I have created a separate pull request to update the framework documentation on signac-docs and linked it here.
  • I have updated the changelog.

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.
@b-butler b-butler requested review from a team as code owners April 20, 2021 20:32
@b-butler b-butler requested review from kidrahahjo and lyrivera and removed request for a team April 20, 2021 20:32
Copy link
Member

@bdice bdice left a 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.

tests/test_project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
doc/api.rst Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 21, 2021

Codecov Report

Merging #502 (895fa20) into master (e56c84b) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
flow/directives.py 98.03% <ø> (ø)
flow/environments/incite.py 88.73% <ø> (ø)
flow/operations.py 83.33% <100.00%> (+0.98%) ⬆️
flow/project.py 77.69% <100.00%> (-0.10%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e56c84b...895fa20. Read the comment docs.

@b-butler b-butler requested a review from bdice April 21, 2021 19:48
@b-butler
Copy link
Member Author

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.

Copy link
Member

@bdice bdice left a 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.

flow/environments/incite.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
@b-butler b-butler requested a review from bdice May 13, 2021 23:59
Copy link
Member

@bdice bdice left a 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!

flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
tests/define_test_project.py Outdated Show resolved Hide resolved
tests/test_project.py Outdated Show resolved Hide resolved
@bdice bdice added this to the v0.15.0 milestone May 14, 2021
@bdice bdice added directives Operation directives enhancement New feature or request labels May 14, 2021
@bdice
Copy link
Member

bdice commented May 17, 2021

@b-butler Can you resolve merge conflicts? I think that some nontrivial change may be required.

@b-butler
Copy link
Member Author

@bdice Done.

Copy link
Collaborator

@kidrahahjo kidrahahjo left a comment

Choose a reason for hiding this comment

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

I really like this implementation. These changes look good to me. @b-butler @bdice Is there a need to add documentation for this in signac-docs?

@b-butler
Copy link
Member Author

@kidrahahjo there is a docs PR glotzerlab/signac-docs#128

@b-butler b-butler merged commit d3f54fb into master May 21, 2021
@b-butler b-butler deleted the feature/operation-with-directives branch May 21, 2021 17:22
@b-butler b-butler linked an issue Jun 23, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
directives Operation directives enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move directives decorator to operations.directive
3 participants