Is there a way to skip a flow registration using p...
# prefect-server
l
Is there a way to skip a flow registration using python logic? I have one
flows
directory that registers the same flows in different runtime environments, but some flows I only want to run in
staging
and not in
production
, for example. I register all staging flows using:
Copy code
prefect register -p lib/flows/ --project {project} --label staging
k
Hey @Lana Dann, are you thinking that the this logic would live inside the
python
file? I don’t think there is a way. The only thing I can think of here would be to split up the flows into different folders inside that
flow
folder so that you can register one folder at a time
l
yeah, i tried adding logic like:
Copy code
if os.environ.get("ENVIRONMENT") == "staging":
    with Flow(...) as flow:
        do_things()
but then it doesn’t register at all 😞
b
you can register all of them, and then turn it off the schedule if you don’t want to run. (or even remove the project using graphql or
client.delete_project(project_id)
) example:
Copy code
if os.environ.get("ENVIRONMENT") == "staging":
    for project_name in stage_project:
        query = "query {flow(where:{project: {name: {_eq: %s}}, archived: {_eq: false}}) {id}}" % project_name
        result = client.graphql(query)
        project_id = '"' + result['data']['flow'][0]['id'] + '"'

        # pause flow
        query = "mutation {set_schedule_inactive(input: {flow_id: %s}) {success}}" % project_id
        client.graphql(query)
or sth like that, I don’t know if would work when deployed tho
upvote 1