Skip to content

Commit 6150d20

Browse files
Load base model config by default
1 parent b970eb5 commit 6150d20

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

ads/aqua/app.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,33 +296,43 @@ def get_config(self, model_id: str, config_file_name: str) -> Dict:
296296
raise AquaRuntimeError(f"Target model {oci_model.id} is not Aqua model.")
297297

298298
config = {}
299-
artifact_path = get_artifact_path(oci_model.custom_metadata_list)
299+
# if the current model has a service model tag, then
300+
if Tags.AQUA_SERVICE_MODEL_TAG in oci_model.freeform_tags:
301+
base_model_ocid = oci_model.freeform_tags[Tags.AQUA_SERVICE_MODEL_TAG]
302+
logger.info(
303+
f"Base model found for the model: {oci_model.id}. "
304+
f"Loading {config_file_name} for base model {base_model_ocid}."
305+
)
306+
base_model = self.ds_client.get_model(base_model_ocid).data
307+
artifact_path = get_artifact_path(base_model.custom_metadata_list)
308+
config_path = f"{os.path.dirname(artifact_path)}/config/"
309+
else:
310+
logger.info(f"Loading {config_file_name} for model {oci_model.id}...")
311+
artifact_path = get_artifact_path(oci_model.custom_metadata_list)
312+
config_path = f"{artifact_path.rstrip('/')}/config/"
313+
300314
if not artifact_path:
301315
logger.debug(
302316
f"Failed to get artifact path from custom metadata for the model: {model_id}"
303317
)
304318
return config
305319

306320
try:
307-
config_path = f"{os.path.dirname(artifact_path)}/config/"
308321
config = load_config(
309322
config_path,
310323
config_file_name=config_file_name,
311324
)
312325
except Exception:
313-
# todo: temp fix for issue related to config load for byom models, update logic to choose the right path
314-
try:
315-
config_path = f"{artifact_path.rstrip('/')}/config/"
316-
config = load_config(
317-
config_path,
318-
config_file_name=config_file_name,
319-
)
320-
except Exception:
321-
pass
326+
logger.debug(
327+
f"Error loading the {config_file_name} at path {config_path}.",
328+
exc_info=True,
329+
)
330+
pass
322331

323332
if not config:
324333
logger.error(
325-
f"{config_file_name} is not available for the model: {model_id}. Check if the custom metadata has the artifact path set."
334+
f"{config_file_name} is not available for the model: {model_id}. "
335+
f"Check if the custom metadata has the artifact path set."
326336
)
327337
return config
328338

0 commit comments

Comments
 (0)