m

    Manuel Aristarán

    2 years ago
    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

    2 years ago
    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
    j

    josh

    2 years ago
    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"
      }
    })