diff --git a/Changelog.md b/Changelog.md index 1a0b6bd..a088281 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,5 @@ ## 0.0.27 ++ Fixed pydantic forward reference errors when constructing `Signature` and `Predictor` instances. + Fixed `model_dump` error when making predictions in Google Colab due to outdated `pydantic` dependency. ## 0.0.26 diff --git a/fxn/types/environment.py b/fxn/types/environment.py index 38186d6..7737c0b 100644 --- a/fxn/types/environment.py +++ b/fxn/types/environment.py @@ -3,7 +3,6 @@ # Copyright © 2024 NatML Inc. All Rights Reserved. # -from __future__ import annotations from pydantic import BaseModel class EnvironmentVariable (BaseModel): diff --git a/fxn/types/prediction.py b/fxn/types/prediction.py index afa36a4..1d500e2 100644 --- a/fxn/types/prediction.py +++ b/fxn/types/prediction.py @@ -3,12 +3,22 @@ # Copyright © 2024 NatML Inc. All Rights Reserved. # -from __future__ import annotations from pydantic import BaseModel from typing import Any, List, Optional from .predictor import PredictorType +class PredictionResource (BaseModel): + """ + Prediction resource. + + Members: + id (str): Resource identifier. + url (str): Resource URL. + """ + id: str + url: str + class Prediction (BaseModel): """ Prediction. @@ -36,15 +46,4 @@ class Prediction (BaseModel): logs: Optional[str] = None implementation: Optional[str] = None resources: Optional[List[PredictionResource]] = None - configuration: Optional[str] = None - -class PredictionResource (BaseModel): - """ - Prediction resource. - - Members: - id (str): Resource identifier. - url (str): Resource URL. - """ - id: str - url: str \ No newline at end of file + configuration: Optional[str] = None \ No newline at end of file diff --git a/fxn/types/predictor.py b/fxn/types/predictor.py index 9183f5c..7848393 100644 --- a/fxn/types/predictor.py +++ b/fxn/types/predictor.py @@ -3,7 +3,6 @@ # Copyright © 2024 NatML Inc. All Rights Reserved. # -from __future__ import annotations from enum import Enum from pydantic import BaseModel, Field from typing import List, Optional, Tuple, Union @@ -12,49 +11,48 @@ from .profile import Profile from .value import Value -class Predictor (BaseModel): +class Acceleration (str, Enum): """ - Predictor. + Predictor acceleration. + """ + CPU = "CPU" + A40 = "A40" + A100 = "A100" - Members: - tag (str): Predictor tag. - owner (Profile): Predictor owner. - name (str): Predictor name. - type (PredictorType): Predictor type. - status (PredictorStatus): Predictor status. - access (AccessMode): Predictor access. - created (str): Date created. - description (str): Predictor description. - card (str): Predictor card. - media (str): Predictor media URL. - acceleration (Acceleration): Predictor acceleration. This only applies to cloud predictors. - signature (Signature): Predictor signature. This is only populated once predictor has been successfully provisioned. - license (str): Predictor license URL. +class AccessMode (str, Enum): """ - tag: str - owner: Profile - name: str - type: PredictorType - status: PredictorStatus - access: AccessMode - created: str - description: Optional[str] = None - card: Optional[str] = None - media: Optional[str] = None - acceleration: Optional[Acceleration] = None - signature: Optional[Signature] = None - license: Optional[str] = None + Predictor access mode. + """ + Public = "PUBLIC" + Private = "PRIVATE" + Protected = "PROTECTED" -class Signature (BaseModel): +class PredictorType (str, Enum): """ - Predictor signature. + Predictor type. + """ + Cloud = "CLOUD" + Edge = "EDGE" + +class PredictorStatus (str, Enum): + """ + Predictor status. + """ + Provisioning = "PROVISIONING" + Active = "ACTIVE" + Invalid = "INVALID" + Archived = "ARCHIVED" + +class EnumerationMember (BaseModel): + """ + Prediction parameter enumeration member. Members: - inputs (list): Input parameters. - outputs (list): Output parameters. + name (str): Enumeration member name. + value (str | int): Enumeration member value. """ - inputs: List[Parameter] - outputs: List[Parameter] + name: str + value: Union[str, int] class Parameter (BaseModel): """ @@ -79,45 +77,46 @@ class Parameter (BaseModel): default_value: Optional[Value] = None value_schema: Optional[dict] = Field(None, alias="schema") -class EnumerationMember (BaseModel): +class Signature (BaseModel): """ - Prediction parameter enumeration member. + Predictor signature. Members: - name (str): Enumeration member name. - value (str | int): Enumeration member value. - """ - name: str - value: Union[str, int] - -class Acceleration (str, Enum): - """ - Predictor acceleration. - """ - CPU = "CPU" - A40 = "A40" - A100 = "A100" - -class AccessMode (str, Enum): - """ - Predictor access mode. + inputs (list): Input parameters. + outputs (list): Output parameters. """ - Public = "PUBLIC" - Private = "PRIVATE" - Protected = "PROTECTED" + inputs: List[Parameter] + outputs: List[Parameter] -class PredictorType (str, Enum): - """ - Predictor type. +class Predictor (BaseModel): """ - Cloud = "CLOUD" - Edge = "EDGE" + Predictor. -class PredictorStatus (str, Enum): - """ - Predictor status. + Members: + tag (str): Predictor tag. + owner (Profile): Predictor owner. + name (str): Predictor name. + type (PredictorType): Predictor type. + status (PredictorStatus): Predictor status. + access (AccessMode): Predictor access. + created (str): Date created. + description (str): Predictor description. + card (str): Predictor card. + media (str): Predictor media URL. + acceleration (Acceleration): Predictor acceleration. This only applies to cloud predictors. + signature (Signature): Predictor signature. This is only populated once predictor has been successfully provisioned. + license (str): Predictor license URL. """ - Provisioning = "PROVISIONING" - Active = "ACTIVE" - Invalid = "INVALID" - Archived = "ARCHIVED" \ No newline at end of file + tag: str + owner: Profile + name: str + type: PredictorType + status: PredictorStatus + access: AccessMode + created: str + description: Optional[str] = None + card: Optional[str] = None + media: Optional[str] = None + acceleration: Optional[Acceleration] = None + signature: Optional[Signature] = None + license: Optional[str] = None \ No newline at end of file diff --git a/fxn/types/value.py b/fxn/types/value.py index 9725413..df7258f 100644 --- a/fxn/types/value.py +++ b/fxn/types/value.py @@ -3,7 +3,6 @@ # Copyright © 2024 NatML Inc. All Rights Reserved. # -from __future__ import annotations from pydantic import BaseModel from typing import List, Optional, Union