https://prefect.io logo
Title
y

Yash

01/21/2022, 12:08 PM
Hi @Anna Geller @Kevin Kho, I have scheduled a flow programatically, but its not geting deleted when Im trying to delete that schedule using mutation
delete_flow_group_schedule
. Is there any way to delete a 'programatically created schedule' by using graphql mutation or client through code.
a

Anna Geller

01/21/2022, 12:21 PM
If you created a schedule in your flow code, the best way to update it would be to remove the schedule in your flow and then reregister. This way, the entire flow including the schedule will get updated. Alternatively, you can programmatically toggle the schedule off using the mutation set_schedule_inactive e.g.:
mutation {
  set_schedule_inactive(input: {
    flow_id: "8e737c4c-194b-4751-ba0c-aaed4a8faf8e"
  }) {
    success
  }
}
y

Yash

01/21/2022, 3:47 PM
Thanks @Anna Geller , To summarize it, a schedule which is registered along with flow through code cant be deleted, but can be deleted if a it is added after its registered. so I'll try to register a flow with no schedule, then create a schedule using the graphql api, and then delete that schedule using a graphql api.
a

Anna Geller

01/21/2022, 3:58 PM
Regardless of how you create a schedule (whether inside of your flow code or through the UI or API), you can always disable the schedule by toggling the schedule off- either in the UI or through the set_schedule_inactive mutation. Does it answer your question?
y

Yash

01/21/2022, 4:01 PM
I don't want to set it inactive, I want to delete existing schedule and then add a new schedule.
k

Kevin Kho

01/21/2022, 4:14 PM
I think this is very hard because the
flow_group_schedule
is the one that you attach in the UI. For the one that comes through registration, it gets added to the Flow. So in GraphQL, if you do:
query{
  flow {
    name
    schedule
  }
}
You will see the schedule. This means that editing the schedule means you need to edit the Flow object itself. Effectively, this is a re-registration. If you did it purely in GraphQL, you would need to pull the serialized flow, edit it, and then
create_flow_from_compressed_string
and pass it back in.
At that point, it’s significantly easier to just register the flow again with the Python API. So your best bet is leaving the schedule blank at registration, and then just using the
flow_group_schedule
to add/delete like this
y

Yash

01/22/2022, 1:53 PM
sure @Kevin Kho, I will try to register a flow without schedule and then I will try to add/delete schedules using grpahql api. Thank you!!!