https://prefect.io logo
Title
m

Manuel Aristarán

04/07/2020, 9:09 PM
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

Brett Naul

04/07/2020, 9:10 PM
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

josh

04/07/2020, 9:17 PM
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:
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"
  }
})