From 8419de40022bc4dd16cd9f57a48b0977beb58668 Mon Sep 17 00:00:00 2001 From: pryce-turner Date: Wed, 31 Jul 2024 13:43:20 -0700 Subject: [PATCH] Formatting Signed-off-by: pryce-turner --- flytekit/core/data_persistence.py | 14 ++++++++------ tests/flytekit/unit/core/test_data_persistence.py | 5 ++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/flytekit/core/data_persistence.py b/flytekit/core/data_persistence.py index c80c473d21..a6b401bff8 100644 --- a/flytekit/core/data_persistence.py +++ b/flytekit/core/data_persistence.py @@ -461,12 +461,14 @@ def generate_new_custom_path( stem: typing.Optional[str] = None, ) -> str: """ - Generates a new path with the raw output prefix and a random string appended to it. Optionally, you can provide - an alternate prefix and a stem. If stem is provided, it will be appended to the path instead of a random string. If alt is provided, it - will replace the first part of the output prefix, e.g. the S3 or GCS bucket. - - If wanting to write to a non-random prefix in a non-default S3 bucket, this can be called with - alt="my-alt-bucket" and stem="my-stem" to generate a path like s3://my-alt-bucket/default-prefix-part/my-stem + Generates a new path with the raw output prefix and a random string appended to it. + Optionally, you can provide an alternate prefix and a stem. If stem is provided, it + will be appended to the path instead of a random string. If alt is provided, it will + replace the first part of the output prefix, e.g. the S3 or GCS bucket. + + If wanting to write to a non-random prefix in a non-default S3 bucket, this can be + called with alt="my-alt-bucket" and stem="my-stem" to generate a path like + s3://my-alt-bucket/default-prefix-part/my-stem :param fs: The filesystem to use. If None, the context's raw output filesystem is used. :param alt: An alternate first member of the prefix to use instead of the default. diff --git a/tests/flytekit/unit/core/test_data_persistence.py b/tests/flytekit/unit/core/test_data_persistence.py index e8535bb245..5063e484d2 100644 --- a/tests/flytekit/unit/core/test_data_persistence.py +++ b/tests/flytekit/unit/core/test_data_persistence.py @@ -141,7 +141,10 @@ def test_generate_new_custom_path(): Test that a new path given alternate bucket and name is generated correctly """ random_dir = tempfile.mkdtemp() - fs = FileAccessProvider(local_sandbox_dir=random_dir, raw_output_prefix="s3://my-default-bucket/my-default-prefix/") + fs = FileAccessProvider( + local_sandbox_dir=random_dir, + raw_output_prefix="s3://my-default-bucket/my-default-prefix/" + ) np = fs.generate_new_custom_path(alt="foo-bucket", stem="bar.txt") assert np == "s3://foo-bucket/my-default-prefix/bar.txt"