jolly-florist-66728
10/11/2024, 12:19 AMfrom flytekit import task, workflow, dynamic
from typing import Callable, Any
@task
def execute_function(func: Callable[..., Any], *args, **kwargs) -> Any:
return func(*args, **kwargs)
@dynamic
def subworkflow(func: Callable[..., Any], *args, **kwargs) -> Any:
return execute_function(func=func, *args, **kwargs)
@workflow
def main_workflow(func: Callable[..., Any], *args, **kwargs) -> Any:
return subworkflow(func=func, *args, **kwargs)
In this example:
1. execute_function
is a task that takes a function and its arguments, and executes it.
2. subworkflow
is a dynamic workflow that calls execute_function
.
3. main_workflow
is the main workflow that passes the function and its arguments to subworkflow
.
Would you like more details or a more complex example?
Sources:
- Flyte Dynamic Workflows
- Flyte Discussion on Dynamic Tasks
Slack Link
https://.slack.com/archives/CP2HDHKE1/p1728605924.500049 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.