Hi — is there any way to support conditional flow ...
# ask-metaflow
c
Hi — is there any way to support conditional flow control? I want something like
Copy code
if self.test_days == 0:
            self.next(self.end)

        self.next(self.predict)
but metaflow complains
Copy code
Invalid self.next() transition detected on line 296:
    Multiple self.next() calls detected in step compute_optimal_threshold. Call self.next() only once.
Is there anything better than checking for
if self.test_days == 0:
in every step? If not, was it a purposeful decision for metaflow to have this restriction?
1
a
@cool-father-88039 - one mechanism is to break down your flow into multiple flows and chain them either through events or through the runner api.
through conditions, do you want to execute different business logic or change the structure of the flow?
c
Yes, we use triggered flows heavily elsewhere. I'm hoping to avoid that since it definitely involves additional mental/operational overhead. And we generally like to have 1:1 mappings between business problems and flows. But maybe it makes sense here.
through conditions, do you want to execute different business logic or change the structure of the flow?
More the latter (though I'm not positive I understand what you mean by it). The example I shared is a common one: in an ML pipeline... • if you have a test set, compute predictions for it, evaluate the predictions, compute feature importance / explainability / fairness, and create plots. • otherwise, don't
1
sorry, didn't mean to send to the channel...
looks like there's been some past discussion on this. There are lots more examples / use cases in that link and the links therein.
a
we do have future plans to allow conditional branching in some limited scenarios. arbitrary conditional branching also introduces a lot of complexity at runtime - especially when debugging failures.
👌 1
s
conditionals are now GA
💯 1
❤️ 1
🙌 1