adaptivemd.Scheduler

class adaptivemd.Scheduler(resource, queue=None, runtime=240, cores=1)[source]

Class to handle task execution on a resource

Notes

In RP this would correspond to a Pilot with a UnitManager

Variables:
  • project (Project) – a back reference to the project that uses this scheduler
  • tasks (dict uid : Task) – dict that references all running task by the associated CU.uid
  • wrapper (Task) – a wrapping task that contains additional commands to be executed around each task running on that scheduler. It usually contains adding certain paths, etc.
Parameters:
  • resource (Resource) – a Resource where this scheduler works on
  • queue (str) – the name of the queue to be used for pilot creation
  • runtime (int) – max runtime in minutes for the created pilot
  • cores – number of used cores to be used in the created pilot
__init__(resource, queue=None, runtime=240, cores=1)[source]
Parameters:
  • resource (Resource) – a Resource where this scheduler works on
  • queue (str) – the name of the queue to be used for pilot creation
  • runtime (int) – max runtime in minutes for the created pilot
  • cores – number of used cores to be used in the created pilot

Methods

__init__(resource[, queue, runtime, cores])
param resource:a Resource where this scheduler works on
add_event(event)
cancel_events() Remove all pending events and stop them from further task execution
change_state(new_state)
enter([project]) Call a preparations to use a scheduler
exit() Shut down the scheduler
flatten_location(obj)
get_path(f) Get the schedulers representation of the path in Location object
on(condition) Shortcut for creation and appending of a new Event
remove_task(task)
replace_prefix(path) Interprete adaptive paths and replace prefixes with real os paths
shut_down([wait_to_finish]) Do a controlled shutdown.
stage_generators() Prepare files and folder for all generators
stage_in(staging)
submit(submission) Submit a task in form of an event, a task or an task-like object
trigger() Trigger a check of state changes that leads to task execution
unroll_staging_path(location) Convert a staging location into an adaptiveMD location
wait() Wait until no more units are running and hence no more state changes

Attributes

folder_name
generators Return the generators of the attached project
is_idle
staging_area_location Return the path to the staging area used by this scheduler
__init__(resource, queue=None, runtime=240, cores=1)[source]
Parameters:
  • resource (Resource) – a Resource where this scheduler works on
  • queue (str) – the name of the queue to be used for pilot creation
  • runtime (int) – max runtime in minutes for the created pilot
  • cores – number of used cores to be used in the created pilot
staging_area_location

Return the path to the staging area used by this scheduler

generators

Return the generators of the attached project

Returns:
Return type:list of TaskGenerator
get_path(f)[source]

Get the schedulers representation of the path in Location object

Parameters:f (Location) – the location object
Returns:a real file path
Return type:str
unroll_staging_path(location)[source]

Convert a staging location into an adaptiveMD location

Parameters:location (Location) – the location to the changed
enter(project=None)[source]

Call a preparations to use a scheduler

Parameters:project (Project) – the project the worker should execute for
exit()[source]

Shut down the scheduler

stage_generators()[source]

Prepare files and folder for all generators

submit(submission)[source]

Submit a task in form of an event, a task or an task-like object

Parameters:submission ((list of) [Task or object or Event]) –
Returns:the list of tasks actually executed after looking at all objects
Return type:list of Task
trigger()[source]

Trigger a check of state changes that leads to task execution

shut_down(wait_to_finish=True)[source]

Do a controlled shutdown. Cancel all units and wait until they finish.

Parameters:wait_to_finish (bool) – if True default the function will block until all tasks report finish
on(condition)[source]

Shortcut for creation and appending of a new Event

Parameters:condition (Condition) –
Returns:
Return type:Event
wait()[source]

Wait until no more units are running and hence no more state changes

cancel_events()[source]

Remove all pending events and stop them from further task execution

replace_prefix(path)[source]

Interprete adaptive paths and replace prefixes with real os paths

Parameters:path (str) – the path with an adaptiveMD prefix
Returns:the path without any adaptiveMD prefixes
Return type:str