@@ -642,9 +642,25 @@ def _log_orchestration_message(self, str: str) -> None:
642642
643643class LocalModelDeploymentBackend (LocalBackend ):
644644 def __init__ (self , config : Dict ) -> None :
645+ """
646+ Initialize a LocalModelDeploymentBackend object with given config.
647+
648+ Parameters
649+ ----------
650+ config: dict
651+ dictionary of configurations
652+ """
645653 super ().__init__ (config )
646654
647655 def predict (self ) -> None :
656+ """
657+ Conducts local verify.
658+
659+ Returns
660+ -------
661+ None
662+ Nothing.
663+ """
648664 artifact_directory = self .config ["execution" ].get ("artifact_directory" )
649665 ocid = self .config ["execution" ].get ("ocid" )
650666 data = self .config ["execution" ].get ("payload" )
@@ -658,8 +674,8 @@ def predict(self) -> None:
658674 _download_model (ocid = ocid , artifact_directory = artifact_directory , region = region , bucket_uri = bucket_uri , timeout = timeout )
659675
660676 if ocid :
661- conda_slug , conda_path = self ._get_conda_info_from_catalog (ocid )
662- elif artifact_directory :
677+ conda_slug , conda_path = self ._get_conda_info_from_custom_metadata (ocid )
678+ if artifact_directory or not conda_path :
663679 if not os .path .exists (artifact_directory ) or len (os .listdir (artifact_directory )) == 0 :
664680 raise ValueError (f"`artifact_directory` { artifact_directory } does not exist or is empty." )
665681 conda_slug , conda_path = self ._get_conda_info_from_runtime (artifact_dir = artifact_directory )
@@ -699,14 +715,33 @@ def predict(self) -> None:
699715 f"Run with the --debug argument to view container logs."
700716 )
701717
702- def _get_conda_info_from_catalog (self , ocid ):
718+ def _get_conda_info_from_custom_metadata (self , ocid ):
719+ """
720+ Get conda env info from custom metadata from model catalog.
721+
722+ Returns
723+ -------
724+ (str, str)
725+ conda slug and conda path.
726+ """
703727 response = self .client .get_model (ocid )
704728 custom_metadata = ModelCustomMetadata ._from_oci_metadata (response .data .custom_metadata_list )
705- conda_path = custom_metadata ['CondaEnvironmentPath' ].value
706- conda_slug = custom_metadata ['SlugName' ].value
729+ conda_slug , conda_path = None , None
730+ if "CondaEnvironmentPath" in custom_metadata :
731+ conda_path = custom_metadata ['CondaEnvironmentPath' ].value
732+ if "SlugName" in custom_metadata :
733+ conda_slug = custom_metadata ['SlugName' ].value
707734 return conda_slug , conda_path
708735
709736 def _get_conda_info_from_runtime (self , artifact_dir ):
737+ """
738+ Get conda env info from runtime yaml file.
739+
740+ Returns
741+ -------
742+ (str, str)
743+ conda slug and conda path.
744+ """
710745 runtime_yaml_file = os .path .join (artifact_dir , "runtime.yaml" )
711746 runtime_info = RuntimeInfo .from_yaml (uri = runtime_yaml_file )
712747 conda_slug = runtime_info .model_deployment .inference_conda_env .inference_env_slug
0 commit comments