|
22 | 22 | UNKNOWN_DICT, |
23 | 23 | get_resource_name, |
24 | 24 | get_model_by_reference_paths, |
| 25 | + get_ocid_substring, |
| 26 | + AQUA_MODEL_TYPE_SERVICE, |
| 27 | + AQUA_MODEL_TYPE_CUSTOM, |
25 | 28 | ) |
26 | 29 | from ads.aqua.finetune import FineTuneCustomMetadata |
27 | 30 | from ads.aqua.data import AquaResourceIdentifier |
@@ -391,40 +394,27 @@ def create( |
391 | 394 | .with_runtime(container_runtime) |
392 | 395 | ).deploy(wait_for_completion=False) |
393 | 396 |
|
394 | | - if is_fine_tuned_model: |
395 | | - # tracks unique deployments that were created in the user compartment |
396 | | - self.telemetry.record_event_async( |
397 | | - category="aqua/custom/deployment", action="create", detail=model_name |
398 | | - ) |
399 | | - # tracks the shape used for deploying the custom models |
400 | | - self.telemetry.record_event_async( |
401 | | - category="aqua/custom/deployment/create", |
402 | | - action="shape", |
403 | | - detail=instance_shape, |
404 | | - ) |
405 | | - # tracks the shape used for deploying the custom models by name |
406 | | - self.telemetry.record_event_async( |
407 | | - category=f"aqua/custom/{model_name}/deployment/create", |
408 | | - action="shape", |
409 | | - detail=instance_shape, |
410 | | - ) |
411 | | - else: |
412 | | - # tracks unique deployments that were created in the user compartment |
413 | | - self.telemetry.record_event_async( |
414 | | - category="aqua/service/deployment", action="create", detail=model_name |
415 | | - ) |
416 | | - # tracks the shape used for deploying the service models |
417 | | - self.telemetry.record_event_async( |
418 | | - category="aqua/service/deployment/create", |
419 | | - action="shape", |
420 | | - detail=instance_shape, |
421 | | - ) |
422 | | - # tracks the shape used for deploying the service models by name |
423 | | - self.telemetry.record_event_async( |
424 | | - category=f"aqua/service/{model_name}/deployment/create", |
425 | | - action="shape", |
426 | | - detail=instance_shape, |
427 | | - ) |
| 397 | + model_type = ( |
| 398 | + AQUA_MODEL_TYPE_CUSTOM if is_fine_tuned_model else AQUA_MODEL_TYPE_SERVICE |
| 399 | + ) |
| 400 | + deployment_id = deployment.dsc_model_deployment.id |
| 401 | + # we arbitrarily choose last 8 characters of OCID to identify MD in telemetry |
| 402 | + telemetry_kwargs = {"ocid": get_ocid_substring(deployment_id, key_len=8)} |
| 403 | + |
| 404 | + # tracks unique deployments that were created in the user compartment |
| 405 | + self.telemetry.record_event_async( |
| 406 | + category=f"aqua/{model_type}/deployment", |
| 407 | + action="create", |
| 408 | + detail=model_name, |
| 409 | + **telemetry_kwargs, |
| 410 | + ) |
| 411 | + # tracks the shape used for deploying the custom or service models by name |
| 412 | + self.telemetry.record_event_async( |
| 413 | + category=f"aqua/{model_type}/deployment/create", |
| 414 | + action="shape", |
| 415 | + detail=instance_shape, |
| 416 | + value=model_name, |
| 417 | + ) |
428 | 418 |
|
429 | 419 | return AquaDeployment.from_oci_model_deployment( |
430 | 420 | deployment.dsc_model_deployment, self.region |
@@ -471,6 +461,19 @@ def list(self, **kwargs) -> List["AquaDeployment"]: |
471 | 461 | ) |
472 | 462 | ) |
473 | 463 |
|
| 464 | + # log telemetry if MD is in active or failed state |
| 465 | + deployment_id = model_deployment.id |
| 466 | + state = model_deployment.lifecycle_state.upper() |
| 467 | + if state in ["ACTIVE", "FAILED"]: |
| 468 | + # tracks unique deployments that were listed in the user compartment |
| 469 | + # we arbitrarily choose last 8 characters of OCID to identify MD in telemetry |
| 470 | + self.telemetry.record_event_async( |
| 471 | + category=f"aqua/deployment", |
| 472 | + action="list", |
| 473 | + detail=get_ocid_substring(deployment_id, key_len=8), |
| 474 | + value=state, |
| 475 | + ) |
| 476 | + |
474 | 477 | # tracks number of times deployment listing was called |
475 | 478 | self.telemetry.record_event_async(category="aqua/deployment", action="list") |
476 | 479 |
|
|
0 commit comments