Skip to content

Commit

Permalink
feat(sdk): improved column definition class (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
maocorte authored Jul 25, 2024
1 parent 039960b commit d126e15
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 81 deletions.
4 changes: 4 additions & 0 deletions sdk/radicalbit_platform_sdk/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
RegressionModelQuality,
)
from .dataset_stats import DatasetStats
from .field_type import FieldType
from .file_upload_result import CurrentFileUpload, FileReference, ReferenceFileUpload
from .job_status import JobStatus
from .model_definition import (
Expand All @@ -39,6 +40,7 @@
OutputType,
)
from .model_type import ModelType
from .supported_types import SupportedTypes

__all__ = [
'OutputType',
Expand Down Expand Up @@ -76,4 +78,6 @@
'CurrentFileUpload',
'FileReference',
'AwsCredentials',
'SupportedTypes',
'FieldType',
]
13 changes: 10 additions & 3 deletions sdk/radicalbit_platform_sdk/models/column_definition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from radicalbit_platform_sdk.models.field_type import FieldType
from radicalbit_platform_sdk.models.supported_types import SupportedTypes

class ColumnDefinition(BaseModel):

class ColumnDefinition(BaseModel, validate_assignment=True):
name: str
type: str
type: SupportedTypes
field_type: FieldType = Field(alias='fieldType')

model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
23 changes: 23 additions & 0 deletions sdk/radicalbit_platform_sdk/models/field_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from enum import Enum

from radicalbit_platform_sdk.models.supported_types import SupportedTypes


class FieldType(str, Enum):
categorical = 'categorical'
numerical = 'numerical'
datetime = 'datetime'

@staticmethod
def from_supported_type(value: SupportedTypes) -> 'FieldType':
match value:
case SupportedTypes.datetime:
return FieldType.datetime
case SupportedTypes.int:
return FieldType.numerical
case SupportedTypes.float:
return FieldType.numerical
case SupportedTypes.bool:
return FieldType.categorical
case SupportedTypes.string:
return FieldType.categorical
9 changes: 9 additions & 0 deletions sdk/radicalbit_platform_sdk/models/supported_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from enum import Enum


class SupportedTypes(str, Enum):
string = 'string'
int = 'int'
float = 'float'
bool = 'bool'
datetime = 'datetime'
Loading

0 comments on commit d126e15

Please sign in to comment.