https://prefect.io logo
Title
a

Aditi Tambi

02/25/2022, 10:22 AM
Hi I am new to this , I am using python, after initialising a prefect flow , we use flow.run() to start the flow . I would like to know any command which can terminate this flow . Did not find any such thing on prefect doc.
a

Anna Geller

02/25/2022, 10:39 AM
Can you try just control + C? 🙂
a

Aditi Tambi

02/25/2022, 10:41 AM
oh no , actually I have deployed the flow code to our server. so was thinking to make some API to terminate the flow if not required
a

Anna Geller

02/25/2022, 10:45 AM
if you start the flow with flow.run() then it doesn't run on Server, it runs locally as a local process running on that machine. An alternative way to kill it would be to list the processes, find it and then kill it:
ps -ef | grep python
kill -s SIGTERM PID
But if you registered the flow and started it through the backend, then you can cancel it directly from the UI as shown below:
a

Aditi Tambi

02/25/2022, 10:50 AM
yes I have started the flow using a backend API
yet not connected the flow and tasks to prefect cloud UI
a

Anna Geller

02/25/2022, 10:54 AM
it's not possible 😄 backend means it's connected to either Prefect Server or Cloud - which one did you use?
a

Aditi Tambi

02/25/2022, 10:56 AM
I had just made an API , with 2 lines
flow = prefect_flow()
flow.run()
and in another file I have implemented the method prefect_flow() and tasks
this will enable me to start the flow with API hit and I was expecting some command to run in the API endpoint to terminate the flow as well
a

Anna Geller

02/25/2022, 10:58 AM
I recommend you follow this guide - it will bring more clarity what is happening and why you need either Server or Cloud https://docs.prefect.io/orchestration/getting-started/quick-start.html
🙌 1
a

Aditi Tambi

02/25/2022, 11:03 AM
Thank you . I will go through this .
👍 1