Skip to content

Commit 1861f25

Browse files
Updating fetch evaluation report flow
1 parent e9267de commit 1861f25

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

ads/aqua/evaluation/evaluation.py

+35-5
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@
8181
from ads.aqua.model.constants import ModelCustomMetadataFields
8282
from ads.common.auth import default_signer
8383
from ads.common.object_storage_details import ObjectStorageDetails
84-
from ads.common.utils import UNKNOWN, get_console_link, get_files, get_log_links
84+
from ads.common.utils import (
85+
UNKNOWN,
86+
get_console_link,
87+
get_files,
88+
get_log_links,
89+
read_file,
90+
)
8591
from ads.config import (
8692
AQUA_JOB_SUBNET_ID,
8793
COMPARTMENT_OCID,
@@ -1268,14 +1274,38 @@ def download_report(self, eval_id) -> AquaEvalReport:
12681274
logger.info(f"Fetching {EVALUATION_REPORT} from custom metadata.")
12691275
dsc_model.get_custom_metadata_artifact(EVALUATION_REPORT, temp_dir)
12701276
else:
1271-
logger.info(f"Fetching {EVALUATION_REPORT} from OSS bucket.")
1277+
logger.info(f"Fetching {EVALUATION_REPORT} from Model artifact.")
12721278
dsc_model.download_artifact(
12731279
temp_dir,
12741280
auth=self._auth,
12751281
)
1276-
content = self._read_from_artifact(
1277-
temp_dir, get_files(temp_dir), EVALUATION_REPORT
1278-
)
1282+
files_in_artifact = get_files(temp_dir)
1283+
if not len(files_in_artifact):
1284+
try:
1285+
evaluation_output_path = dsc_model.custom_metadata_list.get(
1286+
EvaluationCustomMetadata.EVALUATION_OUTPUT_PATH
1287+
).value
1288+
report_path = (
1289+
evaluation_output_path.rstrip("/")
1290+
+ "/"
1291+
+ eval_id
1292+
+ "/"
1293+
+ EVALUATION_REPORT
1294+
)
1295+
logger.info(
1296+
f"Fetching {EVALUATION_REPORT} from {report_path} for evaluation {eval_id}"
1297+
)
1298+
content = read_file(
1299+
file_path=report_path, auth=default_signer()
1300+
).encode()
1301+
except ValueError as err:
1302+
raise AquaValueError(
1303+
f"{EvaluationCustomMetadata.EVALUATION_OUTPUT_PATH} is missing from custom metadata for the model {eval_id}"
1304+
) from err
1305+
else:
1306+
content = self._read_from_artifact(
1307+
temp_dir, files_in_artifact, EVALUATION_REPORT
1308+
)
12791309
report = AquaEvalReport(
12801310
evaluation_id=eval_id, content=base64.b64encode(content).decode()
12811311
)

ads/aqua/modeldeployment/deployment.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
)
6161
from ads.aqua.modeldeployment.utils import MultiModelDeploymentConfigLoader
6262
from ads.common.object_storage_details import ObjectStorageDetails
63-
from ads.common.utils import UNKNOWN, UNKNOWN_LIST, get_log_links
63+
from ads.common.utils import UNKNOWN, get_log_links
6464
from ads.config import (
6565
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
6666
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
@@ -520,7 +520,7 @@ def _create(
520520
params = f"{params} {deployment_params}".strip()
521521
if params:
522522
env_var.update({"PARAMS": params})
523-
env_vars = container_spec.env_vars if container_spec else UNKNOWN_LIST
523+
env_vars = container_spec.env_vars if container_spec else []
524524
for env in env_vars:
525525
if isinstance(env, dict):
526526
env = {k: v for k, v in env.items() if v}
@@ -651,7 +651,7 @@ def _create_multi(
651651

652652
env_var.update({AQUA_MULTI_MODEL_CONFIG: json.dumps({"models": model_config})})
653653

654-
env_vars = container_spec.env_vars if container_spec else UNKNOWN_LIST
654+
env_vars = container_spec.env_vars if container_spec else []
655655
for env in env_vars:
656656
if isinstance(env, dict):
657657
env = {k: v for k, v in env.items() if v}

ads/aqua/modeldeployment/utils.py

+6
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,14 @@ def _fetch_deployment_config_from_metadata_and_oss(
200200
model_id, AquaModelMetadataKeys.DEPLOYMENT_CONFIGURATION
201201
)
202202
if config:
203+
logger.info(
204+
f"Fetched metadata key '{AquaModelMetadataKeys.DEPLOYMENT_CONFIGURATION}' from defined metadata for model '{model_id}'"
205+
)
203206
return config
204207
else:
208+
logger.info(
209+
f"Fetching '{AquaModelMetadataKeys.DEPLOYMENT_CONFIGURATION}' from object storage bucket for {model_id}'"
210+
)
205211
return self.deployment_app.get_config(
206212
model_id, AQUA_MODEL_DEPLOYMENT_CONFIG
207213
)

ads/common/utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
MAX_DISPLAY_VALUES = 10
6565

6666
UNKNOWN = ""
67-
UNKNOWN_LIST = []
6867

6968
# par link of the index json file.
7069
PAR_LINK = "https://objectstorage.us-ashburn-1.oraclecloud.com/p/WyjtfVIG0uda-P3-2FmAfwaLlXYQZbvPZmfX1qg0-sbkwEQO6jpwabGr2hMDBmBp/n/ociodscdev/b/service-conda-packs/o/service_pack/index.json"

0 commit comments

Comments
 (0)