CodexBloom - Programming Q&A Platform

OCI Data Science: how to to Sync Custom Model with OCI Artifact Repository Using Python SDK

👀 Views: 68 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-09
oci data-science python-sdk Python

Quick question that's been bugging me - I'm deploying to production and I'm testing a new approach and I'm currently working on deploying a custom machine learning model to the OCI Artifact Repository using the OCI Python SDK. I've followed the documentation closely, but I'm running into the following behavior when attempting to sync my model: ``` oci.exceptions.ServiceError: (404, 'Not Found', 'The specified resource was not found.') ``` The model was trained and exported correctly in the Data Science service, but when I attempt to push it to the Artifact Repository with the following code: ```python import oci # Configure the client config = oci.config.from_file() # Load config from default file artifact_client = oci.artifacts.ArtifactAdminClient(config) # Assuming the model is already created and I have its OCID model_ocid = 'ocid1.model.oc1..example' # Attempt to sync the model to the artifact repository try: response = artifact_client.create_artifact( create_artifact_details={ 'display_name': 'MyModelArtifact', 'description': 'My custom ML model artifact', 'model_id': model_ocid } ) print('Artifact created:', response) except oci.exceptions.ServiceError as e: print('Service behavior:', e) ``` I've verified that the model OCID is correct and that I have the necessary permissions. The client configuration seems to be fine as well, and I can list existing artifacts without issues. I've also checked that I'm using the latest version of the OCI Python SDK (2.49.0). Is there something I'm missing here? Could it be an scenario with the way I'm referencing the model or the artifact repository? Any help would be greatly appreciated! Any examples would be super helpful. The stack includes Python and several other technologies. What's the best practice here? I'm using Python 3.9 in this project. Any advice would be much appreciated. I'm using Python 3.9 in this project. I'd love to hear your thoughts on this.