Hi,
This is my code to create a data asset:
# This section of code authenticates to an Azure Key Vault Using the Client Secret Credentials
credentials = ClientSecretCredential(client_id=client_id, client_secret=client_secret,tenant_id=tenant_id)
ml_client = MLClient(
credentials, subs_id, res_group
)
# Verify that the handle works correctly.
ws = ml_client.workspaces.get(ws_name)
print(ws.location, ":", ws.resource_group)
my_path = "./data/default_of_credit_card_clients.csv"
# Check if the file exists
if os.path.exists(my_path):
print("The file exists.")
# set the version number of the data asset
v1 = "initial"
ds_name="credit-card"
my_data = Data(name=ds_name,version=v1,description="Credit card data",path=my_path,type=AssetTypes.URI_FILE,)
## create data asset if it doesn't already exist:
try:
data_asset = ml_client.data.get(name=ds_name, version=v1)
print(
f"Data asset already exists. Name: {my_data.name}, version: {my_data.version}"
)
except:
print("came here 2: " + ml_client.workspaces.get(ws_name).resource_group)
ml_client.data.create_or_update(my_data)
#print(f"Data asset created. Name: {my_data.name}, version: {my_data.version}")
But I get the following exception in create_or_update:\
Traceback (most recent call last):
File "/home/nishal/Desktop/code/RosenPrep/hello2.py", line 52, in <module>
data_asset = ml_client.data.get(name=ds_name, version=v1)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_telemetry/activity.py", line 292, in wrapper
return f(*args, **kwargs)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/operations/_data_operations.py", line 276, in get
data_version_resource = self._get(name, version)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/operations/_data_operations.py", line 205, in _get
else self._operation.get(
File "/home/nishal/.local/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 105, in wrapper_use_tracer
return func(*args, **kwargs)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_restclient/v2023_04_01_preview/operations/_data_versions_operations.py", line 467, in get
request = build_get_request(
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_restclient/v2023_04_01_preview/operations/_data_versions_operations.py", line 149, in build_get_request
"workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]{2,32}$'),
File "/home/nishal/.local/lib/python3.10/site-packages/msrest/serialization.py", line 652, in url
output = self.serialize_data(data, data_type, **kwargs)
File "/home/nishal/.local/lib/python3.10/site-packages/msrest/serialization.py", line 760, in serialize_data
raise ValueError("No value for given attribute")
ValueError: No value for given attribute
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/nishal/Desktop/code/RosenPrep/hello2.py", line 58, in <module>
ml_client.data.create_or_update(my_data)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_telemetry/activity.py", line 292, in wrapper
return f(*args, **kwargs)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/operations/_data_operations.py", line 425, in create_or_update
raise ex
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/operations/_data_operations.py", line 367, in create_or_update
data, _ = _check_and_upload_path(
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_artifacts/_artifact_utilities.py", line 506, in _check_and_upload_path
uploaded_artifact = _upload_to_datastore(
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_artifacts/_artifact_utilities.py", line 384, in _upload_to_datastore
artifact = upload_artifact(
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_artifacts/_artifact_utilities.py", line 240, in upload_artifact
datastore_info = get_datastore_info(datastore_operation, datastore_name)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_artifacts/_artifact_utilities.py", line 99, in get_datastore_info
datastore = operations.get(name) if name else operations.get_default()
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_telemetry/activity.py", line 292, in wrapper
return f(*args, **kwargs)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/operations/_datastore_operations.py", line 155, in get
datastore_resource = self._operation.get(
File "/home/nishal/.local/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 105, in wrapper_use_tracer
return func(*args, **kwargs)
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_restclient/v2024_07_01_preview/operations/_datastores_operations.py", line 496, in get
request = build_get_request(
File "/home/nishal/.local/lib/python3.10/site-packages/azure/ai/ml/_restclient/v2024_07_01_preview/operations/_datastores_operations.py", line 147, in build_get_request
"workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]{2,32}$'),
File "/home/nishal/.local/lib/python3.10/site-packages/msrest/serialization.py", line 652, in url
output = self.serialize_data(data, data_type, **kwargs)
File "/home/nishal/.local/lib/python3.10/site-packages/msrest/serialization.py", line 760, in serialize_data
raise ValueError("No value for given attribute")
ValueError: No value for given attribute
Please can anyone advise?