QueuePlugin#

class daq_queuing_service.plugins.converter.Converter[source]#

Bases: object

validate(experiments: list[TaskRequest | Experiment]) → None[source]#

This gets run on new experiments added to the queue through the api endpoint. Any error raised will be handled and cause the experiments to not be added to the queue.

Parameters:
  • experiments (list[TaskRequest | Experiment]) – List of experiments or plans

  • queue. (added to the)

Raises:

Exception – Any exception raised due to experiments failing validation

pre_process(current_task: TaskWithPosition | None, queue: list[Task], history: list[TaskWithPosition], call_history: list[BlueapiCallResponse]) → list[Task][source]#

This gets run whenever something changes in the queue, before ‘construct_blueapi_calls’. It is an opportunity to automatically modify the queue based on it’s current state and history.

For example, it could be used to add calibration scans before any experiments that require them. It could also be used to query another service such as ulims and add experiments to the queue.

If not overridden, this method returns the queue as is with no modification.

Parameters:
  • current_task (TaskWithPosition | None) – The current running task, if one exists.

  • queue (list[Task]) – List of tasks currently in the queue

  • history (list[TaskWithPosition]) – List of completed tasks

  • call_history (list[BlueapiCallResponse]) – List of completed blueapi calls

Returns:

The new list of tasks in the queue

Return type:

list[Task]

construct_blueapi_calls(queue: list[TaskWithPosition], history: list[TaskWithPosition], call_history: list[BlueapiCallResponse]) → list[BlueapiCall][source]#

Converts the list of queued tasks into a list of blueapi calls. This is needed if the queue contains ulims experiments, as these must be mapped onto bluesky plans. If the queue contains TaskRequests, they can just be wrapped into BlueapiCall objects with no conversion, as this default implementation does.

Parameters:
  • queue (list[TaskWithPosition]) – List of tasks in the queue

  • history (list[TaskWithPosition]) – List of completed tasks

  • call_history (list[BlueapiCallResponse]) – List of completed blueapi calls

Returns:

List of blueapi calls to execute.

Return type:

list[BlueapiCall]

pause_on_complete_blueapi_call(call: BlueapiCall, result: TaskResult) → bool[source]#

Decide whether to pause the queue after a blueapi call completes successfully

Parameters:
  • call (BlueapiCall) – The completed call

  • result (TaskResult) – The result of the call from blueapi

Returns:

True to pause the queue, False to leave it running.

Return type:

bool

pause_on_fail_blueapi_call(call: BlueapiCall, errors: list[str | TaskError] | None) → bool[source]#

Decide whether to pause the queue after a blueapi call fails

Parameters:
  • call (BlueapiCall) – The failed call

  • errors (list[str | TaskError] | None) – The errors that occurred

Returns:

True to pause the queue, False to leave it running.

Return type:

bool