adlfs icon indicating copy to clipboard operation
adlfs copied to clipboard

DefaultAzureCredential authentication path throws NotImplementedError on Windows 10

Open edwardlonghurst opened this issue 3 years ago • 2 comments

What happened: On Windows 10: Including 'anon':False in the storage_options throws NotImplementedError on asyncio.get_child_watcher().attach_loop(self.loop)

What you expected to happen: DefaultAzureCredentials are used to authenticate

Minimal Complete Verifiable Example: On Windows 10:

import pandas as pd
url = "abfs://..."
pd.read_parquet(url, storage_options={"anon":False, "account_name":"..."})

Anything else we need to know?: Providing the credentials directly (thus avoiding the call to get_child_watcher) works fine:

from azure.identity.aio import DefaultAzureCredential as AIODefaultAzureCredential
import pandas as pd
url = "abfs://..."
pd.read_parquet(url, storage_options={"anon":False, "account_name":"...", 'credential':AIODefaultAzureCredential()})

Environment:

  • Dask version: 2021.8,1
  • adlfs version: 2021.8.2
  • fsspec version: 2021.7.0
  • Python version: 3.8.8
  • Operating System: Windows 10
  • Install method (conda, pip, source): pip

edwardlonghurst avatar Aug 26 '21 18:08 edwardlonghurst

Man, I've faced the same problem here.

My workaround was (you can see it in my fork, i'm preparing it for PR):

In get_default_azure_credential, I removed the asyncio part (Windows does not have get_child_watcher implemented, this function is Unix only):

https://github.com/gabrieldaiha/adlfs/blob/9d5283f5630e500f71d1ab91e7cc24e8c6592afb/adlfs/spec.py#L532-L539

I moved the get_default_azure_credential call from do_connect function to the init function, like get_service_principal_credential does. I added a new weakref.finalize to async credentials too, in order to avoid Unclosed Client Session ERROR in the exit of the program

https://github.com/gabrieldaiha/adlfs/blob/9d5283f5630e500f71d1ab91e7cc24e8c6592afb/adlfs/spec.py#L455-L466

gabrieldaiha avatar Jun 30 '22 12:06 gabrieldaiha

I think this issue is fixed by #328, thus it can be closed. And the comment about the issue can be removed from https://github.com/fsspec/adlfs/blob/b01b30d5bbffcb0a49033cc4c90af1cba9da3fe2/adlfs/spec.py#L255

PeterFogh avatar Nov 29 '22 12:11 PeterFogh