From eec94d5b765a1516a0df06ae04e7a162477b279d Mon Sep 17 00:00:00 2001 From: Toby Drane Date: Tue, 22 Aug 2023 09:52:26 +0100 Subject: [PATCH] convert layer to string --- sdk/rapid/items/schema.py | 4 +--- sdk/rapid/rapid.py | 18 +++++++++--------- sdk/rapid/utils/constants.py | 18 ------------------ sdk/requirements.txt | 1 - 4 files changed, 10 insertions(+), 31 deletions(-) diff --git a/sdk/rapid/items/schema.py b/sdk/rapid/items/schema.py index ce6d2ea..9217946 100644 --- a/sdk/rapid/items/schema.py +++ b/sdk/rapid/items/schema.py @@ -2,8 +2,6 @@ from typing import Dict, List, Optional, Union from pydantic.main import BaseModel -from rapid.utils.constants import Layer - class SensitivityLevel(Enum): PUBLIC = "PUBLIC" @@ -22,7 +20,7 @@ class Owner(BaseModel): class SchemaMetadata(BaseModel): - layer: Layer + layer: str domain: str dataset: str sensitivity: SensitivityLevel diff --git a/sdk/rapid/rapid.py b/sdk/rapid/rapid.py index c58c063..3bb06b7 100644 --- a/sdk/rapid/rapid.py +++ b/sdk/rapid/rapid.py @@ -12,7 +12,7 @@ from rapid.auth import RapidAuth from rapid.items.schema import Schema from rapid.items.query import Query -from rapid.utils.constants import TIMEOUT_PERIOD, Layer +from rapid.utils.constants import TIMEOUT_PERIOD from rapid.exceptions import ( DataFrameUploadFailedException, DataFrameUploadValidationException, @@ -99,7 +99,7 @@ def wait_for_job_outcome(self, _id: str, interval: int = 1): def download_dataframe( self, - layer: Layer, + layer: str, domain: str, dataset: str, version: Optional[int] = None, @@ -109,7 +109,7 @@ def download_dataframe( Downloads data to a pandas DataFrame based on the domain, dataset and version passed. Args: - layer (Layer): The layer of the dataset to download the DataFrame from. + layer (str): The layer of the dataset to download the DataFrame from. domain (str): The domain of the dataset to download the DataFrame from. dataset (str): The dataset from the domain to download the DataFrame from. version (int, optional): Version of the dataset to download. @@ -142,7 +142,7 @@ def download_dataframe( def upload_dataframe( self, - layer: Layer, + layer: str, domain: str, dataset: str, df: DataFrame, @@ -152,7 +152,7 @@ def upload_dataframe( Uploads a pandas DataFrame to a specified dataset in the API. Args: - layer (Layer): The layer of the dataset to upload the DataFrame to. + layer (str): The layer of the dataset to upload the DataFrame to. domain (str): The domain of the dataset to upload the DataFrame to. dataset (str): The name of the dataset to upload the DataFrame to. df (DataFrame): The pandas DataFrame to upload. @@ -190,13 +190,13 @@ def upload_dataframe( data["details"], ) - def generate_info(self, df: DataFrame, layer: Layer, domain: str, dataset: str): + def generate_info(self, df: DataFrame, layer: str, domain: str, dataset: str): """ Generates metadata information for a pandas DataFrame and a specified dataset in the API. Args: df (DataFrame): The pandas DataFrame to generate metadata for. - layer (Layer): The layer of the dataset to generate metadata for. + layer (str): The layer of the dataset to generate metadata for. domain (str): The domain of the dataset to generate metadata for. dataset (str): The name of the dataset to generate metadata for. @@ -239,14 +239,14 @@ def convert_dataframe_for_file_upload(self, df: DataFrame): } def generate_schema( - self, df: DataFrame, layer: Layer, domain: str, dataset: str, sensitivity: str + self, df: DataFrame, layer: str, domain: str, dataset: str, sensitivity: str ) -> Schema: """ Generates a schema for a pandas DataFrame and a specified dataset in the API. Args: df (DataFrame): The pandas DataFrame to generate a schema for. - layer (Layer): The layer of the dataset to generate a schema for. + layer (str): The layer of the dataset to generate a schema for. domain (str): The domain of the dataset to generate a schema for. dataset (str): The name of the dataset to generate a schema for. sensitivity (str): The sensitivity level of the schema to generate. diff --git a/sdk/rapid/utils/constants.py b/sdk/rapid/utils/constants.py index dcdf8f8..e86af19 100644 --- a/sdk/rapid/utils/constants.py +++ b/sdk/rapid/utils/constants.py @@ -1,19 +1 @@ -import os -from strenum import StrEnum - TIMEOUT_PERIOD = 30 - -LAYERS = "LAYERS" -DEFAULT = "default" - - -def get_layers_from_environment(): - input = os.environ.get(LAYERS, DEFAULT) - layers = [layer.lower() for layer in input.split(",")] - return layers - - -# Dynamically creates the Layer Enum from the environment variables -Layer = StrEnum( - "Layer", dict([(layer, layer) for layer in get_layers_from_environment()]) -) diff --git a/sdk/requirements.txt b/sdk/requirements.txt index 06bf981..c086b21 100644 --- a/sdk/requirements.txt +++ b/sdk/requirements.txt @@ -7,4 +7,3 @@ requests requests-mock twine pydantic -strenum