Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fields required for SSX to events route #250

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyispyb/core/modules/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class EntityType:
models.DataCollection.DataCollectionGroup,
models.DataCollectionGroup.Workflow,
],
models.DataCollection.SSXDataCollection,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be sensible to make this optional based on if models.DataCollection.SSXDataCollection exists. That way if people dont have the table it doesnt break the app

models.DataCollection.Detector,
],
),
"robot": EntityType(
Expand Down
16 changes: 15 additions & 1 deletion pyispyb/core/schemas/datacollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

from pydantic import BaseModel, Field

from pydantic_sqlalchemy import sqlalchemy_to_pydantic

from ispyb import models


class Workflow(BaseModel):
workflowId: int
Expand Down Expand Up @@ -42,7 +46,8 @@ class Config:

class DataCollectionGroup(BaseModel):
dataCollectionGroupId: int
experimentType: str
experimentType: Optional[str]
blSampleId: Optional[int]

Workflow: Optional[Workflow]

Expand Down Expand Up @@ -128,6 +133,13 @@ class DataCollectionBase(BaseModel):
xBeamPix: Optional[float] = Field(title="Beam size X", unit="pixels")
yBeamPix: Optional[float] = Field(title="Beam size Y", unit="pixels")

undulatorGap1: Optional[float]
undulatorGap2: Optional[float]
undulatorGap3: Optional[float]
beamShape: Optional[str]
polarisation: Optional[float]
imagePrefix: Optional[str]

# EM
magnification: Optional[int] = Field(title="Magnification", unit="x")
binning: Optional[int] = Field(title="Binning")
Expand Down Expand Up @@ -155,6 +167,8 @@ class DataCollection(DataCollectionBase):

DataCollectionGroup: DataCollectionGroup
GridInfo: Optional[list[GridInfo]]
SSXDataCollection: Optional[sqlalchemy_to_pydantic(models.SSXDataCollection)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more complicated because its nested and not generated at run time. The easy option is to manually define the Schema in this case. Will have to think about runtime possibilities...

Detector: Optional[sqlalchemy_to_pydantic(models.Detector)]

metadata: DataCollectionMetaData = Field(alias="_metadata")

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ispyb-models==1.0.6
ispyb-models==1.1.0

fastapi
pydantic[dotenv]
Expand Down