Skip to content

Commit

Permalink
Fix FlyteDirectory on Azure (#2564)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Newton <[email protected]>
  • Loading branch information
Tom-Newton authored Jul 5, 2024
1 parent ecbfe51 commit 05f4ae6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions flytekit/remote/remote_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def extract_common(native_urls: typing.List[str]) -> str:
else:
break

fs = fsspec.filesystem(get_protocol(native_urls[0]))
sep = fs.sep
fs_class = fsspec.get_filesystem_class(get_protocol(native_urls[0]))
sep = fs_class.sep
# split the common prefix on the last separator so we don't get any trailing characters.
common_prefix = common_prefix.rsplit(sep, 1)[0]
logger.debug(f"Returning {common_prefix} from {native_urls}")
Expand Down
14 changes: 9 additions & 5 deletions tests/flytekit/unit/remote/test_fs_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ def test_remote_upload_with_data_persistence(sandbox_remote):
assert res == f"s3://my-s3-bucket/flytesnacks/development/O55F24U7RMLDOUI3LZ6SL4ZBEI======/{only_file}"


def test_common_matching():
@pytest.mark.parametrize("url_prefix", ["s3://my-s3-bucket", "abfs://my-azure-container", "abfss://my-azure-container", "gcs://my-gcs-bucket"])
def test_common_matching(url_prefix):
urls = [
"s3://my-s3-bucket/flytesnacks/development/ABCYZWMPACZAJ2MABGMOZ6CCPY======/source/empty.md",
"s3://my-s3-bucket/flytesnacks/development/ABCXKL5ZZWXY3PDLM3OONUHHME======/source/nested/more.txt",
"s3://my-s3-bucket/flytesnacks/development/ABCXBAPBKONMADXVW5Q3J6YBWM======/source/original.txt",
url_prefix + url_suffix
for url_suffix in [
"/flytesnacks/development/ABCYZWMPACZAJ2MABGMOZ6CCPY======/source/empty.md",
"/flytesnacks/development/ABCXKL5ZZWXY3PDLM3OONUHHME======/source/nested/more.txt",
"/flytesnacks/development/ABCXBAPBKONMADXVW5Q3J6YBWM======/source/original.txt",
]
]

assert FlyteFS.extract_common(urls) == "s3://my-s3-bucket/flytesnacks/development"
assert FlyteFS.extract_common(urls) == url_prefix + "/flytesnacks/development"


def test_hashing(sandbox_remote, source_folder):
Expand Down

0 comments on commit 05f4ae6

Please sign in to comment.