-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): improved column definition class (#138)
- Loading branch information
Showing
8 changed files
with
345 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Oops, something went wrong.