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

Enable copy_from and after conditions with multiple arguments. #120

Merged
merged 7 commits into from
Jul 15, 2019

Conversation

csadorf
Copy link
Contributor

@csadorf csadorf commented Jul 2, 2019

Description

Enable the provision of multiple operation functions as argument to pre.after() and pre/post.copy_from()

Motivation and Context

When generating operation functions programmatically, it is much more convenient to store those in a list and then we can use those lists as argument to the condition functions. Otherwise we cannot use the decorator syntax.

Minimal example:

def setup_foo(i):

    @Project.operation(f'foo-{i}')
    @Project.post.true(f'{foo_{i}')
    def foo(job):
        print(f"{i}th foo!")
        job.doc[f'foo_{i}'] = True

    return foo

foos = [setup_foo(i) for i in range(3)]

@Project.operation
@Project.pre.after(*foos)
def bar(job):
    print('all foos ran!')

Without this feature we would need to awkwardly call Project.pre.after as a function manually:

for foo in foos:
    Project.pre.after(foo)(bar)

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.

So that we can use a list of operation functions instead of a
single operaiton function as argument.
@csadorf csadorf requested review from mikemhenry and vyasr July 2, 2019 21:06
@csadorf csadorf marked this pull request as ready for review July 3, 2019 19:05
@csadorf csadorf requested a review from a team as a code owner July 3, 2019 19:05
@vyasr vyasr added this to the v0.8 milestone Jul 5, 2019
@csadorf csadorf self-assigned this Jul 5, 2019
@csadorf
Copy link
Contributor Author

csadorf commented Jul 11, 2019

@mikemhenry @vyasr Any chance you could review this PR soon? Or should I try to find someone else?

@vyasr
Copy link
Contributor

vyasr commented Jul 11, 2019

I can review, I started going through all the issues/PRs associated with me yesterday and will get around to this one sometime today.

Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

Nice feature. One note, depending on the sequence of the workflow you could end up evaluating conditions multiple times if they're conditions for multiple conditions passed to these decorators. However, not sure that there's a whole lot to be done about that, and it shouldn't matter except for massive projects.

@csadorf
Copy link
Contributor Author

csadorf commented Jul 12, 2019

Nice feature. One note, depending on the sequence of the workflow you could end up evaluating conditions multiple times if they're conditions for multiple conditions passed to these decorators. However, not sure that there's a whole lot to be done about that, and it shouldn't matter except for massive projects.

I agree and I've created issue #125 to keep track of that.

Copy link
Member

@b-butler b-butler left a comment

Choose a reason for hiding this comment

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

I like this generalization. It makes sense and is clean.

Copy link
Collaborator

@mikemhenry mikemhenry left a comment

Choose a reason for hiding this comment

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

Is it possible to add a unit test for this feature?

@csadorf
Copy link
Contributor Author

csadorf commented Jul 14, 2019

Is it possible to add a unit test for this feature?

@mikemhenry I've added a unit test to specifically test this feature.

@mikemhenry
Copy link
Collaborator

LGTM 🎉

@csadorf csadorf merged commit 752eff8 into master Jul 15, 2019
@csadorf
Copy link
Contributor Author

csadorf commented Jul 15, 2019

Thank's for the help @vyasr @mikemhenry @b-butler !

@csadorf csadorf deleted the feature/copy-from-and-after-with-multiple-funcs branch July 15, 2019 22:11
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.

4 participants