From 6b2ce3b38eab0d6645e08d48fbcf96470e094df1 Mon Sep 17 00:00:00 2001 From: Andrew <15331990+ahuang11@users.noreply.github.com> Date: Wed, 22 Feb 2023 17:48:32 -0800 Subject: [PATCH] Stop resolve_path defaulting to random UUID if path is "" (#212) --- CHANGELOG.md | 1 + prefect_aws/s3.py | 4 ---- tests/test_s3.py | 4 ++++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0556db2..ce93be10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed errors raised when using `write_path` and `read_path` with `credentials` field on `S3Bucket` - [#208](https://github.com/PrefectHQ/prefect-aws/pull/208) +- Resolving paths in `S3Bucket` unintentionally generating an arbitrary UUID when path is an empty string - [#212](https://github.com/PrefectHQ/prefect-gcp/pull/212) ## 0.2.4 diff --git a/prefect_aws/s3.py b/prefect_aws/s3.py index 5e0ff670..43d0efd2 100644 --- a/prefect_aws/s3.py +++ b/prefect_aws/s3.py @@ -6,7 +6,6 @@ import warnings from pathlib import Path, PurePath from typing import Any, BinaryIO, Dict, List, Optional, Union -from uuid import uuid4 import boto3 from botocore.paginate import PageIterator @@ -402,9 +401,6 @@ def _resolve_path(self, path: str) -> str: bucket has a unique key (or key name). """ - - path = path or str(uuid4()) - bucket_folder = self.bucket_folder or self.basepath # If basepath provided, it means we won't write to the root dir of # the bucket. So we need to add it on the front of the path. diff --git a/tests/test_s3.py b/tests/test_s3.py index 42c04416..936f3491 100644 --- a/tests/test_s3.py +++ b/tests/test_s3.py @@ -594,6 +594,10 @@ def test_deployment_set_basepath(aws_creds_block, type_): assert deployment.location == "home/" +def test_resolve_path(s3_bucket): + assert s3_bucket._resolve_path("") == "" + + class TestS3Bucket: @pytest.fixture( params=[