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

Cannot import name 'AccessTokenInfo' from 'azure.core.credentials' #37491

Closed
miladh opened this issue Sep 20, 2024 · 15 comments
Closed

Cannot import name 'AccessTokenInfo' from 'azure.core.credentials' #37491

miladh opened this issue Sep 20, 2024 · 15 comments
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Machine Learning needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@miladh
Copy link

miladh commented Sep 20, 2024

  • Package Name: az-ai-ml
  • Package Version: 1.19.0
  • Operating System: Linux
  • Python Version: 3.11

Describe the bug

Note

Apologies if this issue should have been created in a different repository. Please let me know if I should create this ticket elsewhere.

In this PR, the minimum version of azure-core was updated to include the new SupportTokenInfo protocol and AccessTokenInfo class. However, when attempting to install the Azure ML extension using:

az extension add --name ml

the following error occurs:

cannot import name 'AccessTokenInfo' from 'azure.core.credentials'

As this issue is currently disrupting our CI pipelines, we would be grateful for any guidance you can provide to help us address it promptly.

Possible Cause

This issue seems to arise because the Azure ML extension installs azure_identity-1.18.0, which relies on AccessTokenInfo from azure.core.credentials. However, azure-cli version 2.64.0 still uses an older version of azure-core (1.28.0), and hence the error above is thrown.

For reference, here’s the azure-cli requirements file.

To Reproduce
Steps to reproduce the behavior:

  1. Install az cli
  2. Run az extension add --name ml
@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Machine Learning needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. labels Sep 20, 2024
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github.

@levu74
Copy link

levu74 commented Sep 20, 2024

Yes, same for me. It's now a blocker for my CI pipelines.

@rikwatson
Copy link

This is no blocking all my ML pipelines

@MetelStairs
Copy link

MetelStairs commented Sep 20, 2024

This is blocking our pipelines also

@dionhaefner
Copy link

dionhaefner commented Sep 20, 2024

Thanks for the pointer to azure-identity @miladh – this works for me as a workaround on CI:

$ az extension add --upgrade --name ml -y
$ sudo /opt/az/bin/python3 -m pip install azure-identity==1.17.1

(use at your own risk)

@rikwatson
Copy link

Also a blocker for me (muliple training pipelines)

@pimonteiro
Copy link

Thanks for the pointer to azure-identity @miladh – this works for me as a workaround on CI:

$ az extension add --upgrade --name ml -y
$ sudo /opt/az/bin/python3 -m pip install azure-identity==1.17.1

(use at your own risk)

This workaround did work on our case.

@pvaneck
Copy link
Member

pvaneck commented Sep 20, 2024

Appears that there is some intermingling of dependencies.

Looking at where CLI extension dependencies are installed for me, (~/.azure/cliextensions/ml), I do see that there are compatible versions of azure-core and azure-identity installed. However, the versions of these packages installed in the azure-cli Python virtual environment (e.g. /opt/az/lib/python3.11/site-packages/) seem to take precedence at runtime causing incompatibilities.

I mentioned this in the linked azure-cli issue, but I think something may need updating in the dependency resolution logic when installing an extension. Ideally, azure-cli extension Python requirements should remain compatible with the base azure-cli requirements when the extension is installed (i.e. azure-identity 1.17.1 should automatically have been installed with the ML extension).

I believe the workaround, as mentioned above, is to install an older version of azure-identity in whatever virtual environment azure-cli is using.

Example workarounds:

Linux:

sudo /opt/az/bin/python3 -m pip install azure-identity==1.17.1

Windows (in elevated/administrator terminal):

C:\"Program Files (x86)"\"Microsoft SDKs"\Azure\CLI2\python.exe -m pip install azure-identity==1.17.1

Not sure about Mac, but probably just need to run the python executable somewhere in /opt/homebrew/Cellar/azure-cli/<version>/libexec/ ?

I think you can glean the location of the environment your azure-cli is using based on the error message:

cannot import name 'AccessTokenInfo' from 'azure.core.credentials' (/opt/az/lib/python3.11/site-packages/azure/core/credentials.py) -> Need to use python executable somewhere in /opt/az

@levu74
Copy link

levu74 commented Sep 20, 2024

@pvaneck for Linux, the workaround works. On my Windows machine, I ran the command (64-bit version), but it doesn't work.

@toby-coleman
Copy link

Same issue here - stopping all of our CI pipelines.

@adtcode216
Copy link

adtcode216 commented Sep 20, 2024

@toby-coleman As a temporary solution, you can add the following to your requirements.txt for a quick CI pipelines fix:

azure-identity==1.17.1

@steflommen
Copy link

steflommen commented Sep 20, 2024

@pvaneck for Linux, the workaround works. On my Windows machine, I ran the command (64-bit version), but it doesn't work.

For our azure pipelines the following command works
C:\"Program Files"\"Microsoft SDKs"\Azure\CLI2\python.exe -m pip install azure-identity==1.17.1

@PratibhaShrivastav18
Copy link
Member

This issue has been resolved. Please retry.
az extension add --name ml --version 2.30.0

@ezpzzz19
Copy link

ezpzzz19 commented Oct 7, 2024

please correct me if I am misunderstanding but this solution assumes that we are using / installed the azure-cli package. In our case we are not.
Will there be a fix directly on the newest version of azure-identity to solve the problem ? We would ideally want to stay up to date with the newest version of azure-identity

@pvaneck
Copy link
Member

pvaneck commented Oct 7, 2024

@ezpzzz19 The latest version of azure-identity already requires the version of azure-core which contains the necessary imports. You shouldn't be encountering this issue if you are installing normally through pip as the dependency resolution will ensure you have compatible versions of azure-core and azure-identity.

If you are seeing this issue outside of the context of Azure CLI or the Azure CLI ML extension, then please open another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Machine Learning needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests