adaptivemd.Worker

class adaptivemd.Worker(walltime=None, generators=None, sleep=None, heartbeat=None, prefetch=1, verbose=False)[source]

A Worker instance the will submit tasks from the DB to a scheduler

__init__(walltime=None, generators=None, sleep=None, heartbeat=None, prefetch=1, verbose=False)[source]

Methods

__init__([walltime, generators, sleep, ...])
args() Return a list of args of the __init__ function of a class
base() Return the most parent class actually derived from StorableMixin
create(project)
descendants() Return a list of all subclassed objects
execute(command) Send and execute a single command to the worker
from_dict(dct)
get_uuid() Create a new unique ID
idx(store) Return the index which is used for the object in the given store.
named(name) Attach a .name property to an object
objects() Returns a dictionary of all storable objects
run() Start the worker to execute tasks until it is shut down
shutdown([gracefully]) Shut down the worker
to_dict()

Attributes

ACTIVE_LONG
CREATION_COUNT
INSTANCE_UUID
base_cls Return the base class
base_cls_name Return the name of the base class
cls Return the class name as a string
command
current
n_tasks
prefetch
project returns: the currently used project
scheduler returns: the currently used scheduler to execute tasks
seen
state
verbose
scheduler
Returns:the currently used scheduler to execute tasks
Return type:WorkerScheduler
project
Returns:the currently used project
Return type:Project
execute(command)[source]

Send and execute a single command to the worker

Note that the worker is registered on the DB but running on your HPC. Just loading it does not allow you to call functions like .shutdown. These would only be called on your local instance. All you can do is use execute which will store a command in the DB and once the real running worker executed it. The command will be cleared from the DB.

Parameters:command (str) – the command to be executed
run()[source]

Start the worker to execute tasks until it is shut down

shutdown(gracefully=True)[source]

Shut down the worker

Parameters:gracefully (bool) – if True the worker is allowed some time to finish running tasks