Skip to content

Commit

Permalink
Remove forward references
Browse files Browse the repository at this point in the history
  • Loading branch information
olokobayusuf committed Jan 24, 2024
1 parent e62e2f2 commit 38d3c7b
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 85 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion fxn/types/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Copyright © 2024 NatML Inc. All Rights Reserved.
#

from __future__ import annotations
from pydantic import BaseModel

class EnvironmentVariable (BaseModel):
Expand Down
25 changes: 12 additions & 13 deletions fxn/types/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
configuration: Optional[str] = None
139 changes: 69 additions & 70 deletions fxn/types/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
"""
Expand All @@ -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"
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
1 change: 0 additions & 1 deletion fxn/types/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 38d3c7b

Please sign in to comment.