Skip to content

Commit

Permalink
Merge branch 'v2.x' into fix/canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
imda-amdlahir authored Feb 25, 2025
2 parents 6df09a6 + 4bc7f31 commit e715460
Show file tree
Hide file tree
Showing 21 changed files with 1,089 additions and 1,141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
from typing import List, Optional

from aiverify_test_engine.utils.url_utils import get_absolute_path
from pydantic import AnyUrl, BaseModel, Field, FileUrl, validator
from pydantic import AnyUrl, BaseModel, ConfigDict, Field, FileUrl, field_validator


class ITestArguments(BaseModel):
testDataset: AnyUrl | FileUrl = Field(..., description="URI of test dataset")
mode: str = Field(
...,
description="Mode of model used, upload for model file and api for model api",
regex="^(upload|api)$",
pattern="^(upload|api)$",
)
modelType: str = Field(
..., description="AI model type", regex="^(classification|regression)$"
..., description="AI model type", pattern="^(classification|regression)$"
)
groundTruthDataset: Optional[AnyUrl | FileUrl] = Field(
None, description="URI of ground truth dataset"
Expand All @@ -25,11 +25,13 @@ class ITestArguments(BaseModel):
)
modelFile: Optional[AnyUrl | FileUrl] = Field(None, description="URI of model file")

@validator("modelType", pre=True)
@field_validator("modelType", mode="before")
@classmethod
def validate_model_type(cls, value):
return value.lower()

@validator("testDataset", "groundTruthDataset", "modelFile", pre=True)
@field_validator("testDataset", "groundTruthDataset", "modelFile", mode="before")
@classmethod
def validate_uri(cls, value):
return get_absolute_path(value)

Expand All @@ -44,7 +46,7 @@ class ITestResult(BaseModel):
description="Unique global identifier for the plugin",
min_length=1,
max_length=128,
regex=r"^[a-zA-Z0-9][a-zA-Z0-9-._]*$",
pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-._]*$",
)
cid: str = Field(
...,
Expand All @@ -68,10 +70,11 @@ class ITestResult(BaseModel):
description="List the test artifacts (e.g., images) produced by the algorithm, to be uploaded to API-GW",
)

class Config:
schema_extra = {
model_config = ConfigDict(
json_schema_extra={
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "/aiverify.algorithm.testresult.schema.json",
"title": "Algorithm Output Schema",
"description": "AI Verify algorithm output schema",
}
)
Loading

0 comments on commit e715460

Please sign in to comment.