1

I am trying to register a dataset in Azure Machine Learning using the Python SDK. Here is the code that I have used:

from azureml.core import Dataset

testdata = Dataset.Tabular.from_delimited_files(default_store.path('test/prep.csv'))
testdata

The dataset is successfully created and I can see its details as below:

{
  "source": [
    "('workspaceblobstore', 'test/prep.csv')"
  ],
  "definition": [
    "GetDatastoreFiles",
    "ParseDelimited",
    "DropColumns",
    "SetColumnTypes"
  ]
}

However, when I try to register the dataset using the register method


test_data_ds = testdata.register(workspace=ws,
                 name='testdata',
                 description='test data',
                 create_new_version=True)

I encounter the following error: Failed to extract subscription information, Exception=AttributeError; 'Logger' object has no attribute 'activity_info'

I have made sure that my Azure ML SDK is up to date and my Azure subscription is active. I also have the necessary permissions to access the resources.

SDXT
  • 11
  • 1

1 Answers1

0

I followed the steps below to create and register a dataset in Azure ML studio with Python SDK and it was successful:-

My Python code to Create and Register a Dataset:-

Code reference:- MS Document


# -----------------------------------------------------
# Import required azureml classes 
# -----------------------------------------------------
from azureml.core import Workspace, Datastore, Dataset


# -----------------------------------------------------
# Access the workspace from the config.json 
# -----------------------------------------------------
ws = Workspace.from_config('./config.json')


# -----------------------------------------------------
# Access datastore by its name
# -----------------------------------------------------
az_store = Datastore.get(ws, "silicondatastore")


# -----------------------------------------------------
# Create and register the dataset
# -----------------------------------------------------

# Create the path of the csv file
csv_path = [(az_store, "Silicon Loan Data/Loan+Approval+Prediction.csv")]

# Create the dataset
loan_dataset = Dataset.Tabular.from_delimited_files(path=csv_path)

# Register the dataset
loan_dataset = loan_dataset.register(workspace=ws,
                                     name="Loan Applications Using SDK",
                                     create_new_version=True)

Output:-

enter image description here

Data-Asset got created successfully:-

enter image description here

Dataset:-

My config.json file is in the same Directory as my Python code, Refer below:-

enter image description here

I downloaded config.json from below:-

enter image description here

I logged into my Azure account with the commands below:-

Command reference:- MS Document2

az login
az account set --subscription <subscription-name>

I added Storage blob data contributor role to the user with whom I logged in with Azure CLI.

enter image description here

ML Datastore:-

enter image description here

enter image description here

Along with this make sure you install azureml-dataset-runtime by referring this Link.

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11