mdadash.backend.widgets.base
Base Class for Widgets and Widget Manager
Classes
This is the base class for all widgets. |
|
This is the manager that manager all widgets. |
- class mdadash.backend.widgets.base.WidgetBase[source]
Bases:
ABCThis is the base class for all widgets.
- alert(message: str) None[source]
Create an alert
- Parameters:
message (str) – The string message used for the alert
- apply_parallel_results(values: Any) None[source]
apply_parallel_results handler
This handler is called with the results of the parallel job execution. This is invoked when the run mode is set to parallel (
_run_mode='parallel') after the parallel job completes.- Parameters:
values (Any) – The results returned by the parallel job run
- get_parallel_job() Any[source]
get_parallel_job handler
This handler is called if the run mode is set to parallel (_run_mode=’parallel’) to get the parallel job to run.
- Returns:
job – A joblib’s delayed function
- Return type:
Any
- on_input_change(attribute: str, old_value: Any, new_value: Any) None[source]
on_input_change handler
This handler is called after a widget input has changed. Validations can be performed in this handler and any exceptions raised with messages will show up as errors in the UI
- Parameters:
attribute (str) – The input attribute that changed
old_value (Any) – The previous value held by this attribute
new_value (Any) – The current value of this attribute
- on_post_connect() None[source]
on_post_connect handler
This handler is called after connecting to the simulation
- on_post_create() None[source]
on_post_create handler
This handler is called after the widget instance is created and after all the inputs are set. (widget create, duplicate, re-create from state)
- on_post_disconnect() None[source]
on_post_disconnect handler
This handler is called after disconnection from simulation
- on_post_pause() None[source]
on_post_pause handler
This handler is called after user pauses trajectory iteration
- on_pre_resume() None[source]
on_pre_resume handler
This handler is called after user resumes trajectory iteration
- class mdadash.backend.widgets.base.WidgetManager[source]
Bases:
objectThis is the manager that manager all widgets.
- duplicate_widget_instance(data: dict) None[source]
Duplicate widget instance based on instance uuid
- execute_code(data: dict) None[source]
Execute code in the kernel
- Parameters:
data (dict) – Dict that has the following keys:
- code: str
The code to execute in the kernel
- get_available_widgets(_data: dict) None[source]
Get available widgets
Sends a dict containing name and description of all available widgets to the client.
- get_widget_inputs(data: dict) None[source]
Get inputs
Send a dict containing the inputs and notes for a given widget uuid.
- Parameters:
data (dict) – Dict that has the following keys:
- uuid: str
The uuid of the instance
- recreate_instances(data: dict) None[source]
Recreate widget instances
Recreate widget instances with data from state file
- Parameters:
data (dict) – Data of the instances that need to be recreated
- classmethod register_class(widget_class: WidgetBase) None[source]
Register widget class
- Parameters:
widget_class – A widget class that is derived from WidgetBase
- remove_widget_instance(data: dict) None[source]
Remove widget instance
Remove widget instance based on uuid returned during the instance creation using
add_widget_instance()- Parameters:
data (dict) – Dict that has the following keys:
- uuid: str
The uuid of the instance
- run_widgets(uid: int, batch_ready: bool) None[source]
Run widget instances
- Parameters:
uid (int) – Universe ID (index into universes array)
batch_ready (bool) – Flag indicating if a batch of timesteps is full