Azure / MachineLearningNotebooks

Python notebooks with ML and deep learning examples with Azure Machine Learning Python SDK | Microsoft
https://docs.microsoft.com/azure/machine-learning/service/
MIT License
4.07k stars 2.52k forks source link

AttributeError: 'InteractiveLoginAuthentication' object has no attribute 'get_token' #1366

Open Carterbouley opened 3 years ago

Carterbouley commented 3 years ago

Following this notebook exactly. The only code change being changing create_or_update() to begin_create_or_update() as advised by a previous issue.

from azure.mgmt.network import NetworkManagementClient

# Virtual network name
vnet_name ="rl_pong_vnet"

# Default subnet
subnet_name ="default"

# The Azure subscription you are using
subscription_id=ws.subscription_id

# The resource group for the reinforcement learning cluster
resource_group=ws.resource_group

# Azure region of the resource group
location=ws.location

network_client = NetworkManagementClient(ws._auth_object, subscription_id)

async_vnet_creation = network_client.virtual_networks.begin_create_or_update(
    resource_group,
    vnet_name,
    {
        'location': location,
        'address_space': {
            'address_prefixes': ['10.0.0.0/16']
        }
    }
)

async_vnet_creation.wait()
print("Virtual network created successfully: ", async_vnet_creation.result())

I get result:

AttributeError                            Traceback (most recent call last)
<ipython-input-6-55fec34bc882> in <module>
     24         'location': location,
     25         'address_space': {
---> 26             'address_prefixes': ['10.0.0.0/16']
     27         }
     28     }

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/mgmt/network/v2020_08_01/operations/_virtual_networks_operations.py in begin_create_or_update(self, resource_group_name, virtual_network_name, parameters, **kwargs)
    319                 parameters=parameters,
    320                 cls=lambda x,y,z: x,
--> 321                 **kwargs
    322             )
    323 

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/mgmt/network/v2020_08_01/operations/_virtual_networks_operations.py in _create_or_update_initial(self, resource_group_name, virtual_network_name, parameters, **kwargs)
    261         body_content_kwargs['content'] = body_content
    262         request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
--> 263         pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
    264         response = pipeline_response.http_response
    265 

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/_base.py in run(self, request, **kwargs)
    209             else _TransportRunner(self._transport)
    210         )
--> 211         return first_node.send(pipeline_request)  # type: ignore

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/_base.py in send(self, request)
     69         _await_result(self._policy.on_request, request)
     70         try:
---> 71             response = self.next.send(request)
     72         except Exception:  # pylint: disable=broad-except
     73             if not _await_result(self._policy.on_exception, request):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/mgmt/core/policies/_base.py in send(self, request)
     45         # type: (PipelineRequest[HTTPRequestType], Any) -> PipelineResponse[HTTPRequestType, HTTPResponseType]
     46         http_request = request.http_request
---> 47         response = self.next.send(request)
     48         if response.http_response.status_code == 409:
     49             rp_name = self._check_rp_not_registered_err(response)

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/_base.py in send(self, request)
     69         _await_result(self._policy.on_request, request)
     70         try:
---> 71             response = self.next.send(request)
     72         except Exception:  # pylint: disable=broad-except
     73             if not _await_result(self._policy.on_exception, request):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/_base.py in send(self, request)
     69         _await_result(self._policy.on_request, request)
     70         try:
---> 71             response = self.next.send(request)
     72         except Exception:  # pylint: disable=broad-except
     73             if not _await_result(self._policy.on_exception, request):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/_base.py in send(self, request)
     69         _await_result(self._policy.on_request, request)
     70         try:
---> 71             response = self.next.send(request)
     72         except Exception:  # pylint: disable=broad-except
     73             if not _await_result(self._policy.on_exception, request):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/_base.py in send(self, request)
     69         _await_result(self._policy.on_request, request)
     70         try:
---> 71             response = self.next.send(request)
     72         except Exception:  # pylint: disable=broad-except
     73             if not _await_result(self._policy.on_exception, request):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/policies/_redirect.py in send(self, request)
    155         redirect_settings = self.configure_redirects(request.context.options)
    156         while retryable:
--> 157             response = self.next.send(request)
    158             redirect_location = self.get_redirect_location(response)
    159             if redirect_location and redirect_settings['allow']:

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/policies/_retry.py in send(self, request)
    434                 start_time = time.time()
    435                 self._configure_timeout(request, absolute_timeout, is_response_error)
--> 436                 response = self.next.send(request)
    437                 if self.is_retry(retry_settings, response):
    438                     retry_active = self.increment(retry_settings, response=response)

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/_base.py in send(self, request)
     67         :rtype: ~azure.core.pipeline.PipelineResponse
     68         """
---> 69         _await_result(self._policy.on_request, request)
     70         try:
     71             response = self.next.send(request)

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/_tools.py in await_result(func, *args, **kwargs)
     27 def await_result(func, *args, **kwargs):
     28     """If func returns an awaitable, raise that this runner can't handle it."""
---> 29     result = func(*args, **kwargs)
     30     if hasattr(result, "__await__"):
     31         raise TypeError(

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azure/core/pipeline/policies/_authentication.py in on_request(self, request)
     91 
     92         if self._token is None or self._need_new_token:
---> 93             self._token = self._credential.get_token(*self._scopes)
     94         self._update_headers(request.http_request.headers, self._token.token)
     95 

AttributeError: 'InteractiveLoginAuthentication' object has no attribute 'get_token'
lostmygithubaccount commented 3 years ago

@Carterbouley which notebook? cannot tell from the issue

lostmygithubaccount commented 3 years ago

looks like the RL pong notebook?

Carterbouley commented 3 years ago

looks like the RL pong notebook?

@lostmygithubaccount Yes it is the pong notebook

Carterbouley commented 3 years ago

Is there any chance this could get looked into? I am unable to create a virtual network using the code you have provided

lostmygithubaccount commented 3 years ago

the Azure ML RL team is investigating

Carterbouley commented 3 years ago

This also occurs under the minecraft notebook, under heading 'Set up Network Security Group on Virtual Network'

lostmygithubaccount commented 3 years ago

@Carterbouley the minecraft notebook is not being updated/fixed, and has been removed from the internal repository which is the source of this GitHub repository - meaning it will be removed from this repository at some point in the near future as well

singankit commented 3 years ago

@Carterbouley what version of azure-mgmt-network are you using ? You can run pip list to check it. Can you please try installing version 12.0.0 by running the following command:

pip install --upgrade azure-mgmt-network==12.0.0 and change back to using create_or_update

Carterbouley commented 3 years ago

@Carterbouley the minecraft notebook is not being updated/fixed, and has been removed from the internal repository which is the source of this GitHub repository - meaning it will be removed from this repository at some point in the near future as well

I have actually found it quite helpful as its the most extensive project in the tutorials, just so you are aware. Those full end to end projects are very helpful

Carterbouley commented 3 years ago

@Carterbouley what version of azure-mgmt-network are you using ? You can run pip list to check it. Can you please try installing version 12.0.0 by running the following command:

pip install --upgrade azure-mgmt-network==12.0.0 and change back to using create_or_update

I am using azure-mgmt-network 17.0.0, which I believes comes included in the azure environment on the notebooks?

singankit commented 2 years ago

@Carterbouley Using latest azureml-core package should solve this issue. pip install -U azureml-core should help to upgrade to latest version.