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 2222 UNKNOWN_DICT ,
2323 get_resource_name ,
2424 get_model_by_reference_paths ,
25+ get_ocid_substring ,
2526)
2627from ads .aqua .finetune import FineTuneCustomMetadata
2728from ads .aqua .data import AquaResourceIdentifier
@@ -393,9 +394,8 @@ def create(
393394
394395 model_type = "custom" if is_fine_tuned_model else "service"
395396 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+
399399 # tracks unique deployments that were created in the user compartment
400400 self .telemetry .record_event_async (
401401 category = f"aqua/{ model_type } /deployment" ,
@@ -464,7 +464,7 @@ def list(self, **kwargs) -> List["AquaDeployment"]:
464464 self .telemetry .record_event_async (
465465 category = f"aqua/deployment" ,
466466 action = "list" ,
467- detail = deployment_id [ - 8 :] if len (deployment_id ) > 8 else "" ,
467+ detail = get_ocid_substring (deployment_id , key_len = 8 ) ,
468468 value = state ,
469469 )
470470
Original file line number Diff line number Diff line change @@ -741,3 +741,9 @@ def known_realm():
741741
742742 """
743743 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