-
Notifications
You must be signed in to change notification settings - Fork 779
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
Conditional branch documentation + example usage #71
Comments
@russellbrooks Please see this link. We don't formally support conditional branches yet. I will remove the code docstring in a PR soon. |
#72 addresses this concern. |
@savingoyal can this be opened again ? I have raised a PR for it - #76 but I would need some help in writing the tests and any other thing I might have missed. |
@savingoyal just want to check on when can we expect the conditional functionality. I have a use case where i want to check if a array len is zero then end the task and if it is greater than zero then proceed with the following and i tried the following it didn't worked but i think the right answer would be metaflow supporting conditional flows from metaflow import FlowSpec, step, Flow
class SomeFlow(FlowSpec):
"""[summary]
Args:
FlowSpec ([type]): [description]
"""
@step
def start(self):
self.array = []
if len(self.array) == 0:
self.next(self.end)
else:
self.next(self.some_value)
@step
def some_value(self):
print(self.array)
self.next(self.end)
@step
def end(self):
print("End task")
|
@kgrvamsi Yes, you would have to essentially do something like -
|
@thesillystudent We would have to make sure that we are supporting |
Are there any plans on adding |
Bumping this thread. Any sense when we might see this feature? |
@mikejmills curious, what's your use case? I listed some commonly used workarounds here https://gitter.im/metaflow_org/community?at=6079df40a2ac0d38e7be28fc |
Hi those suggestions I think will work, thank you.
Currently I'm using Metaflow for a data ingestion process. I was thinking
of using a conditional to separate data into different streams depending on
a check.
…On Fri, Apr 16, 2021 at 12:09 PM Ville Tuulos ***@***.***> wrote:
@mikejmills <https://github.com/mikejmills> curious, what's your use
case? I listed some commonly used workarounds here
https://gitter.im/metaflow_org/community?at=6079df40a2ac0d38e7be28fc
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#71 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AATP5ZCHWYXQZTRBW35STLDTJCDORANCNFSM4J5OGZUQ>
.
|
These workarounds do pretty well but I've come across a use case that isn't covered yet. I have 10+ steps which should be executed in parallel with conditional execution (i.e. 2 or 3 of them may need to be skipped). Some of these steps include their own foreach branching downstream before joining results downstream. I tried manipulating the args to @step
def troublesome_step(self):
possible_next_steps = [self.step1, self.step2, self.step3, ....]
# Here, self.ignored_steps might be ['step1'] or ['step1', 'step10']
actual_steps = [step for step in possible_next_steps if step.__name__ not in self.ignored_steps]
# Filter out steps that are not needed
self.next(*actual_steps) Unfortunately, the graph parser isn't happy with the list unpacking and throws the error Is there a trick to programmatically filter out undesired steps using something like this? |
@ckrapu Would the |
I think it could work, but the iterable I'd prefer to use in the One high level question that I have is about the graph parsing (in particular the bit that occurs here); AFAICT the arguments supplied to |
The gitter.im link does not seem to take me to the message, but I searched and tracked down the message I think it is pointing to. Copying it here for reference:
Here is the new share link to the message: |
From the flowspec docstring:
It'd be great to have this mentioned on Metaflow's website with an example.
On a related note, this capability makes it easier to introduce cycles into the DAG and while the documentation mentions:
The acyclicity seems to be checked by the linter, however that piece of validation is not disabled using the
--no-pylint
flag. It's alluded to the possibility of a graph with cycles, but it doesn't seem possible to do for now.Example:
Results in:
Keep up the great work and I've been enjoying Metaflow so far!
The text was updated successfully, but these errors were encountered: