adaptivemd.Project

class adaptivemd.Project(name)[source]

A simulation project

Notes

You will later create Scheduler objects that explicitly correspond to a specific cue on a specific cluster that is accessible from within this shared FS resource.

Variables:
  • name (str) – a short descriptive name for the project. This name will be used in the database creation also.
  • resource (Resource) – a resource to run the project on. The resource specifies the memory storage location. Not necessarily which cluster is used. An example is, if at an institute several clusters (CPU, GPU) share the same shared FS. If clusters use the same FS you can run simulations across clusters without problems and so so this resource is the most top-level limitation.
  • files (Bundle) – a set of file objects that are available in the project and are believed to be available within the resource as long as the project lives
  • trajectories (ViewBundle) – all File object that are of Trajectory type and which have a positive created attribute. This means the file was really created and has not been altered yet.
  • workers (Bundle) – a set of all registered Worker instanced in the project
  • files – a set of file objects that are available in the project and are believed to be available within the resource as long as the project lives
  • models (Bundle) – a set of stored models in the DB
  • tasks (Bundle) – a set of all queued `Task`s in the project
  • logs (Bundle) – a set of all stored log entries
  • data (Bundle) – a set of DataDict objects that represent completely stored files in the database of arbitrary size
  • schedulers (set of Scheduler) – a set of attached schedulers with controlled shutdown and reference
  • storage (MongoDBStorage) – the mongodb storage wrapper to access the database of the project
  • _worker_dead_time (int) – the time after which an unresponsive worker is considered dead. Its tasks will be assigned the state set in _set_task_state_from_dead_workers. Default is 60s. Make sure that the heartbeat of a worker is much less that this.
  • _set_task_state_from_dead_workers (str) – if a worker is dead then its tasks are assigned this state. Default is created which means the task will be restarted by another worker. You can also chose halt or cancelled. See Task for details

See also

Task

__init__(name)[source]

Methods

__init__(name)
add_event(event) Attach an event to the project
close() Close the project and all related sessions and DB connections
close_rp() Close the RP session
delete(name) Delete a complete project
events_done() Check if all events are done
find_ml_next_frame([n_pick]) Find initial frames picked by inverse equilibrium distribution
get_scheduler([name])
param name:name of the scheduler class provided by the Resource used in
initialize(resource) Initialize a project with a specific resource.
list() List all projects in the DB
new_ml_trajectory(engine, length, number) Find trajectories that have initial points picked by inverse eq dist
new_trajectory(frame, length[, engine, number]) Convenience function to create a new Trajectory object
on_nmodel(numbers) Return a condition representing the reach of a certain number of models
on_ntraj(numbers) Return a condition that is true as soon a the project has n trajectories
queue(*tasks) Submit jobs to the worker queue
reconnect() Reconnect the DB
run() Starts observing events in the project
stop() Stop observing events
trigger() Trigger a check of state changes that leads to task execution
wait_until(condition) Block until the given condition evaluates to true
initialize(resource)[source]

Initialize a project with a specific resource.

Notes

This should only be called to setup the project and only the very first time.

Parameters:resource (Resource) – the resource used in this project
reconnect()[source]

Reconnect the DB

close_rp()[source]

Close the RP session

Before using RP you need to re-open and then you will run in a new session.

classmethod list()[source]

List all projects in the DB

Returns:a list of all project names
Return type:list of str
classmethod delete(name)[source]

Delete a complete project

Notes

Attention!!!! This cannot be undone!!!!

Parameters:name (str) – the project name to be deleted
get_scheduler(name=None, **kwargs)[source]
Parameters:
  • name (str) – name of the scheduler class provided by the Resource used in this project. If None (default) the cluster/queue default is used that needs to be implemented for every resource
  • kwargs (**kwargs) – Additional arguments to initialize the cluster scheduler provided by the Resource

Notes

the scheduler is automatically entered/opened so the pilot jobs is submitted to the queueing system and it counts against your simulation time! If you do not want to do so directly. Create the Scheduler by yourself and later call scheduler.enter(project) to start using it. To close the scheduler call scheduler.exit()

Returns:the scheduler object that can be used to execute tasks on that cluster/queue
Return type:Scheduler
close()[source]

Close the project and all related sessions and DB connections

queue(*tasks)[source]

Submit jobs to the worker queue

Parameters:tasks ((list of) Task or Trajectory) – anything that can be run like a Task or a Trajectory with engine
new_trajectory(frame, length, engine=None, number=1)[source]

Convenience function to create a new Trajectory object

It will use incrementing numbers to create trajectory names used in the engine executions. Use this function to always get an unused trajectory name.

Parameters:
  • frame (File or Frame) – if given a File it is assumed to be a .pdb file that contains initial coordinates. If a frame is given one assumes that this Frame is the initial structure / frame zero in this trajectory
  • length (int) – the length of the trajectory
  • engine (Engine or None) – the engine used to generate the trajectory. The engine contains all the specifics about the trajectory internal structure since it is the responsibility of the engine to really create the trajectory.
  • number (int) – the number of trajectory objects to be returned. If 1 it will be a single object. Otherwise a list of Trajectory objects.
Returns:

Return type:

Trajectory or list of Trajectory

on_ntraj(numbers)[source]

Return a condition that is true as soon a the project has n trajectories

Parameters:numbers (int or iterator of int) – either a single int or an iterator that returns several ints
Returns:the single condition or a generator of conditions matching the ints in the iterator
Return type:NTrajectories or generator of NTrajectories
on_nmodel(numbers)[source]

Return a condition representing the reach of a certain number of models

Parameters:numbers (int or iterator of int) – the number(s) of the models to be reached
Returns:a (list of) Condition
Return type:(generator of) Condition
find_ml_next_frame(n_pick=10)[source]

Find initial frames picked by inverse equilibrium distribution

This is the simplest adaptive strategy possible. Start from the states more likely if a state has not been seen so much. Effectively stating that less knowledge of a state implies a higher likelihood to find a new state.

Parameters:n_pick (int) – number of returned trajectories
Returns:the list of trajectories with the selected initial points.
Return type:list of Frame
new_ml_trajectory(engine, length, number)[source]

Find trajectories that have initial points picked by inverse eq dist

Parameters:
  • engine (Engine) – the engine to be used
  • length (int) – length of the trajectories returned
  • number (int) – number of trajectories returned
Returns:

the list of Trajectory objects with initial frames chosen using find_ml_next_frame()

Return type:

list of Trajectory

events_done()[source]

Check if all events are done

Returns:True if all events are done
Return type:bool
add_event(event)[source]

Attach an event to the project

These events will not be stored and only run in the current python session. These are the parts responsible to create tasks given certain conditions.

Parameters:event (Event or generator) – the event to be added or a generator function that is then converted to an ExecutionPlan
Returns:the actual event used
Return type:Event
trigger()[source]

Trigger a check of state changes that leads to task execution

This needs to be called regularly to advance the simulation. If not, certain checks for state change will not be called and no new tasks will be generated.

run()[source]

Starts observing events in the project

This is still somehow experimental and will call a background thread to call Project.trigger() in regular intervals. Make sure to call Project.stop() before you quit the notebook session or exit. Otherwise there might be a job in the background left (not confirmed but possible!)

stop()[source]

Stop observing events

wait_until(condition)[source]

Block until the given condition evaluates to true

Parameters:condition (callable) – function that is called in regular intervals. If it evaluates to True the function returns
class EventTriggerTimer(event, project)[source]

A special thread to call the project trigger mechanism