mxcubecore.HardwareObjects.QueueModel#

Handles interaction with the data model(s). Adding, removing and retrieving nodes are all done via this object. It is possible to handle several models by using register_model and select_model.

Classes

QueueModel(name)

Serializer()

class mxcubecore.HardwareObjects.QueueModel.QueueModel(name)[source]#

Bases: HardwareObject

add_child(parent, child: TaskNode) None[source]#

Adds the child node <child>. Raises the exception TypeError if child is not of type TaskNode.

Moves the child (re-parents it) if it already has a parent.

Parameters:

child (TaskNode) – TaskNode to add

Returns:

None

Return type:

None

add_child_at_id(_id: int, child: TaskNode) int[source]#

Adds a child <child> at the node with the node id <_id>

Parameters:
  • _id (int) – The id of the parent node.

  • child (TaskNode) – The child node to add.

Returns:

The id of the child.

Return type:

int

check_for_path_collisions(new_path_template)[source]#

Returns True if there is a path template (task) in the model, that produces the same files as this one.

Returns:

True if there is a potential path collision.

clear_model(name: str | None = None) None[source]#

Clears the model with name <name>, clears all if name is None

Parameters:

name (str | None) – The name of the model to clear.

Returns:

None

Return type:

None

clear_queue()[source]#

Clears all models (ispyb, free-pin, plate) and resets the selected model to ‘ispyb’.

copy_node(node: TaskNode) TaskNode[source]#

Copies the node <node> and returns it.

Parameters:

node (TaskNode) – The node to copy.

Returns:

A copy of the node.

Return type:

TaskNode

del_child(parent, child: TaskNode) None[source]#

Removes <child>

Parameters:

child (TaskNode) – Child to remove.

Returns:

None

Return type:

None

get_model_root() TaskNode[source]#
Returns:

The selected model root.

Return type:

TaskNode

get_next_run_number(new_path_template: PathTemplate, exclude_current: bool = True) int[source]#

Iterates through all the path templates of the tasks in the model and returns the next available run number for the path template <new_path_template>.

Parameters:
  • new_path_template (PathTemplate) – PathTempalte to match with.

  • exclude_current (bool) – Skips it self when iterating through the model, default Tree.

Returns:

The next available run number for the given path_template.

Return type:

int

get_node(_id: int, parent: TaskNode | None = None) TaskNode | None[source]#

Retrieves the node with the node id <_id>

Parameters:
  • _id (int) – The id of the node to retrieve.

  • parent (TaskNode | None) – parent node to search in.

Returns:

The node with the id <_id>

Return type:

TaskNode | None

get_node_at_task_index(loc_str: str, tindex: int) TaskNode[source]#

Finds the node at position <tindex> in the task list of the sample with location string <loc_str>

Parameters:
  • loc_str (str) – The sample’s location string.

  • tindex (int) – Index into the sample’s task list.

Returns:

The node at position tindex.

Return type:

TaskNode

get_path_templates()[source]#

Retrieves a list of all the path templates in the model.

get_sample_by_loc_str(loc_str: str) Sample | None[source]#

Finds the Sample node with location string <loc_str>, directly under the selected model’s root.

Parameters:

loc_str (str) – The sample’s location string (Sample.loc_str).

Returns:

The Sample node, or None if not found.

Return type:

Sample | None

init()[source]#

Framework-2 method, inherited from HardwareObject and called by the framework after the object has been initialized.

You should normally not need to call this method.

load_queue_from_file(filename, snapshot=None)[source]#

Loads queue from file. The problem is snapshots that are not stored in the file, so we have to add new ones in the loading process

Returns:

model name ‘free-pin’, ‘ispyb’ or ‘plate’

node_index(node)[source]#

Get the position (index) in the queue, sample and node id of node <node>.

Returns:

dictionary on the form: {‘sample’: sample, ‘idx’: index, ‘queue_id’: node_id}

queue_model_child_added(parent, child)[source]#

Listen to the addition of models to the queue model via the ‘child_added’ event.

This is the single place a QueueEntry is created for a model node:

Callers only ever call add_child() to place a model in the tree. Its not necassary to construct or enqueue an entry themselves.

This method handles the creation of a queue entry for every model type registred in mxcubecore.queue_entry.MODEL_QUEUE_ENTRY_MAPPINGS

register_model(name: str, root_node: RootNode) None[source]#

Register a new model with name <name> and root node <root_node>.

Parameters:
  • name (str) – The name of the ‘new’ model.

  • root_node (RootNode) – The root of the model.

Returns:

None

Return type:

None

save_queue(filename=None)[source]#

Saves queue in the file. Current selected model is saved as a list of dictionaries. Information about samples and baskets is not saved

select_model(name: str) None[source]#

Selects the model with the name <name>

Parameters:

name (str) – The name of the model to select.

Returns:

None

Return type:

None

set_parent(parent: TaskNode, child: TaskNode)[source]#

Sets the parent of the child <child> to <parent>

Parameters:
view_created(view_item, task_model: TaskNode) None[source]#

Method that should be called by the routine that adds the view <view_item> for the model <task_model>

Parameters:
  • view_item – The view item that was added.

  • task_model (TaskNode) – The associated task model.

Returns:

None

Return type:

None