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]¶ x.__init__(…) initializes x; see help(type(x)) for signature
Methods
__init__
([walltime, generators, sleep, …])x.__init__(…) initializes x; see help(type(x)) for signature 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)Reconstruct an object from a dictionary representation get_uuid
()Create a new unique ID :returns: the unique number for an object in the project :rtype: long 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
()Convert object into a dictionary representation 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
-
to_dict
()¶ Convert object into a dictionary representation
Used to convert the dictionary into JSON string for serialization
Returns: the dictionary representing the (immutable) state of the object Return type: dict
-
classmethod
from_dict
(dct)[source]¶ Reconstruct an object from a dictionary representation
Parameters: dct (dict) – the dictionary containing a state representation of the class. Returns: the reconstructed storable object Return type: StorableMixin
-
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
-