Skip to content

bloqade.core.device.local_storage.StorageBackend

← Module overview

classStorageBackendsource

bloqade.core.device.local_storage.StorageBackend

Bases: ABC

Abstract storage backend for shot results.

class StorageBackend

Implementations store shot rows together with enough task metadata to reconstruct TaskDefinition objects and create Result views.

NOTE: methods that return mutable dictionaries should return independent copies. Result helpers may mutate returned metadata records while building merged views.

methodadd_shotssource

bloqade.core.device.local_storage.StorageBackend.add_shots

def add_shots(shots: Iterable[ShotResult]) -> None

Store shot result rows.

Parameters

NameTypeDescription
shotsIterable[ShotResult]Shot rows to store.
source

methodget_shotssource

bloqade.core.device.local_storage.StorageBackend.get_shots

Signature
def get_shots(*, shot_filter: ShotFilter | None = None) -> Iterable[ShotResult]

Return stored shot rows matching a filter.

Parameters

NameTypeDefaultDescription
shot_filterShotFilter | NoneNone

Other Parameters

NameTypeDescription
shot_filterShotFilter | NoneOptional shot filter. When None, all shots are returned. Defaults to None.

Returns

Iterable[ShotResult]Matching shot rows.

source

methodtask_idssource

bloqade.core.device.local_storage.StorageBackend.task_ids

def task_ids() -> set[str]

Return task IDs with stored task definitions.

Returns

set[str]Stored task IDs.

source

methodadd_task_definitionsource

bloqade.core.device.local_storage.StorageBackend.add_task_definition

Signature
def add_task_definition(task_id: str, task_definition: TaskDefinition, creation_time: datetime.datetime)

Store a task definition and its creation time.

Parameters

NameTypeDescription
task_idstrBackend task ID.
task_definitionTaskDefinitionTask definition to store.
creation_timedatetime.datetimeBackend task creation time.
source

methodget_program_languagesource

bloqade.core.device.local_storage.StorageBackend.get_program_language

def get_program_language(task_id: str) -> str

Return the program language for a stored task definition.

Parameters

NameTypeDescription
task_idstrBackend task ID.

Returns

strstr: Program language stored for the task.

Raises

TypeDescription
KeyErrorIf `task_id` is not present.
source

methodget_task_creation_timesource

bloqade.core.device.local_storage.StorageBackend.get_task_creation_time

def get_task_creation_time(task_id: str) -> datetime.datetime

Return the creation time for a stored task.

Parameters

NameTypeDescription
task_idstrBackend task ID.

Returns

datetime.datetimeStored task creation time.

Raises

TypeDescription
KeyErrorIf `task_id` is not present.
source

methodget_task_group_idsource

bloqade.core.device.local_storage.StorageBackend.get_task_group_id

def get_task_group_id(task_id: str) -> UUID | None

Return the QLAM group associated with a stored task definition.

The default keeps existing custom storage backends compatible; those backends simply reconstruct definitions without an explicit group. Built-in storage backends override this to preserve the group UUID.

Parameters

NameTypeDescription
task_idstrBackend task ID.

Returns

(UUID | None, UUID | None)Stored group UUID, or None when the task definition did not specify a group.

source

methodget_profile_idsource

bloqade.core.device.local_storage.StorageBackend.get_profile_id

def get_profile_id(task_id: str) -> UUID | None

Parameters

NameTypeDescription
task_idstr

Returns

UUID | None

source

methodget_programssource

bloqade.core.device.local_storage.StorageBackend.get_programs

def get_programs(task_ids: tuple[str, ...] | None = None) -> list[dict]

Return stored program records.

Parameters

NameTypeDefaultDescription
task_idstuple[str, ...] | NoneNoneOptional task IDs to include. When None, programs for all stored task IDs are returned. Defaults to None.

Returns

list[dict]Program dictionaries with `task_id`, `program_index`, and `content`.

source

methodget_subtaskssource

bloqade.core.device.local_storage.StorageBackend.get_subtasks

Signature
def get_subtasks(storage_filter: StorageFilter | None = None) -> list[dict]

Return stored subtask records.

Parameters

NameTypeDefaultDescription
storage_filterStorageFilter | NoneNoneOptional subtask metadata filter. When None, all subtasks are returned. Defaults to None.

