AI Core SDK Create an Artifact

I am trying to create an artifact, but response says: Failed to create artifact. Status code: 404
It used to complain about the scenario id, but has not lately

artifact that I am trying to create:
{‘name’: ‘sound-data’, ‘kind’: ‘dataset’, ‘url’: ‘ai://sound/data’, ‘description’: ‘Cutting machine sound clips for defect detection’, ‘scenario_id’: ‘sound-scen’}

# Load AICoreServiceKey.json
AICoreServiceKeyFile = r”C:UsersI840539testjsonAICoreServiceKey.json”
uua_url, clientid, clientsecret, ai_api_url, token = get_ai_service_key(AICoreServiceKeyFile)

Code:

# Load training_workflow.yaml
training_workflow_file = ‘./files/training_workflow.yaml’
with open(training_workflow_file) as twf:
training_workflow = yaml.safe_load(twf)

print(‘training_workflow: n’, training_workflow)

# Load scenario id from train_workflow.yaml
scenario_id = training_workflow[‘metadata’][‘labels’][‘scenarios.ai.sap.com/id’]
print(‘scenario_id: ‘, scenario_id)

# Set the artifact configuration
artifact = {
“name”: “sound-data”, # Modifiable name
“kind”: “dataset”,
“url”: “ai://rds-ai-core-training-api/data”,
“description”: “Cutting machine sound clips for defect detection”,
“scenario_id”: scenario_id
}
print(‘artifact: n’, artifact)

# Prepare headers with authorization token
headers = {
‘Content-Type’: ‘application/json’,
‘Authorization’: f’Bearer {token}’
}

# Make the POST request to create the artifact
url = f”{ai_api_url}/v2/admin/artifacts”
response = requests.post(url=url, json=artifact, headers=headers)

# Check response status
if response.status_code == 200:
print(“Artifact created successfully.”)
else:
print(f”Failed to create artifact. Status code: {response.status_code}”)
print(f”Error message: {response.text}”)

 

Scroll to Top