https://prefect.io logo
Title
b

Bivu Raj

07/30/2020, 4:55 PM
using the Client class, how do i use the flow name rather that flow uuid? e.g.
client.create_flow_run("a14f9774-e94d-40cc-b019-cb9044e120d4", run_name=f"manually_run_flow")
I understand that there can be multiple versions of the same flow. However, is there a way to query the latest version of UUID for a given flow from the client class itself and not using the graphql api? Thanks
c

Chris White

07/30/2020, 5:02 PM
Hi Bivu - you can instead pass
version_group_id
as a keyword argument to `create_flow_run`; the version group ID of your Flow is a stable ID that will always reference the latest version of your flow
b

Bivu Raj

07/30/2020, 5:09 PM
Thanks Chris. Let me try that and I will let you know. In addition, what would the equivalent of airflow sensor? As in if i need to trigger a flow when new files arrive in a directory, what is the best way of doing that in prefect?
c

Chris White

07/30/2020, 5:10 PM
It depends on a few factors, but ultimately you’d write whatever logic you want to determine whether a new flow run should be created and call that route above; check out this blog post for an example that integrates this natively into S3: https://medium.com/the-prefect-blog/event-driven-workflows-with-aws-lambda-2ef9d8cc8f1a
👍 1
p

Pedro Machado

07/31/2020, 5:00 AM
Is the
version_group_id
automatically generated or do I have to provide it when registering the flow? I have been creating flow runs using the ID I get from
prefect get flows
but I couldn't figure out a way to get the same using the Python client.
c

Chris White

07/31/2020, 3:32 PM
to retrieve the version group ID you can run:
query{
    flow(where: {id: {_eq: "FLOW-ID"}}){
        version_group_id
    }
}
in the interactive API or via the Python Client’s
graphql
method
you can provide a custom version group ID when you register the Flow; if you don’t provide one, one will be automaticalyl generated
p

Pedro Machado

08/01/2020, 6:21 AM
Thanks!