future-hospital-70237
06/03/2025, 7:53 AMjolly-florist-66728
06/03/2025, 7:53 AM@dynamic
creates a dynamic workflow whose DAG is constructed at runtime, allowing you to use Python control flow (like loops and conditionals) to generate tasks and dependencies dynamically, while @task
nesting (calling a task from within another task) is not supported and can lead to unexpected behavior—nested tasks run in the same process, not as separate Flyte tasks, and Flyte emits warnings or errors for this pattern. Dynamic workflows are the recommended way to achieve dynamic or conditional task execution in Flyte, as they are compiled and executed at runtime and can generate subworkflows on the fly, whereas tasks should not invoke other tasks directly except via workflows or dynamic workflows.
For example, using @dynamic
allows you to loop over inputs and spawn tasks dynamically, and each task runs as a separate Flyte execution unit. In contrast, calling a task from within another task just executes the function locally, not as a Flyte task, and is discouraged in the documentation and codebase. See Dynamic workflows and Nested @task invocations should not supported for more details.
Would you like more detail or code examples?
Sources:
- Dynamic workflows
- Nested @task invocations should not supported 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.future-hospital-70237
06/03/2025, 8:22 AMjolly-florist-66728
06/03/2025, 8:22 AM@dynamic
workflow using the requests
and limits
parameters, just like with @task
. These resource specifications will apply to the dynamic workflow's execution container, which constructs the subworkflow at runtime. Use the Resources
object to specify these values, e.g., @dynamic(requests=Resources(cpu="2", mem="4Gi"), limits=Resources(cpu="4", mem="8Gi"))
see API reference.
Would you like a code example or more detail?
Sources:
- flytekit.core.environment dynamic API reference 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.future-hospital-70237
06/03/2025, 10:19 AMjolly-florist-66728
06/03/2025, 10:19 AMfuture-hospital-70237
06/03/2025, 10:20 AMjolly-florist-66728
06/03/2025, 10:20 AMkubectl logs
) and see no output, but expect logs, this usually indicates that your task code is not writing to stdout/stderr, or the process may not have started, exited early, or is writing logs to a file instead of the console. Also, if the pod is still pending or initializing, logs may not be available yet. See debugging executions guide for steps to investigate.
Would you like more detailed troubleshooting steps for missing pod logs?
Sources:
- debugging executions guide 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.future-hospital-70237
06/05/2025, 8:04 AMjolly-florist-66728
06/05/2025, 8:04 AM@dynamic
workflows can increase memory usage, as each dynamic invocation generates a new workflow specification (DAG) and stores metadata for all nodes, which accumulates with recursion depth and breadth. Flyte imposes limits on recursion depth to prevent excessive resource consumption and potential system instability, as described in the dynamic workflows documentation and merge sort example.
Would you like more detail on how memory usage grows or best practices for recursive dynamic workflows?
Sources:
- dynamic workflows documentation
- merge sort example 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.future-hospital-70237
06/05/2025, 8:50 AMjolly-florist-66728
06/05/2025, 8:50 AM