Release 2.8.6
prefect.runtime
for context access
Many users of Prefect run their flows in highly dynamic environments; because of this it can be incredibly useful to access information about the current flow run or deployment run outside of a flow function for configuration purposes.
For example, if we are running a Prefect deployment within a larger Dask cluster, we might want to use each flow run id as the Dask client name for easier searching of the scheduler logs. Prefect now offers a user-friendly way of accessing this information through the prefect.runtime
namespace:
from prefect.runtime import flow_run
from prefect import flow
from prefect_dask.task_runners import DaskTaskRunner
@flow(task_runner=DaskTaskRunner(client_kwargs = {"name": flow_run.id}))
def my_flow():
...
This will create a Dask client whose name mirrors the flow run ID. Similarly, you can use prefect.runtime
to access parameters that were passed to this deployment run via prefect.runtime.deployment.parameters
. Note that all of these attributes will be empty if they are not available.
See https://github.com/PrefectHQ/prefect/pull/8790 for details.
Other key enhancements and fixes
Enhancements
- Add deployment id support to
run_deployment
— Add deployment id support to `run_deployment` by devanshdoshi9 · Pull Request #7958 · PrefectHQ/prefect · GitHub - Disable Postgres JIT for performance improvements — Disable Postgres JIT by madkinsz · Pull Request #8804 · PrefectHQ/prefect · GitHub
Fixes
- Fix blocking file read in async method
Deployment.load_from_yaml
— Fix blocking file read in `Deployment.load_from_yaml` by madkinsz · Pull Request #8798 · PrefectHQ/prefect · GitHub - Allow tasks and flows to make redundant transitions such as
RUNNING
→RUNNING
— Remove `PreventRedundantTransitions` rule from core task orchestration policy by rpeden · Pull Request #8802 · PrefectHQ/prefect · GitHub
Documentation
- Update workspace roles table to emphasize differences between roles — Update workspace roles table to emphasize differences between roles by billpalombi · Pull Request #8787 · PrefectHQ/prefect · GitHub
- Add webhook block docs — adding webhook block docs by WillRaphaelson · Pull Request #8773 · PrefectHQ/prefect · GitHub
- Update info on Ray’s support for hardware and software — Update info on Ray's support for hardware and software by discdiver · Pull Request #8811 · PrefectHQ/prefect · GitHub
Helm chart
- Helm charts are now automatically published on each Prefect release — chore: trigger helm chart release upon release by parkedwards · Pull Request #8776 · PrefectHQ/prefect · GitHub
Contributors
- @devanshdoshi9
See the release notes for a full list of changes!