Azure / azure-cli

Azure Command-Line Interface
MIT License
3.95k stars 2.93k forks source link

`az ml model list` fails with `unexpected keyword argument 'enable_broker_on_windows'` #28713

Open jkyl opened 4 months ago

jkyl commented 4 months ago

Describe the bug

The commands az ml model list and az ml model download fail with the following error:

TypeError: __init__() got an unexpected keyword argument 'enable_broker_on_windows'

Other commands may fail too, but these are the ones I encountered.

Related command

az ml model list az ml model download

Errors

The command failed with an unexpected error. Here is the traceback:
__init__() got an unexpected keyword argument 'enable_broker_on_windows'
Traceback (most recent call last):
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
    raise ex
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
    result = cmd_copy(params)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
    return self.handler(*args, **kwargs)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/command_operation.py", line 112, in handler
    client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
  File "/opt/az/extensions/ml/azext_mlv2/generated/_client_factory.py", line 20, in cf_ml_cl
    return get_mgmt_service_client(cli_ctx, AzureMachineLearningWorkspaces, **kwargs)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/client_factory.py", line 83, in get_mgmt_service_client
    client, _ = _get_mgmt_service_client(cli_ctx, client_type, subscription_id=subscription_id,
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/client_factory.py", line 236, in _get_mgmt_service_client
    credential, subscription_id, _ = profile.get_login_credentials(
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 334, in get_login_credentials
    credential = self._create_credential(account, client_id=client_id)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 592, in _create_credential
    return identity.get_user_credential(username_or_sp_id)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/auth/identity.py", line 232, in get_user_credential
    return UserCredential(self.client_id, username, **self._msal_public_app_kwargs)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/auth/msal_authentication.py", line 45, in __init__
    super().__init__(client_id, **kwargs)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/msal/application.py", line 1676, in __init__
    super(PublicClientApplication, self).__init__(
TypeError: __init__() got an unexpected keyword argument 'enable_broker_on_windows'

Issue script & Debug output

cli.knack.cli: Command arguments: ['ml', 'model', 'list', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7ff10ce9ba60>, <function OutputProducer.on_global_arguments at 0x7ff10cc690d0>, <function CLIQuery.on_global_arguments at 0x7ff10cc8a790>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'ml': ['azext_mlv2']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: Total (0)                 0.000         0         0
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
azext_mlv2.manual.vendored_curated_sdk.azure.ai.ml._azure_environments: Using the default cloud configuration: 'AzureCloud'.
azext_mlv2.manual.vendored_curated_sdk.azure.ai.ml._azure_environments: Using the default cloud configuration: 'AzureCloud'.
azext_mlv2.manual.vendored_curated_sdk.azure.ai.ml._azure_environments: Using the default cloud configuration: 'AzureCloud'.
cli.azure.cli.core: ml                        1.390        21       150  /opt/az/extensions/ml
cli.azure.cli.core: Total (1)                 1.390        21       150  
cli.azure.cli.core: Loaded 21 groups, 150 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : ml model list
cli.azure.cli.core: Command table: ml model list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7ff10b78c5e0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/azureuser/.azure/commands/2024-04-08.19-45-38.ml_model_list.8517.log'.
az_command_data_logger: command args: ml model list --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7ff10b71f3a0>]
cli.knack.commands: Configured default 'rg-gen-ai' for arg resource_group_name
cli.knack.commands: Configured default 'proton-ml-workspace' for arg workspace_name
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7ff10b73e3a0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7ff10b6d71f0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7ff10cc69160>, <function CLIQuery.handle_query_parameter at 0x7ff10cc8a820>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7ff10b6d7160>]
az_command_data_logger: extension name: ml
az_command_data_logger: extension version: 2.25.0
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=AzureMachineLearningWorkspaces
cli.azure.cli.core.auth.persistence: build_persistence: location='/home/azureuser/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /home/azureuser/.azure/msal_http_cache.bin
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
    raise ex
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
    result = cmd_copy(params)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
    return self.handler(*args, **kwargs)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/command_operation.py", line 112, in handler
    client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
  File "/opt/az/extensions/ml/azext_mlv2/generated/_client_factory.py", line 20, in cf_ml_cl
    return get_mgmt_service_client(cli_ctx, AzureMachineLearningWorkspaces, **kwargs)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/client_factory.py", line 83, in get_mgmt_service_client
    client, _ = _get_mgmt_service_client(cli_ctx, client_type, subscription_id=subscription_id,
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/commands/client_factory.py", line 236, in _get_mgmt_service_client
    credential, subscription_id, _ = profile.get_login_credentials(
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 334, in get_login_credentials
    credential = self._create_credential(account, client_id=client_id)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 592, in _create_credential
    return identity.get_user_credential(username_or_sp_id)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/auth/identity.py", line 232, in get_user_credential
    return UserCredential(self.client_id, username, **self._msal_public_app_kwargs)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/azure/cli/core/auth/msal_authentication.py", line 45, in __init__
    super().__init__(client_id, **kwargs)
  File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/msal/application.py", line 1676, in __init__
    super(PublicClientApplication, self).__init__(
TypeError: __init__() got an unexpected keyword argument 'enable_broker_on_windows'

Expected behavior

I expect az ml model list to print the list of models registered to my ML workspace. I expect az ml model download to download model artifacts for the specified model name and version.

Environment Summary

azure-cli                         2.59.0

core                              2.59.0
telemetry                          1.1.0

Extensions:
ml                                2.25.0

Dependencies:
msal                              1.22.0
azure-mgmt-resource             23.1.0b2

Python location '/anaconda/envs/azureml_py38/bin/python'
Extensions directory '/opt/az/extensions'

Python (Linux) 3.8.5 (default, Sep  4 2020, 07:30:14) 
[GCC 7.3.0]

Additional context

This is on a managed compute instance within an Azure ML workspace. I updated the Azure CLI and the ML extension to 2.59.0 and 2.25.0 respectively, and subsequently encountered the error.

yonzhan commented 4 months ago

Thank you for opening this issue, we will look into it.

azure-client-tools-bot-prd[bot] commented 4 months ago
Hi @jkyl Find similar issue https://github.com/Azure/azure-cli/issues/19640.
Issue title Unofficial Azure CLI deb packages are distributed by Linux repositories
Create time 2021-09-22
Comment number 9

Possible solution: The error message you are seeing is caused by an unexpected keyword argument 'enable_broker_on_windows'. This issue has been reported before and it is related to the installation of unofficial Azure CLI packages from Linux repositories. To solve this issue, you need to uninstall the unofficial Azure CLI packages first with sudo apt remove azure-cli --yes && sudo apt autoremove --yes and then install the latest official Azure CLI by following the official document: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt.


Please confirm if this resolves your issue.

jkyl commented 4 months ago

Please confirm if this resolves your issue.

No, uninstalling with sudo apt remove azure-cli --yes && sudo apt autoremove --yes and reinstalling with curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash as suggested does not resolve the issue.

jkyl commented 4 months ago

The conda environment / CLI installation where this issue occurs is one configured by Azure ML. It is the default environment enabled on new compute instances. The only modifications I made were (from within the conda env):

az upgrade
az extension add -n ml --allow-preview false
akshayrana30 commented 4 months ago

Updating msal fixed this error for me. Was previously on 1.22 and now on 1.28

pip install --upgrade msal

jkyl commented 4 months ago

Thanks @akshayrana30 that fixed it for me too.