<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic AI Core SDK Create an Artifact in Artificial Intelligence Forum</title>
    <link>https://community.sap.com/t5/artificial-intelligence-forum/ai-core-sdk-create-an-artifact/m-p/13601441#M297</link>
    <description>&lt;P&gt;I am trying to create an artifact, but response says:&amp;nbsp;Failed to create artifact. Status code: 404&lt;BR /&gt;It used to complain about the scenario id, but has not lately&lt;/P&gt;&lt;P&gt;artifact that I am trying to create:&lt;BR /&gt;{'name': 'sound-data', 'kind': 'dataset', 'url': 'ai://sound/data', 'description': 'Cutting machine sound clips for defect detection', 'scenario_id': 'sound-scen'}&lt;/P&gt;&lt;P&gt;# Load AICoreServiceKey.json&lt;BR /&gt;AICoreServiceKeyFile = r"C:\Users\I840539\testjson\AICoreServiceKey.json"&lt;BR /&gt;uua_url, clientid, clientsecret, ai_api_url, token = get_ai_service_key(AICoreServiceKeyFile)&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Load training_workflow.yaml&lt;BR /&gt;training_workflow_file = './files/training_workflow.yaml'&lt;BR /&gt;with open(training_workflow_file) as twf:&lt;BR /&gt;training_workflow = yaml.safe_load(twf)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;print('training_workflow: \n', training_workflow)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Load scenario id from train_workflow.yaml&lt;BR /&gt;scenario_id = training_workflow['metadata']['labels']['scenarios.ai.sap.com/id']&lt;BR /&gt;print('scenario_id: ', scenario_id)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Set the artifact configuration&lt;BR /&gt;artifact = {&lt;BR /&gt;"name": "sound-data", # Modifiable name&lt;BR /&gt;"kind": "dataset",&lt;BR /&gt;"url": "ai://rds-ai-core-training-api/data",&lt;BR /&gt;"description": "Cutting machine sound clips for defect detection",&lt;BR /&gt;"scenario_id": scenario_id&lt;BR /&gt;}&lt;BR /&gt;print('artifact: \n', artifact)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Prepare headers with authorization token&lt;BR /&gt;headers = {&lt;BR /&gt;'Content-Type': 'application/json',&lt;BR /&gt;'Authorization': f'Bearer {token}'&lt;BR /&gt;}&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Make the POST request to create the artifact&lt;BR /&gt;url = f"{ai_api_url}/v2/admin/artifacts"&lt;BR /&gt;response = requests.post(url=url, json=artifact, headers=headers)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Check response status&lt;BR /&gt;if response.status_code == 200:&lt;BR /&gt;print("Artifact created successfully.")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Failed to create artifact. Status code: {response.status_code}")&lt;BR /&gt;print(f"Error message: {response.text}")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Feb 2024 18:03:57 GMT</pubDate>
    <dc:creator>robert_schmidt01</dc:creator>
    <dc:date>2024-02-10T18:03:57Z</dc:date>
    <item>
      <title>AI Core SDK Create an Artifact</title>
      <link>https://community.sap.com/t5/artificial-intelligence-forum/ai-core-sdk-create-an-artifact/m-p/13601441#M297</link>
      <description>&lt;P&gt;I am trying to create an artifact, but response says:&amp;nbsp;Failed to create artifact. Status code: 404&lt;BR /&gt;It used to complain about the scenario id, but has not lately&lt;/P&gt;&lt;P&gt;artifact that I am trying to create:&lt;BR /&gt;{'name': 'sound-data', 'kind': 'dataset', 'url': 'ai://sound/data', 'description': 'Cutting machine sound clips for defect detection', 'scenario_id': 'sound-scen'}&lt;/P&gt;&lt;P&gt;# Load AICoreServiceKey.json&lt;BR /&gt;AICoreServiceKeyFile = r"C:\Users\I840539\testjson\AICoreServiceKey.json"&lt;BR /&gt;uua_url, clientid, clientsecret, ai_api_url, token = get_ai_service_key(AICoreServiceKeyFile)&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Load training_workflow.yaml&lt;BR /&gt;training_workflow_file = './files/training_workflow.yaml'&lt;BR /&gt;with open(training_workflow_file) as twf:&lt;BR /&gt;training_workflow = yaml.safe_load(twf)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;print('training_workflow: \n', training_workflow)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Load scenario id from train_workflow.yaml&lt;BR /&gt;scenario_id = training_workflow['metadata']['labels']['scenarios.ai.sap.com/id']&lt;BR /&gt;print('scenario_id: ', scenario_id)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Set the artifact configuration&lt;BR /&gt;artifact = {&lt;BR /&gt;"name": "sound-data", # Modifiable name&lt;BR /&gt;"kind": "dataset",&lt;BR /&gt;"url": "ai://rds-ai-core-training-api/data",&lt;BR /&gt;"description": "Cutting machine sound clips for defect detection",&lt;BR /&gt;"scenario_id": scenario_id&lt;BR /&gt;}&lt;BR /&gt;print('artifact: \n', artifact)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Prepare headers with authorization token&lt;BR /&gt;headers = {&lt;BR /&gt;'Content-Type': 'application/json',&lt;BR /&gt;'Authorization': f'Bearer {token}'&lt;BR /&gt;}&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Make the POST request to create the artifact&lt;BR /&gt;url = f"{ai_api_url}/v2/admin/artifacts"&lt;BR /&gt;response = requests.post(url=url, json=artifact, headers=headers)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;# Check response status&lt;BR /&gt;if response.status_code == 200:&lt;BR /&gt;print("Artifact created successfully.")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Failed to create artifact. Status code: {response.status_code}")&lt;BR /&gt;print(f"Error message: {response.text}")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Feb 2024 18:03:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/artificial-intelligence-forum/ai-core-sdk-create-an-artifact/m-p/13601441#M297</guid>
      <dc:creator>robert_schmidt01</dc:creator>
      <dc:date>2024-02-10T18:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: AI Core SDK Create an Artifact</title>
      <link>https://community.sap.com/t5/artificial-intelligence-forum/ai-core-sdk-create-an-artifact/m-p/13618957#M300</link>
      <description>&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;404 Error stands for the server cannot find the requested resource and as per what I can see in your code looks like the URL you are using to create an artifact is wrong instead of&amp;nbsp;&lt;SPAN&gt;{ai_api_url}/v2/admin/artifacts it should be&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN&gt;{ai_api_url}/v2/lm/artifacts&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 09:39:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/artificial-intelligence-forum/ai-core-sdk-create-an-artifact/m-p/13618957#M300</guid>
      <dc:creator>anurag_batra</dc:creator>
      <dc:date>2024-02-26T09:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: AI Core SDK Create an Artifact</title>
      <link>https://community.sap.com/t5/artificial-intelligence-forum/ai-core-sdk-create-an-artifact/m-p/13619475#M303</link>
      <description>&lt;P&gt;Hi, I tried AI Core Client and AI Client, and also AI Client with tht path. The error was from my workflow having an error. I found the error when I checked the status of one of the components, maybe application. In the status json it mentioned that workflow failed, which means the scenario didn't get created. I marked your reply correct, because if that was my issue it would be correct. Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 14:11:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/artificial-intelligence-forum/ai-core-sdk-create-an-artifact/m-p/13619475#M303</guid>
      <dc:creator>robert_schmidt01</dc:creator>
      <dc:date>2024-02-26T14:11:58Z</dc:date>
    </item>
  </channel>
</rss>

