Blake
08/09/2024, 6:36 PMMarvin
08/09/2024, 6:37 PMpython
from prefect import flow, task
from prefect import runtime
@flow(log_prints=True)
def my_flow(x):
print("Flow run name:", runtime.flow_run.name)
@task
def my_task(y):
print("Task run name:", runtime.task_run.name)
print("Flow run creation time:", runtime.flow_run.created)
my_flow(1)
For more detailed information, refer to the Prefect documentation:
* https://docs.prefect.io/latest/guides/runtime-context/
Regarding your specific requirement for accessing the flow version, it appears this is not currently supported directly. There is a GitHub issue suggesting improvements to runtime parameter access, which indicates that enhancements in this area are being considered:
* https://github.com/PrefectHQ/prefect/issues/9076
For now, if you need the flow version, you might need to fetch it through the Prefect API or set it as an environment variable during deployment and access it through your task.
Would you like to explore using the API for this purpose, or do you have any further questions?Chris White
runtime
makes a lot of sense - to ensure I don't forget, would you mind opening an enhancement request for this?Blake
08/12/2024, 2:36 AM