From 10b6ea53bf1ecb942b2d6d292a874f7524b4b3e8 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Tue, 22 Oct 2024 17:06:15 +0200 Subject: [PATCH] Preliminary work on querying for only "validated" models (i.e. models for which validation tests have been run, whether the model performance on the test is good or bad) --- validation_service_api/validation_service/data_models.py | 3 +++ .../validation_service/resources/models.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/validation_service_api/validation_service/data_models.py b/validation_service_api/validation_service/data_models.py index 0115324d..93361143 100644 --- a/validation_service_api/validation_service/data_models.py +++ b/validation_service_api/validation_service/data_models.py @@ -517,6 +517,7 @@ class ScientificModel(BaseModel): images: List[Image] = None old_uuid: UUID = None instances: List[ModelInstance] = None + validation_count: int = 0 class Config: schema_extra = {"example": EXAMPLES["ScientificModel"]} @@ -669,11 +670,13 @@ class ScientificModelSummary(BaseModel): description: str date_created: datetime = None format: List[str] = None + validation_count: int = 0 @classmethod def from_kg_query(cls, item, client): item.pop("@context") item["id"] = client.uuid_from_uri(item["uri"]) + item["validation_count"] = len(item.pop("validations", [])) return cls(**item) @classmethod diff --git a/validation_service_api/validation_service/resources/models.py b/validation_service_api/validation_service/resources/models.py index 63015e04..b68a7ea9 100644 --- a/validation_service_api/validation_service/resources/models.py +++ b/validation_service_api/validation_service/resources/models.py @@ -118,6 +118,7 @@ async def query_models( format: str = Query(None, description="Model format expressed as a content type"), private: bool = Query(None, description="Limit the search to public or private models"), summary: bool = Query(False, description="Return only summary information about each model"), + validated: bool = Query(False, description="Limit the search to models for which there are validation results"), size: int = Query(100, description="Maximum number of responses"), from_index: int = Query(0, description="Index of the first response returned"), # from header @@ -222,7 +223,10 @@ async def query_models( if summary: cls = ScientificModelSummary - query_label = "VF_ScientificModelSummary" + if validated: + query_label = "VF_ValidatedScientificModelSummary" + else: + query_label = "VF_ScientificModelSummary" else: cls = ScientificModel query_label = "VF_ScientificModel"