<@ULVA73B9P> Is it possible to get the flow versio...
# ask-marvin
b
@Marvin Is it possible to get the flow version from the runtime? I have a _`result_storage_key`_ on a task that I want to set to: “/”.join( [ “v{flow_run.flow_version}“, “{flow_run.created.year}“, “{flow_run.created.month:02d}“, “{flow_run.created.day:02d}“, “{flow_run.id}“, ] ) But there seems to be no way to get the flow version from the runtime?
m
You can access runtime context information about a flow run using Prefect's runtime module, but as of now, there isn't a direct method exposed to retrieve the flow version. Here’s how you might access other runtime information, such as the flow run name or creation time:
Copy code
python
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?
c
Hey @Blake! Getting the version available in
runtime
makes a lot of sense - to ensure I don't forget, would you mind opening an enhancement request for this?
b