<?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 Unable to Register Models After Uploading Artifacts to DBFS in Databricks in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/unable-to-register-models-after-uploading-artifacts-to-dbfs-in/m-p/107113#M9637</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm currently working on a project where I'm migrating models and artifacts from a source Databricks workspace to a target one. I've written a script to upload the model artifacts from my local system to DBFS in the target workspace (using the /api/2.0/dbfs/put API). The upload part works perfectly, and the files are successfully transferred to DBFS.&lt;/P&gt;&lt;P&gt;However, I'm struggling to register the models in the target workspace after the upload. I’ve tried using the mlflow.register_model method, but it doesn’t seem to work.&lt;/P&gt;&lt;P&gt;Here’s a summary of what I’ve done so far:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I’ve uploaded the model artifacts using the code below.&lt;/LI&gt;&lt;LI&gt;After the upload, I tried registering the models in the target workspace using mlflow.register_model or mlflow.models.Model.register, but I don’t see the model appearing in the Model Registry.&lt;P&gt;Here’s my upload script for reference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;python&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;import os &lt;SPAN class=""&gt;import requests &lt;SPAN class=""&gt;# Databricks host and token (directly in the script) databricks_host = &lt;SPAN class=""&gt;"&amp;lt;databricks_host&amp;gt;" token = &lt;SPAN class=""&gt;"&amp;lt;token&amp;gt;" &lt;SPAN class=""&gt;# Define the local directory and DBFS destination path local_directory = &lt;SPAN class=""&gt;r"C:\Users\offerings_admin\Downloads\artifacts" dbfs_directory = &lt;SPAN class=""&gt;"dbfs:/artifacts2/" &lt;SPAN class=""&gt;# Function to upload a file to DBFS using REST API &lt;SPAN class=""&gt;def &lt;SPAN class=""&gt;upload_to_dbfs(&lt;SPAN class=""&gt;local_path, dbfs_path): &lt;SPAN class=""&gt;with &lt;SPAN class=""&gt;open(local_path, &lt;SPAN class=""&gt;"rb") &lt;SPAN class=""&gt;as f: file_data = f.read() url = &lt;SPAN class=""&gt;f"&lt;SPAN class=""&gt;{databricks_host}/api/2.0/dbfs/put" headers = { &lt;SPAN class=""&gt;"Authorization": &lt;SPAN class=""&gt;f"Bearer &lt;SPAN class=""&gt;{token}" } data = { &lt;SPAN class=""&gt;"path": dbfs_path, &lt;SPAN class=""&gt;"overwrite": &lt;SPAN class=""&gt;"true" } &lt;SPAN class=""&gt;# Sending the POST request to upload the file response = requests.post(url, headers=headers, data=data, files={&lt;SPAN class=""&gt;"file": file_data}) &lt;SPAN class=""&gt;if response.status_code == &lt;SPAN class=""&gt;200: &lt;SPAN class=""&gt;print(&lt;SPAN class=""&gt;f"File &lt;SPAN class=""&gt;{local_path} uploaded successfully!") &lt;SPAN class=""&gt;else: &lt;SPAN class=""&gt;print(&lt;SPAN class=""&gt;f"Failed to upload file &lt;SPAN class=""&gt;{local_path}: &lt;SPAN class=""&gt;{response.text}") &lt;SPAN class=""&gt;# Iterate through the artifacts directory and upload files while preserving the folder structure &lt;SPAN class=""&gt;for root, dirs, files &lt;SPAN class=""&gt;in os.walk(local_directory): &lt;SPAN class=""&gt;for file &lt;SPAN class=""&gt;in files: local_file_path = os.path.join(root, file) relative_path = os.path.relpath(local_file_path, local_directory) dbfs_file_path = os.path.join(dbfs_directory, relative_path).replace(&lt;SPAN class=""&gt;"\\", &lt;SPAN class=""&gt;"/") upload_to_dbfs(local_file_path, dbfs_file_path)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Could anyone suggest why the models aren't being registered, or what I might be missing in the process?&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Mon, 27 Jan 2025 07:07:00 GMT</pubDate>
    <dc:creator>Sudheer2</dc:creator>
    <dc:date>2025-01-27T07:07:00Z</dc:date>
    <item>
      <title>Unable to Register Models After Uploading Artifacts to DBFS in Databricks</title>
      <link>https://community.databricks.com/t5/get-started-discussions/unable-to-register-models-after-uploading-artifacts-to-dbfs-in/m-p/107113#M9637</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm currently working on a project where I'm migrating models and artifacts from a source Databricks workspace to a target one. I've written a script to upload the model artifacts from my local system to DBFS in the target workspace (using the /api/2.0/dbfs/put API). The upload part works perfectly, and the files are successfully transferred to DBFS.&lt;/P&gt;&lt;P&gt;However, I'm struggling to register the models in the target workspace after the upload. I’ve tried using the mlflow.register_model method, but it doesn’t seem to work.&lt;/P&gt;&lt;P&gt;Here’s a summary of what I’ve done so far:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I’ve uploaded the model artifacts using the code below.&lt;/LI&gt;&lt;LI&gt;After the upload, I tried registering the models in the target workspace using mlflow.register_model or mlflow.models.Model.register, but I don’t see the model appearing in the Model Registry.&lt;P&gt;Here’s my upload script for reference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;python&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;import os &lt;SPAN class=""&gt;import requests &lt;SPAN class=""&gt;# Databricks host and token (directly in the script) databricks_host = &lt;SPAN class=""&gt;"&amp;lt;databricks_host&amp;gt;" token = &lt;SPAN class=""&gt;"&amp;lt;token&amp;gt;" &lt;SPAN class=""&gt;# Define the local directory and DBFS destination path local_directory = &lt;SPAN class=""&gt;r"C:\Users\offerings_admin\Downloads\artifacts" dbfs_directory = &lt;SPAN class=""&gt;"dbfs:/artifacts2/" &lt;SPAN class=""&gt;# Function to upload a file to DBFS using REST API &lt;SPAN class=""&gt;def &lt;SPAN class=""&gt;upload_to_dbfs(&lt;SPAN class=""&gt;local_path, dbfs_path): &lt;SPAN class=""&gt;with &lt;SPAN class=""&gt;open(local_path, &lt;SPAN class=""&gt;"rb") &lt;SPAN class=""&gt;as f: file_data = f.read() url = &lt;SPAN class=""&gt;f"&lt;SPAN class=""&gt;{databricks_host}/api/2.0/dbfs/put" headers = { &lt;SPAN class=""&gt;"Authorization": &lt;SPAN class=""&gt;f"Bearer &lt;SPAN class=""&gt;{token}" } data = { &lt;SPAN class=""&gt;"path": dbfs_path, &lt;SPAN class=""&gt;"overwrite": &lt;SPAN class=""&gt;"true" } &lt;SPAN class=""&gt;# Sending the POST request to upload the file response = requests.post(url, headers=headers, data=data, files={&lt;SPAN class=""&gt;"file": file_data}) &lt;SPAN class=""&gt;if response.status_code == &lt;SPAN class=""&gt;200: &lt;SPAN class=""&gt;print(&lt;SPAN class=""&gt;f"File &lt;SPAN class=""&gt;{local_path} uploaded successfully!") &lt;SPAN class=""&gt;else: &lt;SPAN class=""&gt;print(&lt;SPAN class=""&gt;f"Failed to upload file &lt;SPAN class=""&gt;{local_path}: &lt;SPAN class=""&gt;{response.text}") &lt;SPAN class=""&gt;# Iterate through the artifacts directory and upload files while preserving the folder structure &lt;SPAN class=""&gt;for root, dirs, files &lt;SPAN class=""&gt;in os.walk(local_directory): &lt;SPAN class=""&gt;for file &lt;SPAN class=""&gt;in files: local_file_path = os.path.join(root, file) relative_path = os.path.relpath(local_file_path, local_directory) dbfs_file_path = os.path.join(dbfs_directory, relative_path).replace(&lt;SPAN class=""&gt;"\\", &lt;SPAN class=""&gt;"/") upload_to_dbfs(local_file_path, dbfs_file_path)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Could anyone suggest why the models aren't being registered, or what I might be missing in the process?&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Mon, 27 Jan 2025 07:07:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/unable-to-register-models-after-uploading-artifacts-to-dbfs-in/m-p/107113#M9637</guid>
      <dc:creator>Sudheer2</dc:creator>
      <dc:date>2025-01-27T07:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Register Models After Uploading Artifacts to DBFS in Databricks</title>
      <link>https://community.databricks.com/t5/get-started-discussions/unable-to-register-models-after-uploading-artifacts-to-dbfs-in/m-p/107258#M9638</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/104469"&gt;@Sudheer2&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Does it give you any error while trying to register the model?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 15:11:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/unable-to-register-models-after-uploading-artifacts-to-dbfs-in/m-p/107258#M9638</guid>
      <dc:creator>Alberto_Umana</dc:creator>
      <dc:date>2025-01-27T15:11:59Z</dc:date>
    </item>
  </channel>
</rss>

