Hi, I want to de-register some flows programatical...
# prefect-community
m
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.
a
All of what you're asking is possible via GraphQL. #1 To list all flows, use the flow query. One example:
Copy code
query {
  flow {
    flow_group_id
    name
    project {
      name
    }
    version
  }
}
# 2 To archive (aka deregister) some flows, use this mutation
Copy code
mutation {
  archive_flow(input: {flow_id: "0f94bd12-87d7-4fb6-b3a1-cebb510db8d3"}) {
    success
  }
}
to use those in Python:
Copy code
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
m
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!
👍 1