Is there any best practice to obtain a Flow ID by ...
# prefect-community
m
Is there any best practice to obtain a Flow ID by the Flow name with 
prefect.client.Client
? my use case is triggering a Flow from an app.
b
the
cli
module has a bunch of calls related to that. in particular when you do
prefect run cloud
you can pass the name and it looks up the ID
👍 1
j
Yeah there are some good examples in the CLI! Also there are some helper functions such as
with_args
for constructing queries to send to the
client.graphql
method:
Copy code
from prefect import Client
from prefect.utilities.graphql import with_args

c = Client()

name = "my_flow"
c.graphql({
  "query": {
    with_args("flow", {
      "where": {
        "name": {
          "_eq": name
        }
      }
    }): "id"
  }
})