Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError when defining an Azure UPath with protocol "abfss" #310

Open
jslorrma opened this issue Nov 14, 2024 · 0 comments · May be fixed by #311
Open

ValueError when defining an Azure UPath with protocol "abfss" #310

jslorrma opened this issue Nov 14, 2024 · 0 comments · May be fixed by #311

Comments

@jslorrma
Copy link

jslorrma commented Nov 14, 2024

Description

When attempting to define a UPath with the Azure protocol "abfss", a ValueError is raised:

File .../lib/python3.11/site-packages/upath/implementations/cloud.py:104, in AzurePath.__init__(self, protocol, *args, **storage_options)
    102 print(self.drive, len(self.parts))
    103 if not self.drive and len(self.parts) > 1:
--> 104     raise ValueError("non key-like path provided (bucket/container missing)")

ValueError: non key-like path provided (bucket/container missing)

Steps to Reproduce

Define a UPath with the "abfss" protocol:

from upath import UPath
from azure.identity import DefaultAzureCredential

credential = DefaultAzureCredential(exclude_managed_identity_credential=True)
UPath("abfss://<container>@<account_name>.dfs.core.windows.net/<path>/", credential=credential)

Analysis

From my debugging and analysis the root cause of this issue is that the "abfss" protocol is missing in the WrappedFileSystemFlavour.protocol_config["netloc_is_anchor"] list here. This list only includes "abfs", "az", and "adl" from the adlfs filesystem protocols. Consequently, paths like "abfs://container/path..." function as expected, but paths starting with "abfss"-protocol trigger an error. On closer look, it turns out that the absence of "abfss" in the netloc_is_anchor list causes the splitdrive method here of WrappedFileSystemFlavour to return an empty drive.

def splitdrive(self, path: PathOrStr) -> tuple[str, str]:
    if self.netloc_is_anchor:  # <-- this evaluates to False in case of "abfss" is used in UPath
    ...
    else:
        # all other cases don't have a drive
        return "", path

Question

Is the exclusion of the "abfss" protocol in the netloc_is_anchor list intentional or a mistake?

@jslorrma jslorrma linked a pull request Nov 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant