Reputation:
I've been looking through the documentation, and I can't find any way to stop Ray after an answer is calculated within a tolerance level. Right now I'm writing the answer to a csv with a print('Ok to stop'), and then I kill the process manually. I'd like to stop all of the workers, and then have it automatically move on to another problem. Is there an error that I can raise that will make all of the workers stop?
Thanks.
Upvotes: 7
Views: 13439
Reputation: 71
Have a line in your Python code to break the process if a condition is met and then shutdown your Ray instance:
ray.init()
....
if tolerance_level > 50:
break
ray.shutdown()
Upvotes: 4
Reputation: 925
If you start a ray cluster with ray.init, the cluster should be killed when your python program exists. If you start it with ray start
, you can use the ray stop
command to shutdown the cluster. You can also use ray stop --force
to forcefully kill all processes left.
Upvotes: 4