mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
fix: add model_config to pydantic models to allow runtime checks after creation
This commit is contained in:
@ -15,6 +15,7 @@ class ScanInfo(BaseModel):
|
|||||||
scan_report_devices: list
|
scan_report_devices: list
|
||||||
monitored_devices: list
|
monitored_devices: list
|
||||||
status: str
|
status: str
|
||||||
|
model_config: dict = {"validate_assignment": True}
|
||||||
|
|
||||||
|
|
||||||
class AutoUpdates:
|
class AutoUpdates:
|
||||||
|
@ -20,6 +20,7 @@ class ConnectionConfig(BaseModel):
|
|||||||
gui_id: Optional[str] = Field(
|
gui_id: Optional[str] = Field(
|
||||||
default=None, validate_default=True, description="The GUI ID of the widget."
|
default=None, validate_default=True, description="The GUI ID of the widget."
|
||||||
)
|
)
|
||||||
|
model_config: dict = {"validate_assignment": True}
|
||||||
|
|
||||||
@field_validator("gui_id")
|
@field_validator("gui_id")
|
||||||
def generate_gui_id(cls, v, values):
|
def generate_gui_id(cls, v, values):
|
||||||
|
@ -19,6 +19,7 @@ class ProcessingConfig(BaseModel):
|
|||||||
rotation: Optional[int] = Field(
|
rotation: Optional[int] = Field(
|
||||||
None, description="The rotation angle of the monitor data before displaying."
|
None, description="The rotation angle of the monitor data before displaying."
|
||||||
)
|
)
|
||||||
|
model_config: dict = {"validate_assignment": True}
|
||||||
|
|
||||||
|
|
||||||
class ImageProcessor:
|
class ImageProcessor:
|
||||||
|
@ -20,6 +20,7 @@ class AxisConfig(BaseModel):
|
|||||||
y_lim: Optional[tuple] = Field(None, description="The limits of the y-axis.")
|
y_lim: Optional[tuple] = Field(None, description="The limits of the y-axis.")
|
||||||
x_grid: bool = Field(False, description="Show grid on the x-axis.")
|
x_grid: bool = Field(False, description="Show grid on the x-axis.")
|
||||||
y_grid: bool = Field(False, description="Show grid on the y-axis.")
|
y_grid: bool = Field(False, description="Show grid on the y-axis.")
|
||||||
|
model_config: dict = {"validate_assignment": True}
|
||||||
|
|
||||||
|
|
||||||
class SubplotConfig(ConnectionConfig):
|
class SubplotConfig(ConnectionConfig):
|
||||||
|
@ -17,6 +17,7 @@ class SignalData(BaseModel):
|
|||||||
unit: Optional[str] = None # todo implement later
|
unit: Optional[str] = None # todo implement later
|
||||||
modifier: Optional[str] = None # todo implement later
|
modifier: Optional[str] = None # todo implement later
|
||||||
limits: Optional[list[float]] = None # todo implement later
|
limits: Optional[list[float]] = None # todo implement later
|
||||||
|
model_config: dict = {"validate_assignment": True}
|
||||||
|
|
||||||
|
|
||||||
class Signal(BaseModel):
|
class Signal(BaseModel):
|
||||||
@ -26,6 +27,7 @@ class Signal(BaseModel):
|
|||||||
x: SignalData # TODO maybe add metadata for config gui later
|
x: SignalData # TODO maybe add metadata for config gui later
|
||||||
y: SignalData
|
y: SignalData
|
||||||
z: Optional[SignalData] = None
|
z: Optional[SignalData] = None
|
||||||
|
model_config: dict = {"validate_assignment": True}
|
||||||
|
|
||||||
|
|
||||||
class CurveConfig(ConnectionConfig):
|
class CurveConfig(ConnectionConfig):
|
||||||
|
@ -13,6 +13,7 @@ from bec_widgets.utils import BECConnector, ConnectionConfig
|
|||||||
class RingConnections(BaseModel):
|
class RingConnections(BaseModel):
|
||||||
slot: Literal["on_scan_progress", "on_device_readback"] = None
|
slot: Literal["on_scan_progress", "on_device_readback"] = None
|
||||||
endpoint: EndpointInfo | str = None
|
endpoint: EndpointInfo | str = None
|
||||||
|
model_config: dict = {"validate_assignment": True}
|
||||||
|
|
||||||
@field_validator("endpoint")
|
@field_validator("endpoint")
|
||||||
def validate_endpoint(cls, v, values):
|
def validate_endpoint(cls, v, values):
|
||||||
|
Reference in New Issue
Block a user