Source code for qualpipe_webapp.backend.generated

"""Auto-generated code from qualpipe_webapp.backend.codegen."""

# Auto-generated from traitlets-based criteria. Do not edit.
from pydantic import BaseModel, field_validator, model_validator, Field, ConfigDict
from typing import Literal, Union, Annotated, List, Tuple

# Type alias for telescope parameter tuples
TelescopeParameterTuple = Tuple[Literal['type', 'id'], Union[str, int], float]


[docs] class BaseRangeCriterionConfig(BaseModel): pass model_config = ConfigDict(extra='forbid')
[docs] class BaseRangeCriterionRecord(BaseModel): result: bool config: BaseRangeCriterionConfig
[docs] class BaseThresholdCriterionConfig(BaseModel): pass model_config = ConfigDict(extra='forbid')
[docs] class BaseThresholdCriterionRecord(BaseModel): result: bool config: BaseThresholdCriterionConfig
[docs] class RangeCriterionConfig(BaseModel): max_value: float min_value: float model_config = ConfigDict(extra='forbid')
[docs] class RangeCriterionRecord(BaseModel): result: bool config: RangeCriterionConfig
[docs] class TelescopeRangeCriterionConfig(BaseModel): max_value: List[TelescopeParameterTuple] = Field(..., description='List of telescope parameters with format [selector_type, selector_value, numeric_value]') min_value: List[TelescopeParameterTuple] = Field(..., description='List of telescope parameters with format [selector_type, selector_value, numeric_value]') model_config = ConfigDict(extra='forbid') @field_validator('max_value') @classmethod def _validate_max_value(cls, v): if not isinstance(v, list): raise ValueError("telescope parameter must be a list") for item in v: if not (isinstance(item, (list, tuple)) and len(item) == 3): raise ValueError("telescope parameter items must be length-3 [selector_type, selector, value]") selector_type, selector_value, numeric_value = item # First field must be enum: "type" or "id" if selector_type not in ('type', 'id'): raise ValueError("first element must be 'type' or 'id'") # Second field validation depends on first field if selector_type == 'type': # For type: any string value if not isinstance(selector_value, str): raise ValueError("selector value must be string when selector_type='type'") elif selector_type == 'id': # For id: positive integer if not isinstance(selector_value, int) or selector_value < 1: raise ValueError("selector value must be positive integer when selector_type='id'") # Third field must be numeric if not isinstance(numeric_value, (int, float)): raise ValueError("third element must be numeric") return v @field_validator('min_value') @classmethod def _validate_min_value(cls, v): if not isinstance(v, list): raise ValueError("telescope parameter must be a list") for item in v: if not (isinstance(item, (list, tuple)) and len(item) == 3): raise ValueError("telescope parameter items must be length-3 [selector_type, selector, value]") selector_type, selector_value, numeric_value = item # First field must be enum: "type" or "id" if selector_type not in ('type', 'id'): raise ValueError("first element must be 'type' or 'id'") # Second field validation depends on first field if selector_type == 'type': # For type: any string value if not isinstance(selector_value, str): raise ValueError("selector value must be string when selector_type='type'") elif selector_type == 'id': # For id: positive integer if not isinstance(selector_value, int) or selector_value < 1: raise ValueError("selector value must be positive integer when selector_type='id'") # Third field must be numeric if not isinstance(numeric_value, (int, float)): raise ValueError("third element must be numeric") return v
[docs] class TelescopeRangeCriterionRecord(BaseModel): result: bool config: TelescopeRangeCriterionConfig
[docs] class TelescopeThresholdCriterionConfig(BaseModel): above: bool = True threshold: List[TelescopeParameterTuple] = Field(..., description='List of telescope parameters with format [selector_type, selector_value, numeric_value]') model_config = ConfigDict(extra='forbid') @field_validator('threshold') @classmethod def _validate_threshold(cls, v): if not isinstance(v, list): raise ValueError("telescope parameter must be a list") for item in v: if not (isinstance(item, (list, tuple)) and len(item) == 3): raise ValueError("telescope parameter items must be length-3 [selector_type, selector, value]") selector_type, selector_value, numeric_value = item # First field must be enum: "type" or "id" if selector_type not in ('type', 'id'): raise ValueError("first element must be 'type' or 'id'") # Second field validation depends on first field if selector_type == 'type': # For type: any string value if not isinstance(selector_value, str): raise ValueError("selector value must be string when selector_type='type'") elif selector_type == 'id': # For id: positive integer if not isinstance(selector_value, int) or selector_value < 1: raise ValueError("selector value must be positive integer when selector_type='id'") # Third field must be numeric if not isinstance(numeric_value, (int, float)): raise ValueError("third element must be numeric") return v
[docs] class TelescopeThresholdCriterionRecord(BaseModel): result: bool config: TelescopeThresholdCriterionConfig
[docs] class ThresholdCriterionConfig(BaseModel): above: bool = True threshold: float model_config = ConfigDict(extra='forbid')
[docs] class ThresholdCriterionRecord(BaseModel): result: bool config: ThresholdCriterionConfig
CRITERION_CLASS_MAP = { "BaseRangeCriterion": (BaseRangeCriterionConfig, BaseRangeCriterionRecord), "BaseThresholdCriterion": (BaseThresholdCriterionConfig, BaseThresholdCriterionRecord), "RangeCriterion": (RangeCriterionConfig, RangeCriterionRecord), "TelescopeRangeCriterion": (TelescopeRangeCriterionConfig, TelescopeRangeCriterionRecord), "TelescopeThresholdCriterion": (TelescopeThresholdCriterionConfig, TelescopeThresholdCriterionRecord), "ThresholdCriterion": (ThresholdCriterionConfig, ThresholdCriterionRecord), }
[docs] class CriteriaReport(BaseModel): BaseRangeCriterion: BaseRangeCriterionRecord | None = None BaseThresholdCriterion: BaseThresholdCriterionRecord | None = None RangeCriterion: RangeCriterionRecord | None = None TelescopeRangeCriterion: TelescopeRangeCriterionRecord | None = None TelescopeThresholdCriterion: TelescopeThresholdCriterionRecord | None = None ThresholdCriterion: ThresholdCriterionRecord | None = None @model_validator(mode='before') @classmethod def _exactly_one(cls, values): present = [k for k,v in values.items() if v is not None] if len(present) != 1: raise ValueError("criteria report must contain exactly one criterion entry") return values
[docs] class FetchedMetadata(BaseModel): criteriaReport: CriteriaReport
[docs] class MetadataPayload(BaseModel): fetchedMetadata: FetchedMetadata