Source code for resonance.api.data.models
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any
[docs]
@dataclass
class RunSummary:
"""Lightweight summary of a single run, used for catalog listing operations.
This is a denormalized projection built from joining the `runs` and `samples`
tables. It is intended for display and filtering, not for full data retrieval.
Attributes
----------
uid : str
Run UUID in hexadecimal form, as stored in the database.
plan_name : str
Name of the scan plan that produced this run, e.g. "en_scan".
time_start : float
Unix timestamp marking the start of the run.
sample_name : str | None
Sample name denormalized from the `samples` join. None if no sample was
associated with the run or if the join produced no match.
time_stop : float | None
Unix timestamp marking the end of the run. None if the run did not finish
cleanly or if the stop document was not recorded.
exit_status : str | None
Final status string from the RunStop document. Expected values are
"success", "aborted", or "failed". None if not recorded.
"""
uid: str
plan_name: str
time_start: float
sample_name: str | None = None
time_stop: float | None = None
exit_status: str | None = None
[docs]
@dataclass
class BeamtimeInfo:
"""Represents a beamtime entry as stored in the master index database.
Each beamtime corresponds to a single experimental session and owns its own
SQLite database file. The master index holds one row per beamtime so that
multiple sessions can be cataloged from a single entry point.
Attributes
----------
id : int
Primary key in the master index database.
researcher_name : str
Name of the researcher who led the beamtime session.
label : str
Human-readable label for the beamtime, typically an ISO date string
such as "2026-03-05".
db_path : str
Path to the beamtime SQLite file, relative to the DATA root directory.
time_start : float | None
Unix timestamp for the beginning of the beamtime. None if not recorded.
time_stop : float | None
Unix timestamp for the end of the beamtime. None if still in progress or
not recorded.
"""
id: int
researcher_name: str
label: str
db_path: str
time_start: float | None = None
time_stop: float | None = None