markovmodel / adaptivemd

A python framework to run adaptive Markov state model (MSM) simulation on HPC resources
GNU Lesser General Public License v2.1
18 stars 7 forks source link

Add task cancelling #18

Closed jhprinz closed 7 years ago

jhprinz commented 7 years ago

You can now send a worker the command to cancel a task.

worker.command = 'cancel'

or which looks nicer

worker.execute('cancel')

This will cancel a task for good. You can also halt a task using halt. Which will also stop the task but allow you to restart it using

task.restart()

This works, when a task has failed, or halted (stopped by a user). Doing so will set the state back to created which can be picked up by a worker

This PR already includes the PyEMMA argument support

Another nice feature added is a shortcut to get an attribute or call a function on all elements in a bundle

project.workers.all.execute('shutdown')

by using project.workers.all you get a delegator that will apply the next command or attribute to all objects.


project.workers.all.state
>>> ['down', 'down', 'running', 'running']

This should make code look nicer in lots of cases. It works with all Bundles (like `.generators`, too).