Prefect can run jobs locally. In Prefect 1.0, this could be achieved with either the UniversalRun config or with a LocalRun config. The local agent allows for greater granularity in flow configurations compared to the universal run. For example, environment variables and working directory path configs are exposed.
- The main components of a Prefect flow will remain the same: you have tasks and flows. Tasks are essentially Python functions, while flows apply workflow logic to those tasks.
- We still run the flow locally
- flow is imported with a lowercase ‘f’ rather than uppercase, and now has a decorator: @flow
- there is no longer a concept of flow runners. Prefect 2.0 affords some of the customizability offered with a local flow runner, replacing labels with tags and using environment variables to override default configurations.
- Install Prefect version 2.0+
from prefect import Flowwith
from prefect import flow
- Optionally, configure your flow with tags and environment variables
- You no longer call run on a Flow object, but call the flow as if its a function(see video)
from prefect import flow, task @task def do_something(x: int) -> int: print(x**2) return x**2 @flow def my_flow(tags=["dev"]): do_something(5) if __name__ == "__main__": my_flow()