Hi folks - my team is looking into adopting prefec...
# prefect-community
Hi folks - my team is looking into adopting prefect 2.1. One of the functionalities that we need is to be able to run a flow every time some external parameters change (if no flow is being run, run the flow, if a flow is being run, wait until it finishes). I was looking into the concept of work_queues and it satisfies that need mostly - however, we only care about running the latest job in the queue (the one that has the most up to date parameters) is there a way for the agent to always pick the most updated job in the queue and discard the others?
I don't believe there is.. I'm still learning to work with the queues. One way to achieve this is to read your entire queue, then compare them to purge the ones you no longer want executed. https://docs.prefect.io/api-ref/prefect/client/#prefect.client.orion.OrionClient.get_runs_in_work_queue
🙌 1
🙏 1
interesting... and to purge them I would probably do delete_flow_run(id) most likely right? Thanks
yep, exactly. Another option might be to
to Cancelled. But there is some validation logic in CoreFlowPolicy to make things safe and could prevent this. (I feel like it should be a valid transition to go from scheduled -> cancelled).
got it!