unable to call Workspace class and save to variable ws, MSLearning Path module 08

MikeRichardson-3493 161 Reputation points
2021-01-26T19:59:00.17+00:00

I keep getting error, running commands in Jupyter notebook.

import azureml.core
from azureml.core import Workspace
ws = Workspace.from_config()
print('Ready to use Azure ML {} to work with {}'.format(azureml.core.VERSION, ws.name))

return RED text line number = 4 # Load the workspace from the saved config file
----> 5 ws = Workspace.from_config()
another line in RED = --> 292 resource_group=resource_group)

I seem to be unable to call the Workspace Class

I have tried these

  • print(Workspace.get('worksp_mike1')) fails with TypeError, _get_ambient_new() takes 1 positional argument but 2 were given
  • Workspace.get_details() ... return = TypeError: get_details() missing 1 required positional argument: 'self'
  • I have run this successfully = !pip install --upgrade azureml-sdk azureml-widgets
  • this also runs OK, print("SDK version:", azureml.core.VERSION) = SDK version: 1.21.0
  • I get the same ws error in previous modules....

this is where I am, module 08 in Jupyter, "Create a Pipeline"
https://microsoftlearning.github.io/mslearn-dp100/

60644-azure-workspace-error1.jpg

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,729 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. romungi-MSFT 43,696 Reputation points Microsoft Employee
    2021-01-27T07:50:26.537+00:00

    @MikeRichardson-3493 In this case it looks like the step wants to load a workspace from a config file. The config file will contain the subscription id, resource group and workspace name and when you run Workspace.from_config() the details are loaded from this file and used in the next cells. A configuration sample notebook is available here to setup and you can try to create this and load the workspace details and use them.

    from azureml.core import Workspace  
      
    subscription_id = "<my-subscription-id>"  
    resource_group = "<my-resource-group>"  
    workspace_name = "<my-workspace-name>"  
      
    ws = Workspace(subscription_id = subscription_id, resource_group = resource_group, workspace_name = workspace_name)  
    ws.write_config()  
    

  2. Hanna Moazam 1 Reputation point Microsoft Employee
    2021-02-14T07:58:27.507+00:00

    I'm not sure what the actual issue is, as I was also initially unable to run the code block which instantiates the Workspace object, and was getting the same error as the OP.

    This was when I cloned the repository into an Azure ML workspace I had previously created.

    To fix it, I created a new workspace (https://microsoftlearning.github.io/mslearn-dp100/instructions/01-create-a-workspace.html) and cloned the git repository for the learning path as specified, and then it somehow worked fine.

    I did not need to add the config file - from my understanding, you should only need to do that if you're using the SDK on your own machine, not if you're accessing Jupyter for your workspace via ML studio.

    0 comments No comments