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

Error for groups that decorate non-operation functions #538

Closed
bdice opened this issue Jun 10, 2021 · 4 comments · Fixed by #544
Closed

Error for groups that decorate non-operation functions #538

bdice opened this issue Jun 10, 2021 · 4 comments · Fixed by #544
Assignees
Labels
bug Something isn't working groups
Milestone

Comments

@bdice
Copy link
Member

bdice commented Jun 10, 2021

Description

I created a group like this and then assigned it to a function but forgot to mark the function as an operation. Like this:

from flow import FlowProject

class MyProject(FlowProject):
    pass

my_group = MyProject.make_group("my_group")

@my_group
def my_operation(job):
    print(job)

We agreed during my live demo in office hours that this should probably throw an error.

One way to do this might be to track how many times the group is used to decorate a function, and then make sure that it has the same number of operations on FlowProject instantiation, during group registration.

System configuration

  • Version of signac-flow: 0.14
@bdice bdice added the bug Something isn't working label Jun 10, 2021
@kidrahahjo
Copy link
Collaborator

@bdice I can fix this if no one has started working on it.

@bdice
Copy link
Member Author

bdice commented Jun 12, 2021

@kidrahahjo Sure, feel free to assign yourself. We discussed how this might be implemented very briefly but we don't have a good design plan in mind. I suggested one way in my comment above but if you see a better approach, go for it.

@kidrahahjo kidrahahjo self-assigned this Jun 13, 2021
@vyasr
Copy link
Contributor

vyasr commented Jun 17, 2021

You could also check if the operation is present in cls._OPERATION_FUNCTIONS, the one caveat there is that it imposes an ordering requirement on the group and operation decorators. Not sure if we want that.

@kidrahahjo
Copy link
Collaborator

The approach @bdice suggested is efficient in nature but then we might not be able to know which function will have this error. I suggest we store the names of the operations and then check whether they're present in the operations we store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working groups
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants