From 260359468fba05b5fc84ab43118e9ee31c6f533d Mon Sep 17 00:00:00 2001 From: Todd Birchard Date: Wed, 7 Aug 2024 18:46:53 -0400 Subject: [PATCH] Bring repo to functionality and usability standards. --- .env.example | 4 ++ Makefile | 2 +- README.md | 23 +++--- config.py | 26 +++++-- files/peas.jpg | Bin 32835 -> 0 bytes files/test.csv | 15 ---- googlecloud_storage_tutorial/__init__.py | 19 +++-- googlecloud_storage_tutorial/storage.py | 85 +++++++++++++---------- poetry.lock | 55 ++++++++++++++- pyproject.toml | 2 + 10 files changed, 157 insertions(+), 74 deletions(-) create mode 100644 .env.example delete mode 100644 files/peas.jpg delete mode 100644 files/test.csv diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..97237e2 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +GCP_BUCKET_URL="https://console.cloud.google.com/storage/browser/[BUCKET_NAME]" +GCP_BUCKET_NAME="[BUCKET_NAME]" +GCP_BUCKET_FOLDER_NAME="foo/bar" +GOOGLE_APPLICATION_CREDENTIALS="gcloud.json" \ No newline at end of file diff --git a/Makefile b/Makefile index 033b9ec..c801821 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ $(VIRTUAL_ENV): .PHONY: run run: env - $(LOCAL_PYTHON) -m main:init_script + $(LOCAL_PYTHON) -m main .PHONY: install diff --git a/README.md b/README.md index adba279..9ff5fb9 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,25 @@ Source for the accompanying tutorial here: [https://hackersandslackers.com/googl ## Getting Started -Installation is recommended via Makefile +Get set up locally in two steps: -```shell -$ git clone https://github.com/hackersandslackers/googlecloud-storage-tutorial.git -$ cd googlecloud-storage-tutorial -$ make install -``` +### Environment Variables + +Replace the values in **.env.example** with your values and rename this file to **.env**: + +* `GCP_BUCKET_URL`: URL of your Google Cloud Storage bucket. +* `GCP_BUCKET_NAME`: Name of your Google Cloud Storage bucket. +* `GCP_BUCKET_FOLDER_NAME`: Directory within your bucket to store and modify files. +* `GOOGLE_APPLICATION_CREDENTIALS`: Path to your Google Cloud Platform service account key file. + +### Installation -### Usage +Get up and running with `make run`: ```shell -$ make run +git clone https://github.com/hackersandslackers/googlecloud-storage-tutorial.git +cd googlecloud-storage-tutorial +make run ``` ----- diff --git a/config.py b/config.py index ea104a5..e9ae96d 100644 --- a/config.py +++ b/config.py @@ -1,10 +1,22 @@ """Google Cloud Storage Configuration.""" -from os import environ -# Google Cloud Storage -bucket_url = environ.get("GCP_BUCKET_URL") -bucket_name = environ.get("GCP_BUCKET_NAME") -bucket_dir = environ.get("GCP_BUCKET_FOLDER_NAME") +from os import environ, getenv, path -# Data -local_dir = environ.get("LOCAL_FOLDER") +from dotenv import load_dotenv + +# Resolve local directory +BASE_DIR: str = path.abspath(path.dirname(__file__)) + +# Google Cloud Storage Secrets +environ["GOOGLE_APPLICATION_CREDENTIALS"] = "gcloud.json" +load_dotenv(path.join(BASE_DIR, ".env")) + +BUCKET_URL = getenv("GCP_BUCKET_URL") +BUCKET_NAME = getenv("GCP_BUCKET_NAME") +BUCKET_DIR = getenv("GCP_BUCKET_FOLDER_NAME") + +# Example local files +LOCAL_DIR = path.join(BASE_DIR, "files") +SAMPLE_CSV = path.join(BASE_DIR, "sample_csv.csv") +SAMPLE_IMG = path.join(BASE_DIR, "sample_image.jpg") +SAMPLE_TXT = path.join(BASE_DIR, "sample_text.txt") diff --git a/files/peas.jpg b/files/peas.jpg deleted file mode 100644 index 3e9e02fe1ddeee667a532bc899bb59536da36601..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32835 zcmeFZbwE{3*C@W}l$4ZCQHeu`bc=LI3mgs&hwerRrCR|(r4bR7E&-*bI|T%!rIoz< zfciYo`#$gYefM|o{p1Gj03{3QviUc013D7QPg&9b+#e*CKl+2j@#p>^ zBmLrm#E<-&H$KNDJ3s+ULCsvI=VRv^0PaOk?n^5J$mg2?-bD#84@A(NPXZ4BTue+% zEKFQ1EL=hyY#c%od|X_75^`c<5@KRdj6#_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dmsr|Bm5n{3+apJd~Hkok;A)CU&Tt$Cz$No%Y z=#{{|s_Wym`(Ql^hB@}2VB!h?>+;)eBQ~ag0r(m3u@{pxcFxYN74C6YeH6j9u@+u| zo|ilesk}+E#iaQ)Zt)W2BwzvOkyfiZXK$}C?AH&}OGcPe zIDB#CzhXEA)(bq&@YSP&yBmT17AK|mmc-gP#uE_D8YpasgReq3~ts{uDa1Ij$b7wmZE~1%v)O(%l@;> z*8gx(TICP@524FmGB3=n*qn3%8=VZB3Kq#II+JKNgP2QCr;jeo9;n#7?)nbjX#91+ zekSzxB-{IYVv<0d@IU7z_1F0w$g}5GygP(q&)j0NPGipUiwNr{@;Z#3!VKzhmFFev zT<+U=NT=9WjVZo;UG&k=G@0sn1vphcA)$+YuwfUAPP#@hc%F4ex^V?rQ?_;)a-xu5<1G|z5HaBuhqBxkgzK)*- z>mB9a(dLyPr9{<7u77Q7UIMjLC> str: +def list_files() -> List[Optional[str]]: """ - Upload files to GCP bucket. + List all objects with file extension in a GCP bucket. :param str bucket_name: Human-readable GCP bucket name. :param str bucket_dir: Bucket directory in which object exists. - :param str local_dir: Local file path to upload/download files. - :returns: str + :returns: List[Optional[str]] """ - files = [f for f in listdir(local_dir) if isfile(join(local_dir, f))] - for file in files: - local_file = local_dir + file - blob = bucket.blob(bucket_dir + file) - blob.upload_from_filename(local_file) - return f"Uploaded {files.join(', ')} to '{bucket_name}' bucket." + blobs = bucket.list_blobs(prefix=BUCKET_DIR) + blob_file_list = [blob.name for blob in blobs if "." in blob.name] + return blob_file_list -def list_files(bucket_dir: str) -> List[Optional[str]]: +def pick_random_file() -> str: """ - List all objects with file extension in a GCP bucket. + Pick a `random` file from GCP bucket. :param str bucket_name: Human-readable GCP bucket name. - :param str bucket_dir: Bucket directory in which object exists. - :returns: List[Optional[str]] + :returns: str """ - files = bucket.list_blobs(prefix=bucket_dir) - file_list = [file.name for file in files if "." in file.name] - return file_list + blobs = list_files() + rand = randint(0, len(blobs) - 1) + blob = bucket.blob(blobs[rand]) + return blob, blob.name -def download_random_file(bucket_name: str, local_dir: str) -> str: +def download_random_file(local_dir: str) -> Tuple[Blob, str]: """ Download random file from GCP bucket. @@ -54,15 +53,12 @@ def download_random_file(bucket_name: str, local_dir: str) -> str: :returns: str """ - fileList = list_files(bucket_name) - rand = randint(0, len(fileList) - 1) - blob = bucket.blob(fileList[rand]) - file_name = blob.name.split("/")[-1] - blob.download_to_filename(local_dir + file_name) - return f"{file_name} downloaded from bucket." + blob, blob_filename = pick_random_file() + blob.download_to_filename(f"{local_dir}/{blob.name.split('/')[-1]}") + return blob, blob_filename -def delete_file(bucket_name: str, bucket_dir: str) -> str: +def delete_file(bucket_name: str) -> str: """ Delete file from GCP bucket. @@ -71,13 +67,12 @@ def delete_file(bucket_name: str, bucket_dir: str) -> str: :returns: str """ - blob = bucket.blob(bucket_dir + file_name) - file_name = blob.name.split("/")[-1] - bucket.delete_blob(bucket_name + file_name) - return f"{file_name} deleted from bucket: {bucket_name}." + blob, blob_filename = pick_random_file() + bucket.delete_blob(blob_filename) + return f"{blob_filename} deleted from bucket: {bucket_name}." -def rename_file(bucket_dir: str, new_filename: str) -> str: +def rename_file(new_filename: str) -> str: """ Rename a file in GCP bucket. @@ -87,7 +82,25 @@ def rename_file(bucket_dir: str, new_filename: str) -> str: :returns: str """ - blob = bucket.blob(bucket_dir + file_name) - file_name = blob.name.split("/")[-1] + blob, blob_filename = pick_random_file() bucket.rename_blob(blob, new_name=new_filename) - return f"{file_name} renamed to {new_filename}." + return f"{blob_filename} renamed to {new_filename}." + + +def upload_files(bucket_name: str, bucket_dir: str, local_dir: str) -> str: + """ + Upload files to GCP bucket. + + :param str bucket_name: Human-readable GCP bucket name. + :param str bucket_dir: Bucket directory in which object exists. + :param str local_dir: Local file path to upload/download files. + + :returns: str + """ + files = [f for f in listdir(local_dir) if isfile(join(local_dir, f))] + for file in files: + local_file = f"{local_dir}/{file}" + print(f"local file = {local_file}\n") + blob = bucket.blob(f"{bucket_dir}/{file}") + blob.upload_from_filename(local_file) + return f"Uploaded {files} to '{bucket_name}' bucket." diff --git a/poetry.lock b/poetry.lock index eca8bfc..1154f7b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -489,6 +489,20 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "faker" +version = "26.2.0" +description = "Faker is a Python package that generates fake data for you." +optional = false +python-versions = ">=3.8" +files = [ + {file = "Faker-26.2.0-py3-none-any.whl", hash = "sha256:7b123090774deff5f2cd3eb92a84dcbbf1e163f30a6d07321b7852c11bfe6a75"}, + {file = "Faker-26.2.0.tar.gz", hash = "sha256:81768de19012147521140f0d8bf5353e501ac42c1065d25e0cac455d3615c0a7"}, +] + +[package.dependencies] +python-dateutil = ">=2.4" + [[package]] name = "fastjsonschema" version = "2.20.0" @@ -1260,6 +1274,34 @@ tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +[[package]] +name = "python-dateutil" +version = "2.9.0.post0" +description = "Extensions to the standard Python datetime module" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"}, + {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"}, +] + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "python-dotenv" +version = "1.0.1" +description = "Read key-value pairs from a .env file and set them as environment variables" +optional = false +python-versions = ">=3.8" +files = [ + {file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"}, + {file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"}, +] + +[package.extras] +cli = ["click (>=5.0)"] + [[package]] name = "pywin32-ctypes" version = "0.2.2" @@ -1451,6 +1493,17 @@ files = [ {file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"}, ] +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + [[package]] name = "tomli" version = "2.0.1" @@ -1623,4 +1676,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = ">=3.10,<4.0" -content-hash = "9a11e88ae48f48e4a8e386fe9e9fbbba235760dfa7e40277fa305c384622f1dc" +content-hash = "83c584ed145d4af9403e4bd68e561e37aeedcacc47b7783a947eb49ea5135bbe" diff --git a/pyproject.toml b/pyproject.toml index dc540c2..c196aa7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,8 @@ isort = "*" flake8 = "*" gunicorn = "*" poetry-plugin-export = "^1.8.0" +faker = "^26.2.0" +python-dotenv = "^1.0.1" [tool.poetry.scripts] run = "main:init_script"