ancient-wolf-19325
08/07/2024, 4:23 PMfrom flytekit import task, workflow, conditional
@task
def preprocess():
# Preprocessing logic
return True # or False based on some condition
@task
def train():
# Training logic
pass
@task
def evaluate():
# Evaluation logic
pass
@task
def deploy():
# Deployment logic
pass
@workflow
def subworkflow():
train()
evaluate()
deploy()
@workflow
def main_workflow(preprocess_only: bool):
preprocess_result = preprocess()
conditional("preprocess_only").if_(preprocess_only.is_false()).then(
subworkflow()
)
# Example usage
main_workflow(preprocess_only=True)
In this example, the main_workflow will only execute the subworkflow (which contains the train, evaluate, and deploy tasks) if the preprocess_only parameter is False.
Would you like more details on this or other potential solutions?
Sources:
- Flyte Discussion on Conditionals
Slack Link
https://flyte-org.slack.com/archives/CP2HDHKE1/p1723047802.637619 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.