mdadash.backend.kernel.core

Kernel core where MDAnalysis code runs

Classes

BufferFrameIteratorIndices()

Iterable over the frames of a trajectory buffer listed as a sequence of indices.

BufferedTrajectory(u, buffer_size[, ...])

Buffered Trajectory

CommHandler()

Comm Handler

MultiArrayBuffer(spec[, use_shm])

Multi Array Buffer

UniverseManager(_comms)

Universe Manager

class mdadash.backend.kernel.core.BufferFrameIteratorIndices[source]

Bases: FrameIteratorBase

Iterable over the frames of a trajectory buffer listed as a sequence of indices. This is very similar to FrameIteratorIndices in MDAnalysis, but without rewind() and __getitem__ as they aren’t needed here.

property frames
class mdadash.backend.kernel.core.BufferedTrajectory(u: Universe, buffer_size: int, reference_ts: Timestep = None, use_shm: bool = True)[source]

Bases: object

Buffered Trajectory

This class is a wrapper for the trajectory reader and provides buffered access to the last n timesteps.

trajectory[index] can be used to access individual frames. Index values can range from 0 to the configured batch size.

property buffer_size

Total buffer size

check_slice_indices(start, stop, step)[source]
cleanup()[source]

Cleanup the buffer

property n_frames

Number of frames in the buffer

next()[source]

Iterate next frame and save timestep into buffer

property ref_u: Universe

Reference timestep universe

The earliest timestep available for this trajectory since the dashboard was launched can be obtained from this single frame reference universe. This timestep persists across multiple connect / disconnects while the dashboard is running, but not across different runs of the dashboard (mdadash) itself.

class mdadash.backend.kernel.core.CommHandler[source]

Bases: object

Comm Handler

This class is responsible for handling all the communication to and from this kernel. This is the class that interfaces with the KernelManager on the server side.

register_handler(msg_type: str, handler_func: callable) → None[source]

Register a handler function for a message type

Parameters:
  • msg_type (str) – A message type to identify the handler

  • handler_func (callable) – The handler function to invoke when a message with this message type is received

send(msg: dict) → None[source]

Send a message (response) back on the comm

Parameters:

msg (dict) – A generic message dictionary

class mdadash.backend.kernel.core.MultiArrayBuffer(spec: dict, use_shm: bool = True)[source]

Bases: object

Multi Array Buffer

This class manages a single contiguous buffer that is used by multiple numpy arrays. All individual np arrays are 64-byte aligned. There is an option to create this memory buffer as shared memory to achieve zero-copy access from parallel worker processes.

cleanup()[source]

Cleanup in case of shm

getstate(gen: int = 0) → dict[source]

Get the state to use for serialization

classmethod setstate(state: dict)[source]

Set the state and re-create the instance

This method is invoked only on workers during de-serialization

class mdadash.backend.kernel.core.UniverseManager(_comms: CommHandler)[source]

Bases: object

Universe Manager

This class is responsible for managing all MDAnalysis universes. It has handlers to interact with the MD simulation. These handlers are invoked by comm messages sent from the server.

This also provides an iterable and indexable access to the individual universes.

cleanup(_data: dict)[source]

Cleanup the UniverseManager

This is invoked when mdadash is being shutdown. The simulation is disconnected, but we don’t have to wait till all parallel jobs are done etc because the app itself is shutting down

connect_to_simulations(universe_configs: list[dict]) → None[source]

Connect to MD simulations

Parameters:

universe_configs (list[dict]) – A list of configurations for universe(s) creation. Each dict has universe related config like topology, trajectory, imdclient params, user-defined kwargs etc

disconnect_from_simulations(data: dict) → None[source]

Disconnect from MD simulations

get_topology(_data: dict)[source]

Get topology of current 3dview selection

init_n_universes(n: int) → None[source]

Initialize array for n universes

Parameters:

n (int) – Number of universes to initialize

pause_simulations(_data: dict) → None[source]

Pause MD simulations

resume_simulations(_data: dict) → None[source]

Resume MD simulations

update_3dview_frequency(data: dict)[source]
update_3dview_selection(data: dict)[source]

Update 3dview selection phrase

update_n_jobs(data: dict) → None[source]

Update n_jobs for joblib.Parallel

Parameters:

data (dict) – Dict that has the following keys:

n_jobs: int

The number of parallel jobs