From a9cb91ddd7b868101676dc2f3d0d99a672a93750 Mon Sep 17 00:00:00 2001 From: Maxence Guindon Date: Tue, 16 Apr 2024 13:07:10 +0000 Subject: [PATCH] Fixes #18: initial commit --- nachet/datastore.py | 35 +++++++++++++++++++++++++++++++++++ nachet/todo.py | 16 ++++++++++++++++ requirements.txt | 2 ++ 3 files changed, 53 insertions(+) create mode 100644 nachet/datastore.py create mode 100644 nachet/todo.py diff --git a/nachet/datastore.py b/nachet/datastore.py new file mode 100644 index 0000000..f442894 --- /dev/null +++ b/nachet/datastore.py @@ -0,0 +1,35 @@ +from azure.storage.blob import BlobServiceClient, ContainerClient +from azure.core.exceptions import ResourceNotFoundError + +class DatastoreErrors(Exception): + pass + +def get_blob_client(connection: str) -> BlobServiceClient: + """ + Returns a BlobServiceClient object initialized with the provided connection + string. + + Args: + connection (str): The connection string for the Azure Blob Storage + account. + + Returns: + BlobServiceClient: The initialized BlobServiceClient object. + + Raises: + DatastoreErrors: If the blob client cannot be retrieved. + """ + try: + return BlobServiceClient.from_connection_string(connection) + except ValueError as error: + raise DatastoreErrors("could not retrieve the blob client") from error + + +def get_testing_image(amount: int, blob_path: str, + blob_service_client: BlobServiceClient) -> list[str]: + pass + + +def get_user_image(amount: int, blob_path: str | list, + blob_service_client: BlobServiceClient) -> list[str]: + pass diff --git a/nachet/todo.py b/nachet/todo.py new file mode 100644 index 0000000..58f08e4 --- /dev/null +++ b/nachet/todo.py @@ -0,0 +1,16 @@ +# TODO Createa connexion to azure storage that can eventually be switch to a +# datastore connection + +# TODO Retrieve a user specified amount of testing image + +# TODO Retrieve a user specified amount of user image + +# TODO Have a datastructure for both image type + +# TODO have a user message displaying the end of the loading image. + +import os + +# Environment variable +AZURE_STORAGE_CONNECTION_STRING = os.env("AZURE_STORAGE_CONNECTION_STRING") +SEEDS_NAME = os.env("SEEDS_NAME") diff --git a/requirements.txt b/requirements.txt index 92c606b..d31c762 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ locust python-dotenv azure-cognitiveservices-search-websearch +azure-storage-blob +azure-identity msrest openpyxl natsort