Christoph Deil
12/30/2021, 5:21 PMJeremiah
Flow
object was entering its context; once in that context, we could identify Parameter
objects and Task
dependencies through that graph analysis. This tells us the DAG structure and inputs that can be provided at runtime.
Orion is a dynamic engine. This means that the flow structure is discovered at runtime and may modify itself in response to runtime activity. A flow may be run at any time - including from within another flow. Therefore, flows are (almost literally) functions in this paradigm - they have inputs and outputs and can be composed arbitrarily. Hence, a decorator is a much more natural abstraction.
In Orion, strictly speaking, the post-hoc execution of a flow run remains a DAG (task runs execute in a strict order from a retrospective point of view) but the flow object itself does not inherit that constraint.Christoph Deil
12/30/2021, 6:54 PMJeremiah
Parameters
to behave as Tasks
, and be an explicit part of the DAG, so introducing a decorated function (with arguments) would have conflicted with that. But as with many things in Python it’s definitely possible :) For example the decorator in your gist could open a flow context, call the function, return the resulting flow object. However I think you’re also right that it would have introduced a (possibly) uncomfortable question of when the DAG introspection actually took place, especially if your decorated function took arguments.
Maybe one way to sum up the design objectives:
- Prefect Core sought to make the exercise of building static DAG structures as Pythonic as possible by introducing the functional task API (but no similar facility for flows, which were exclusively used as containers for tasks). However, this still involves separate “compile” and “run” steps to discover and execute the DAG.
- Prefect Orion idealizes “code as workflows”, seeking to make all workflow operations as Pythonic as possible to minimize developer overhead. Flows are functions; tasks are functions; run them however you want.Dominik Tornow
12/31/2021, 3:07 AMKevin Kho