Source code for chap_core.rest_api.data_models
from typing import List
from pydantic import BaseModel
from chap_core.api_types import FeatureCollectionModel
from chap_core.database.base_tables import DBModel
from chap_core.database.dataset_tables import ObservationBase, DataSetCreateInfo
from chap_core.database.tables import BackTestBase, BackTestMetric, BackTestForecast, BackTestRead
[docs]
class PredictionBase(BaseModel):
orgUnit: str
dataElement: str
period: str
[docs]
class PredictionResponse(PredictionBase):
value: float
[docs]
class PredictionSamplResponse(PredictionBase):
values: list[float]
[docs]
class FullPredictionResponse(BaseModel):
diseaseId: str
dataValues: List[PredictionResponse]
[docs]
class FetchRequest(DBModel):
feature_name: str
data_source_name: str
[docs]
class DatasetMakeRequest(DataSetCreateInfo):
geojson: FeatureCollectionModel
provided_data: List[ObservationBase]
data_to_be_fetched: List[FetchRequest]
[docs]
class JobResponse(BaseModel):
id: str
[docs]
class PredictionParams(DBModel):
model_id: str
n_periods: int = 3
[docs]
class ValidationError(DBModel):
reason: str
org_unit: str
feature_name: str
time_periods: List[str]
[docs]
class ImportSummaryResponse(DBModel):
id: str | None
imported_count: int
rejected: list[ValidationError]
[docs]
class BackTestCreate(BackTestBase): ...
[docs]
class BackTestFull(BackTestRead):
metrics: list[BackTestMetric]
forecasts: list[BackTestForecast]