Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk): improved column definition class #138

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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