From 7e6d494214ff37749dd5b572343a51ef2ed54349 Mon Sep 17 00:00:00 2001 From: Alex Arvanitidis Date: Mon, 9 Dec 2024 12:59:43 +0200 Subject: [PATCH] chore: update openapi specs --- src/jaqpot_api_client/__init__.py | 1 + src/jaqpot_api_client/models/__init__.py | 1 + src/jaqpot_api_client/models/docker_config.py | 98 +++++++++++++++++++ src/jaqpot_api_client/models/feature_type.py | 1 + src/jaqpot_api_client/models/model.py | 8 +- src/jaqpot_api_client/models/model_type.py | 1 + .../models/prediction_model.py | 7 +- 7 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 src/jaqpot_api_client/models/docker_config.py diff --git a/src/jaqpot_api_client/__init__.py b/src/jaqpot_api_client/__init__.py index 5cd1343..0e0016d 100644 --- a/src/jaqpot_api_client/__init__.py +++ b/src/jaqpot_api_client/__init__.py @@ -54,6 +54,7 @@ from jaqpot_api_client.models.dataset_type import DatasetType from jaqpot_api_client.models.doa import Doa from jaqpot_api_client.models.doa_method import DoaMethod +from jaqpot_api_client.models.docker_config import DockerConfig from jaqpot_api_client.models.error_code import ErrorCode from jaqpot_api_client.models.error_response import ErrorResponse from jaqpot_api_client.models.feature import Feature diff --git a/src/jaqpot_api_client/models/__init__.py b/src/jaqpot_api_client/models/__init__.py index 9531fd0..09b5f67 100644 --- a/src/jaqpot_api_client/models/__init__.py +++ b/src/jaqpot_api_client/models/__init__.py @@ -27,6 +27,7 @@ from jaqpot_api_client.models.dataset_type import DatasetType from jaqpot_api_client.models.doa import Doa from jaqpot_api_client.models.doa_method import DoaMethod +from jaqpot_api_client.models.docker_config import DockerConfig from jaqpot_api_client.models.error_code import ErrorCode from jaqpot_api_client.models.error_response import ErrorResponse from jaqpot_api_client.models.feature import Feature diff --git a/src/jaqpot_api_client/models/docker_config.py b/src/jaqpot_api_client/models/docker_config.py new file mode 100644 index 0000000..eae1a45 --- /dev/null +++ b/src/jaqpot_api_client/models/docker_config.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + Jaqpot API + + A modern RESTful API for model management and prediction services, built using Spring Boot and Kotlin. Supports seamless integration with machine learning workflows. + + The version of the OpenAPI document: 1.0.0 + Contact: upci.ntua@gmail.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class DockerConfig(BaseModel): + """ + DockerConfig + """ # noqa: E501 + app_name: Annotated[str, Field(strict=True, max_length=63)] = Field(description="Unique identifier used for internal service discovery", alias="appName") + docker_image: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Reference to the Docker image (for admin documentation)", alias="dockerImage") + __properties: ClassVar[List[str]] = ["appName", "dockerImage"] + + @field_validator('app_name') + def app_name_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match(r"^[a-z0-9][a-z0-9-]*[a-z0-9]$", value): + raise ValueError(r"must validate the regular expression /^[a-z0-9][a-z0-9-]*[a-z0-9]$/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DockerConfig from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DockerConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "appName": obj.get("appName"), + "dockerImage": obj.get("dockerImage") + }) + return _obj + + diff --git a/src/jaqpot_api_client/models/feature_type.py b/src/jaqpot_api_client/models/feature_type.py index 4f7ee4b..f8358c9 100644 --- a/src/jaqpot_api_client/models/feature_type.py +++ b/src/jaqpot_api_client/models/feature_type.py @@ -33,6 +33,7 @@ class FeatureType(str, Enum): SMILES = 'SMILES' STRING = 'STRING' TEXT = 'TEXT' + BOOLEAN = 'BOOLEAN' FLOAT_ARRAY = 'FLOAT_ARRAY' STRING_ARRAY = 'STRING_ARRAY' diff --git a/src/jaqpot_api_client/models/model.py b/src/jaqpot_api_client/models/model.py index 1c566c0..f6d27c0 100644 --- a/src/jaqpot_api_client/models/model.py +++ b/src/jaqpot_api_client/models/model.py @@ -23,6 +23,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated from jaqpot_api_client.models.doa import Doa +from jaqpot_api_client.models.docker_config import DockerConfig from jaqpot_api_client.models.feature import Feature from jaqpot_api_client.models.library import Library from jaqpot_api_client.models.model_scores import ModelScores @@ -67,9 +68,10 @@ class Model(BaseModel): legacy_prediction_service: Optional[StrictStr] = Field(default=None, alias="legacyPredictionService") scores: Optional[ModelScores] = None r_pbpk_config: Optional[RPbpkConfig] = Field(default=None, alias="rPbpkConfig") + docker_config: Optional[DockerConfig] = Field(default=None, alias="dockerConfig") created_at: Optional[datetime] = Field(default=None, description="The date and time when the feature was created.", alias="createdAt") updated_at: Optional[datetime] = Field(default=None, description="The date and time when the model was last updated.", alias="updatedAt") - __properties: ClassVar[List[str]] = ["id", "name", "description", "type", "jaqpotpyVersion", "doas", "libraries", "dependentFeatures", "independentFeatures", "sharedWithOrganizations", "visibility", "task", "archived", "archivedAt", "torchConfig", "preprocessors", "featurizers", "rawPreprocessor", "rawModel", "creator", "canEdit", "isAdmin", "selectedFeatures", "tags", "legacyPredictionService", "scores", "rPbpkConfig", "createdAt", "updatedAt"] + __properties: ClassVar[List[str]] = ["id", "name", "description", "type", "jaqpotpyVersion", "doas", "libraries", "dependentFeatures", "independentFeatures", "sharedWithOrganizations", "visibility", "task", "archived", "archivedAt", "torchConfig", "preprocessors", "featurizers", "rawPreprocessor", "rawModel", "creator", "canEdit", "isAdmin", "selectedFeatures", "tags", "legacyPredictionService", "scores", "rPbpkConfig", "dockerConfig", "createdAt", "updatedAt"] model_config = ConfigDict( populate_by_name=True, @@ -168,6 +170,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of r_pbpk_config if self.r_pbpk_config: _dict['rPbpkConfig'] = self.r_pbpk_config.to_dict() + # override the default output from pydantic by calling `to_dict()` of docker_config + if self.docker_config: + _dict['dockerConfig'] = self.docker_config.to_dict() return _dict @classmethod @@ -207,6 +212,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "legacyPredictionService": obj.get("legacyPredictionService"), "scores": ModelScores.from_dict(obj["scores"]) if obj.get("scores") is not None else None, "rPbpkConfig": RPbpkConfig.from_dict(obj["rPbpkConfig"]) if obj.get("rPbpkConfig") is not None else None, + "dockerConfig": DockerConfig.from_dict(obj["dockerConfig"]) if obj.get("dockerConfig") is not None else None, "createdAt": obj.get("createdAt"), "updatedAt": obj.get("updatedAt") }) diff --git a/src/jaqpot_api_client/models/model_type.py b/src/jaqpot_api_client/models/model_type.py index 1cc7fe2..bbf6e47 100644 --- a/src/jaqpot_api_client/models/model_type.py +++ b/src/jaqpot_api_client/models/model_type.py @@ -41,6 +41,7 @@ class ModelType(str, Enum): R_SVM = 'R_SVM' R_TREE_CLASS = 'R_TREE_CLASS' R_TREE_REGR = 'R_TREE_REGR' + DOCKER = 'DOCKER' QSAR_TOOLBOX_CALCULATOR = 'QSAR_TOOLBOX_CALCULATOR' QSAR_TOOLBOX_QSAR_MODEL = 'QSAR_TOOLBOX_QSAR_MODEL' QSAR_TOOLBOX_PROFILER = 'QSAR_TOOLBOX_PROFILER' diff --git a/src/jaqpot_api_client/models/prediction_model.py b/src/jaqpot_api_client/models/prediction_model.py index b454573..a6f7188 100644 --- a/src/jaqpot_api_client/models/prediction_model.py +++ b/src/jaqpot_api_client/models/prediction_model.py @@ -32,7 +32,7 @@ class PredictionModel(BaseModel): """ PredictionModel """ # noqa: E501 - id: Optional[StrictInt] = Field(default=None, description="Unique identifier for the prediction model") + id: StrictInt = Field(description="Unique identifier for the prediction model") dependent_features: List[Feature] = Field(description="List of dependent features for the model", alias="dependentFeatures") independent_features: List[Feature] = Field(description="List of independent features for the model", alias="independentFeatures") type: ModelType @@ -123,11 +123,6 @@ def to_dict(self) -> Dict[str, Any]: if _item_preprocessors: _items.append(_item_preprocessors.to_dict()) _dict['preprocessors'] = _items - # set to None if id (nullable) is None - # and model_fields_set contains the field - if self.id is None and "id" in self.model_fields_set: - _dict['id'] = None - # set to None if torch_config (nullable) is None # and model_fields_set contains the field if self.torch_config is None and "torch_config" in self.model_fields_set: