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

How can I progress @step based on some condition? #1647

Open
sangwoo-joh opened this issue Nov 30, 2023 · 1 comment
Open

How can I progress @step based on some condition? #1647

sangwoo-joh opened this issue Nov 30, 2023 · 1 comment

Comments

@sangwoo-joh
Copy link

For example, the following code seems not working:

class SomeFlow(FlowSpec):
    some_condition = Parameter( ... )

    @step
    def start(self):
        if self.some_condition == ... : 
            self.next(self.a)
        else:
            self.next(self.b)

    @step 
    def a(self): ...

    @step 
    def b(self): ....

How can I do this with metaflow @step?

@maxzheng
Copy link
Contributor

maxzheng commented Dec 7, 2023

@sangwoo-joh Conditions are not supported. Found this via Googling "metaflow conditional step": #71

You can easily workaround that by doing something like this:

self.next(self.a, self.b)

And then inside of a and b, check for self.some_condition and act accordingly.

Alternatively, combine the logic of a and b into c and call c instead where you would use an if/then/else to do different things.

Hope that works for you!

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

No branches or pull requests

2 participants