Skip to content

Commit

Permalink
Preliminary work on querying for only "validated" models (i.e. models…
Browse files Browse the repository at this point in the history
… for which validation tests have been run, whether the model performance on the test is good or bad)
  • Loading branch information
apdavison committed Oct 22, 2024
1 parent 4fbc8c7 commit 10b6ea5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions validation_service_api/validation_service/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 10b6ea5

Please sign in to comment.