Skip to content

Commit 6c7a72f

Browse files
support input tags for evaluation
1 parent 13053b1 commit 6c7a72f

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

ads/aqua/evaluation/entities.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ class CreateAquaEvaluationDetails(Serializable):
6464
The metrics for the evaluation.
6565
force_overwrite: (bool, optional). Defaults to `False`.
6666
Whether to force overwrite the existing file in object storage.
67+
freeform_tags: (dict, optional)
68+
Freeform tags for the evaluation model
69+
defined_tags: (dict, optional)
70+
Defined tags for the evaluation model
6771
"""
6872

6973
evaluation_source_id: str
@@ -85,6 +89,8 @@ class CreateAquaEvaluationDetails(Serializable):
8589
log_id: Optional[str] = None
8690
metrics: Optional[List[Dict[str, Any]]] = None
8791
force_overwrite: Optional[bool] = False
92+
freeform_tags: Optional[dict] = None
93+
defined_tags: Optional[dict] = None
8894

8995
class Config:
9096
extra = "ignore"

ads/aqua/evaluation/evaluation.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ def create(
297297
evaluation_mvs_freeform_tags = {
298298
Tags.AQUA_EVALUATION: Tags.AQUA_EVALUATION,
299299
}
300+
evaluation_mvs_freeform_tags = {
301+
**evaluation_mvs_freeform_tags,
302+
**(create_aqua_evaluation_details.freeform_tags or {}),
303+
}
300304

301305
model_version_set = (
302306
ModelVersionSet()
@@ -307,6 +311,9 @@ def create(
307311
create_aqua_evaluation_details.experiment_description
308312
)
309313
.with_freeform_tags(**evaluation_mvs_freeform_tags)
314+
.with_defined_tags(
315+
**(create_aqua_evaluation_details.defined_tags or {})
316+
)
310317
# TODO: decide what parameters will be needed
311318
.create(**kwargs)
312319
)
@@ -369,6 +376,10 @@ def create(
369376
Tags.AQUA_EVALUATION: Tags.AQUA_EVALUATION,
370377
Tags.AQUA_EVALUATION_MODEL_ID: evaluation_model.id,
371378
}
379+
evaluation_job_freeform_tags = {
380+
**evaluation_job_freeform_tags,
381+
**(create_aqua_evaluation_details.freeform_tags or {}),
382+
}
372383

373384
evaluation_job = Job(name=evaluation_model.display_name).with_infrastructure(
374385
DataScienceJob()
@@ -379,6 +390,7 @@ def create(
379390
.with_shape_name(create_aqua_evaluation_details.shape_name)
380391
.with_block_storage_size(create_aqua_evaluation_details.block_storage_size)
381392
.with_freeform_tag(**evaluation_job_freeform_tags)
393+
.with_defined_tag(**(create_aqua_evaluation_details.defined_tags or {}))
382394
)
383395
if (
384396
create_aqua_evaluation_details.memory_in_gbs
@@ -425,6 +437,7 @@ def create(
425437
evaluation_job_run = evaluation_job.run(
426438
name=evaluation_model.display_name,
427439
freeform_tags=evaluation_job_freeform_tags,
440+
defined_tags=(create_aqua_evaluation_details.defined_tags or {}),
428441
wait=False,
429442
)
430443
logger.debug(
@@ -444,13 +457,23 @@ def create(
444457
for metadata in evaluation_model_custom_metadata.to_dict()["data"]
445458
]
446459

460+
evaluation_model_freeform_tags = {
461+
Tags.AQUA_EVALUATION: Tags.AQUA_EVALUATION,
462+
}
463+
evaluation_model_freeform_tags = {
464+
**evaluation_model_freeform_tags,
465+
**(create_aqua_evaluation_details.freeform_tags or {}),
466+
}
467+
evaluation_model_defined_tags = (
468+
create_aqua_evaluation_details.defined_tags or {}
469+
)
470+
447471
self.ds_client.update_model(
448472
model_id=evaluation_model.id,
449473
update_model_details=UpdateModelDetails(
450474
custom_metadata_list=updated_custom_metadata_list,
451-
freeform_tags={
452-
Tags.AQUA_EVALUATION: Tags.AQUA_EVALUATION,
453-
},
475+
freeform_tags=evaluation_model_freeform_tags,
476+
defined_tags=evaluation_model_defined_tags,
454477
),
455478
)
456479

@@ -520,10 +543,14 @@ def create(
520543
),
521544
),
522545
tags={
523-
"aqua_evaluation": Tags.AQUA_EVALUATION,
524-
"evaluation_job_id": evaluation_job.id,
525-
"evaluation_source": create_aqua_evaluation_details.evaluation_source_id,
526-
"evaluation_experiment_id": experiment_model_version_set_id,
546+
**{
547+
"aqua_evaluation": Tags.AQUA_EVALUATION,
548+
"evaluation_job_id": evaluation_job.id,
549+
"evaluation_source": create_aqua_evaluation_details.evaluation_source_id,
550+
"evaluation_experiment_id": experiment_model_version_set_id,
551+
},
552+
**evaluation_model_freeform_tags,
553+
**evaluation_model_defined_tags,
527554
},
528555
parameters=AquaEvalParams(),
529556
)

tests/unitary/with_extras/aqua/test_evaluation.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ def test_create_evaluation(
475475
self.app.ds_client.update_model = MagicMock()
476476
self.app.ds_client.update_model_provenance = MagicMock()
477477

478+
eval_model_freeform_tags = {"ftag1": "fvalue1", "ftag2": "fvalue2"}
479+
eval_model_defined_tags = {"dtag1": "dvalue1", "dtag2": "dvalue2"}
480+
478481
create_aqua_evaluation_details = dict(
479482
evaluation_source_id="ocid1.datasciencemodel.oc1.iad.<OCID>",
480483
evaluation_name="test_evaluation_name",
@@ -486,6 +489,8 @@ def test_create_evaluation(
486489
experiment_name="test_experiment_name",
487490
memory_in_gbs=1,
488491
ocpus=1,
492+
freeform_tags=eval_model_freeform_tags,
493+
defined_tags=eval_model_defined_tags,
489494
)
490495
aqua_evaluation_summary = self.app.create(**create_aqua_evaluation_details)
491496

@@ -516,10 +521,14 @@ def test_create_evaluation(
516521
"url": f"https://cloud.oracle.com/data-science/models/ocid1.datasciencemodel.oc1.iad.<OCID>?region={self.app.region}",
517522
},
518523
"tags": {
519-
"aqua_evaluation": "aqua_evaluation",
520-
"evaluation_experiment_id": f"{experiment.id}",
521-
"evaluation_job_id": f"{mock_job_id.return_value}",
522-
"evaluation_source": "ocid1.datasciencemodel.oc1.iad.<OCID>",
524+
**{
525+
"aqua_evaluation": "aqua_evaluation",
526+
"evaluation_experiment_id": f"{experiment.id}",
527+
"evaluation_job_id": f"{mock_job_id.return_value}",
528+
"evaluation_source": "ocid1.datasciencemodel.oc1.iad.<OCID>",
529+
},
530+
**eval_model_freeform_tags,
531+
**eval_model_defined_tags,
523532
},
524533
"time_created": f"{oci_dsc_model.time_created}",
525534
}

0 commit comments

Comments
 (0)