metaflow
metaflow copied to clipboard
How can I progress `@step` based on some condition?
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?
@sangwoo-joh Conditions are not supported. Found this via Googling "metaflow conditional step": https://github.com/Netflix/metaflow/issues/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!
what if I want to skip one step based on condition? a --> b --> c
@step
def a(self):
if condition:
self.next(b)
else:
self.next(c)