Skip to content

Commit

Permalink
convert layer to string
Browse files Browse the repository at this point in the history
  • Loading branch information
TobyDrane committed Aug 22, 2023
1 parent 5836d67 commit eec94d5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 31 deletions.
4 changes: 1 addition & 3 deletions sdk/rapid/items/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -22,7 +20,7 @@ class Owner(BaseModel):


class SchemaMetadata(BaseModel):
layer: Layer
layer: str
domain: str
dataset: str
sensitivity: SensitivityLevel
Expand Down
18 changes: 9 additions & 9 deletions sdk/rapid/rapid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -142,7 +142,7 @@ def download_dataframe(

def upload_dataframe(
self,
layer: Layer,
layer: str,
domain: str,
dataset: str,
df: DataFrame,
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 0 additions & 18 deletions sdk/rapid/utils/constants.py
Original file line number Diff line number Diff line change
@@ -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()])
)
1 change: 0 additions & 1 deletion sdk/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ requests
requests-mock
twine
pydantic
strenum

0 comments on commit eec94d5

Please sign in to comment.