Thread
#prefect-community
    Madhup Sukoon

    Madhup Sukoon

    6 months ago
    Hi, I want to de-register some flows programatically based on certain conditions. Is it possible to:1. Get a list of all registered flows in python (i.e. the Python equivalent of
    prefect get flows
    ), and 2. De-register some of these flows through python.
    Anna Geller

    Anna Geller

    6 months ago
    All of what you're asking is possible via GraphQL. #1 To list all flows, use the flow query. One example:
    query {
      flow {
        flow_group_id
        name
        project {
          name
        }
        version
      }
    }

    2 To archive (aka deregister) some flows, use this mutation

    mutation {
      archive_flow(input: {flow_id: "0f94bd12-87d7-4fb6-b3a1-cebb510db8d3"}) {
        success
      }
    }
    to use those in Python:
    from prefect import Client
    client = Client()
    client.graphql(your_query_or_mutation)
    A similar discussion for reference https://discourse.prefect.io/t/how-to-archive-decommission-a-flow-we-no-longer-use-without-losing-the-run-history/364
    Madhup Sukoon

    Madhup Sukoon

    6 months ago
    Yup, got it to work through graphql. Was wondering if it's possible to do so without GraphQL, directly from the flow objects. Thanks a lot though!