Add beamtime functionality to backend.

Introduce new endpoint and model for managing beamtimes, including shifts and user-specific access. Updated test scripts and data to reflect beamtime integration, along with minor fixes for job status enumeration and example notebook refinement.
This commit is contained in:
GotthardG
2025-05-05 16:05:37 +02:00
parent db6474c86a
commit 102a11eed7
9 changed files with 220 additions and 196 deletions

View File

@ -8,6 +8,7 @@ from sqlalchemy import (
DateTime,
Boolean,
func,
Enum,
)
from sqlalchemy.orm import relationship
from .database import Base
@ -235,11 +236,15 @@ class PuckEvent(Base):
puck = relationship("Puck", back_populates="events")
SHIFT_CHOICES = ("morning", "afternoon", "night")
class Beamtime(Base):
__tablename__ = "beamtimes"
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
pgroups = Column(String(255), nullable=False)
shift = Column(Enum(*SHIFT_CHOICES, name="shift_enum"), nullable=False, index=True)
beamtime_name = Column(String(255), index=True)
beamline = Column(String(255), nullable=True)
start_date = Column(Date, nullable=True)
@ -282,6 +287,7 @@ class Results(Base):
__tablename__ = "results"
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
status = Column(String(255), nullable=False)
result = Column(JSON, nullable=False) # store the full result object as JSON
sample_id = Column(Integer, ForeignKey("samples.id"), nullable=False)
run_id = Column(Integer, ForeignKey("experiment_parameters.id"), nullable=False)
@ -310,7 +316,7 @@ class Results(Base):
class JobStatus(str, enum.Enum):
TODO = "todo"
TO_DO = "to_do"
SUBMITTED = "submitted"
DONE = "done"
TO_CANCEL = "to_cancel"