File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 22
22
UNKNOWN_DICT ,
23
23
get_resource_name ,
24
24
get_model_by_reference_paths ,
25
+ get_ocid_substring ,
25
26
)
26
27
from ads .aqua .finetune import FineTuneCustomMetadata
27
28
from ads .aqua .data import AquaResourceIdentifier
@@ -393,9 +394,8 @@ def create(
393
394
394
395
model_type = "custom" if is_fine_tuned_model else "service"
395
396
deployment_id = deployment .dsc_model_deployment .id
396
- telemetry_kwargs = (
397
- {"ocid" : deployment_id [- 8 :]} if len (deployment_id ) > 8 else {}
398
- )
397
+ telemetry_kwargs = {"ocid" : get_ocid_substring (deployment_id , key_len = 8 )}
398
+
399
399
# tracks unique deployments that were created in the user compartment
400
400
self .telemetry .record_event_async (
401
401
category = f"aqua/{ model_type } /deployment" ,
@@ -464,7 +464,7 @@ def list(self, **kwargs) -> List["AquaDeployment"]:
464
464
self .telemetry .record_event_async (
465
465
category = f"aqua/deployment" ,
466
466
action = "list" ,
467
- detail = deployment_id [ - 8 :] if len (deployment_id ) > 8 else "" ,
467
+ detail = get_ocid_substring (deployment_id , key_len = 8 ) ,
468
468
value = state ,
469
469
)
470
470
Original file line number Diff line number Diff line change @@ -741,3 +741,9 @@ def known_realm():
741
741
742
742
"""
743
743
return os .environ .get ("CONDA_BUCKET_NS" ) in AQUA_GA_LIST
744
+
745
+
746
+ def get_ocid_substring (ocid : str , key_len : int = 8 ) -> str :
747
+ """This helper function returns the last n characters of the ocid specified by key_len parameter, which defaults
748
+ to 8. If ocid is None or length is less than key_len, it returns an empty string."""
749
+ return ocid [- key_len :] if ocid and len (ocid ) > key_len else ""
You can’t perform that action at this time.
0 commit comments