Returns

list[dict]Subtask dictionaries, including task ID, subtask index, program index, shot count, arguments, metadata, and completion date.

source

methodupdate_subtasks_completed_datesource

bloqade.core.device.local_storage.StorageBackend.update_subtasks_completed_date

Signature
def update_subtasks_completed_date(task_id, subtasks: list[dict]) -> None

Update completion times for stored subtasks.

Parameters

NameTypeDescription
task_idstrBackend task ID.
subtaskslist[dict]API subtask dictionaries containing `completed_date` and `shot_results` whose entries carry the `subtask_index`. The subtask object itself has no index.
source

methodget_task_definitionsource

bloqade.core.device.local_storage.StorageBackend.get_task_definition

def get_task_definition(task_id: str) -> TaskDefinition

Reconstruct a task definition from stored metadata.

Parameters

NameTypeDescription
task_idstrBackend task ID.

Returns

TaskDefinitionTaskDefinition: Reconstructed task definition.

source

methodget_argumentssource

bloqade.core.device.local_storage.StorageBackend.get_arguments

Signature
def get_arguments(storage_filter: StorageFilter | None = None) -> list[dict | None]

Return arguments from stored subtasks.

Parameters

NameTypeDefaultDescription
storage_filterStorageFilter | NoneNoneOptional subtask metadata filter. Defaults to None.

Returns

list[dict | None]Arguments from matching subtasks.

source

methodfilter_by_subtaskssource

bloqade.core.device.local_storage.StorageBackend.filter_by_subtasks

Signature
def filter_by_subtasks(predicate: Callable[[dict], bool], storage_filter: StorageFilter | None = None) -> StorageFilter

Build a filter from subtasks matching a predicate.

Parameters

NameTypeDefaultDescription
predicateCallable[[dict], bool]requiredPredicate applied to each selected subtask dictionary.
storage_filterStorageFilter | NoneNoneOptional filter used before evaluating the predicate. Defaults to None.

Returns

StorageFilterStorageFilter: Filter containing matching `(task_id, subtask_index)` pairs.

source

methodfilter_by_metadatasource

bloqade.core.device.local_storage.StorageBackend.filter_by_metadata

Signature
def filter_by_metadata(predicate: Callable[[dict | None], bool], storage_filter: StorageFilter | None = None) -> StorageFilter

Build a filter from JSON-decoded user metadata.

This expects metadata to have been set as a dictionary and serialized as JSON. If metadata cannot be deserialized by JSON, fetch and filter the subtasks manually.

Parameters

NameTypeDefaultDescription
predicateCallable[[dict | None], bool]requiredPredicate applied to each selected subtask's decoded `user_metadata`.
storage_filterStorageFilter | NoneNoneOptional filter used before evaluating the predicate. Defaults to None.

Returns

StorageFilterStorageFilter: Filter containing matching `(task_id, subtask_index)` pairs.

source

methodfilter_by_argumentssource

bloqade.core.device.local_storage.StorageBackend.filter_by_arguments

Signature
def filter_by_arguments(predicate: Callable[[dict | None], bool], storage_filter: StorageFilter | None = None) -> StorageFilter

Build a filter from subtask arguments matching a predicate.

Parameters

NameTypeDefaultDescription
predicateCallable[[dict | None], bool]requiredPredicate applied to each selected subtask's arguments.
storage_filterStorageFilter | NoneNoneOptional filter used before evaluating the predicate. Defaults to None.

Returns

StorageFilterStorageFilter: Filter containing matching `(task_id, subtask_index)` pairs.

source

methodfilter_by_shotssource

bloqade.core.device.local_storage.StorageBackend.filter_by_shots

Signature
def filter_by_shots(predicate: Callable[[ShotResult], bool], shot_filter: ShotFilter | None = None) -> ShotFilter

Build a filter from shots matching a predicate.

Parameters

NameTypeDefaultDescription
predicateCallable[[ShotResult], bool]requiredPredicate applied to each selected shot.
shot_filterShotFilter | NoneNoneOptional filter used before evaluating the predicate. Defaults to None.

Returns

ShotFilterShotFilter: Filter containing matching `(task_id, shot_index)` pairs.

source