Prefect : 2.0.2 I added the "version" parameter to...
# prefect-community
r
Prefect : 2.0.2 I added the "version" parameter to my flow, but it doesn't show up in the UI. When I go to retrieve the flow model version is not included either.
Copy code
from prefect import flow, get_run_logger

@flow(name="test", version="1.0beta")
def main():
    logger = get_run_logger()
    <http://logger.info|logger.info>(f"Hello World")

if __name__ == "__main__":
    main()
Flow model details:
id=UUID('120dea46-79e8-4f42-99f0-7e300a2b3cb9') name='test' tags=[]
This is big blocker for me as I want to the
create_flow_run
method, but it errors out after you give it a flow model without a version in it. Any suggestion on what i am doing wrong here?
k
Copy code
from prefect import flow, task
import pickle 
from prefect.filesystems import LocalFileSystem

@task
def my_task():
    a = [1, 2, 3]
    local_file_system_block = LocalFileSystem.load("test")

    save_path = f'{local_file_system_block.basepath}/a.pkl'
    pickle.dump(a, open(save_path, 'wb'))


@flow(version="1")
def my_flow():
    my_task()


if __name__ == "__main__":
    my_flow()
I saw the version on the UI on the right panel when clicking the flow run. Can you check again if you see it?
r
Still shows up as None for me. The version is correctly being added to the deployment.yaml file. I just don't see in either my local or cloud UI
@Khuyen Tran what version of Prefect are you using? Can i also see your prefect deployment build command?
k
It could be because your flow didn’t finish running before you check the version. Flow Version will be None when the flow is running, but will have a value then the flow finish running
I’m using 2.0.2
r
@Khuyen Tran thank you that did it. I think my confusion came from trying to use the "create_flow_run" method: After I getting the flow model using "read_flow" method and passing it to the create_flow_run method I would always get a missing flow version error. However digging a little deeper here the orion.schemas.core.flow object doesn't even contain a flow version field. The deployment object contains that field.
k
Could you give me a context of why you use
create_flow_run
?
r
I want to be able to create new flow_runs with different names/tags and parameters using an existing flow. That is the only method that allows me to do that
k
I think what you need is Deployment. Have you tried it?
r
@Khuyen Tran thanks for the help here. I cleared up the confusion on the methods. I did use create_flow_run_from_deployment and that worked, but i was missing the ability to easily add a unique name to each flow run. I had thought i could use the other method since you can add a name, but it uses prefect.flow.Flow() instead of the orion flow object hence my confusion.
k
A deployment allows you configure your flow runs, which includes the name, schedule, storage, and notifications. You can create different deployments for the same flow. Not sure if you actually need the function
create_flow_run_from_deployment
since you can specify a name for a deployment. Maybe I don’t understand your use case here?
r
In my use case my deployment doesn't change. What useful to me is tracking the individual flow runs. For every new flow run that get created (via api) I need to be able to add a unique name/tag and parameters to it. From my end I have 1 script that has 1 deployment that converts data from a webhook we have setup in our platform. What useful here is tracking tasks (flow runs) individually. The concept of deployment is not so useful if you need track and modify at a flow run level.