Skip to content

Commit

Permalink
feat(sdk): get all reference and current datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
maocorte committed Jun 25, 2024
1 parent 6967044 commit fd4ef3f
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion sdk/radicalbit_platform_sdk/apis/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import boto3
from botocore.exceptions import ClientError as BotoClientError
import pandas as pd
from pydantic import ValidationError
from pydantic import TypeAdapter, ValidationError
import requests

from radicalbit_platform_sdk.apis import ModelCurrentDataset, ModelReferenceDataset
Expand Down Expand Up @@ -89,6 +89,50 @@ def delete(self) -> None:
func=lambda _: None,
)

def get_reference_datasets(self) -> List[ModelReferenceDataset]:
def __callback(response: requests.Response) -> List[ModelReferenceDataset]:
try:
adapter = TypeAdapter(List[ReferenceFileUpload])
references = adapter.validate_python(response.json())

return [
ModelReferenceDataset(
self.__base_url, self.__uuid, self.__model_type, ref
)
for ref in references
]
except ValidationError as e:
raise ClientError(f'Unable to parse response: {response.text}') from e

return invoke(
method='GET',
url=f'{self.__base_url}/api/models/{str(self.__uuid)}/reference/all',
valid_response_code=200,
func=__callback,
)

def get_current_datasets(self) -> List[ModelCurrentDataset]:
def __callback(response: requests.Response) -> List[ModelCurrentDataset]:
try:
adapter = TypeAdapter(List[CurrentFileUpload])
references = adapter.validate_python(response.json())

return [
ModelCurrentDataset(
self.__base_url, self.__uuid, self.__model_type, ref
)
for ref in references
]
except ValidationError as e:
raise ClientError(f'Unable to parse response: {response.text}') from e

return invoke(
method='GET',
url=f'{self.__base_url}/api/models/{str(self.__uuid)}/current/all',
valid_response_code=200,
func=__callback,
)

def load_reference_dataset(
self,
file_name: str,
Expand Down

0 comments on commit fd4ef3f

Please sign in to comment.