5050 Volume ,
5151 USER_NAME_LABEL_KEY ,
5252)
53+ from hyperpod_cli .telemetry import _hyperpod_telemetry_emitter
54+ from hyperpod_cli .telemetry .constants import Feature
5355from hyperpod_cli .clients .kubernetes_client import (
5456 KubernetesClient ,
5557)
124126 is_flag = True ,
125127 help = "Enable debug mode" ,
126128)
129+ @_hyperpod_telemetry_emitter (Feature .HYPERPOD_V2 , "hyperpod_v2.get_job_cli" )
127130def get_job (
128131 job_name : str ,
129132 namespace : Optional [str ],
@@ -144,9 +147,8 @@ def get_job(
144147 result = get_training_job_service .get_training_job (job_name , namespace , verbose )
145148 click .echo (result )
146149 except Exception as e :
147- sys .exit (
148- f"Unexpected error happens when trying to get training job { job_name } : { e } "
149- )
150+ logger .error (f"Unexpected error happens when trying to get training job { job_name } : { e } " )
151+ raise
150152
151153
152154@click .command ()
@@ -186,6 +188,7 @@ def get_job(
186188 is_flag = True ,
187189 help = "Enable debug mode" ,
188190)
191+ @_hyperpod_telemetry_emitter (Feature .HYPERPOD_V2 , "hyperpod_v2.list_jobs_cli" )
189192def list_jobs (
190193 namespace : Optional [str ],
191194 all_namespaces : Optional [bool ],
@@ -205,7 +208,8 @@ def list_jobs(
205208 )
206209 click .echo (result )
207210 except Exception as e :
208- sys .exit (f"Unexpected error happens when trying to list training job : { e } " )
211+ logger .error (f"Unexpected error happens when trying to list training job : { e } " )
212+ raise
209213
210214
211215@click .command ()
@@ -228,6 +232,7 @@ def list_jobs(
228232 is_flag = True ,
229233 help = "Enable debug mode" ,
230234)
235+ @_hyperpod_telemetry_emitter (Feature .HYPERPOD_V2 , "hyperpod_v2.list_pods_cli" )
231236def list_pods (
232237 job_name : str ,
233238 namespace : Optional [str ],
@@ -246,9 +251,8 @@ def list_pods(
246251 result = list_pods_service .list_pods_for_training_job (job_name , namespace , True )
247252 click .echo (result )
248253 except Exception as e :
249- sys .exit (
250- f"Unexpected error happens when trying to list pods for training job { job_name } : { e } "
251- )
254+ logger .error (f"Unexpected error happens when trying to list pods for training job { job_name } : { e } " )
255+ raise
252256
253257
254258@click .command ()
@@ -271,6 +275,7 @@ def list_pods(
271275 is_flag = True ,
272276 help = "Enable debug mode" ,
273277)
278+ @_hyperpod_telemetry_emitter (Feature .HYPERPOD_V2 , "hyperpod_v2.cancel_job_cli" )
274279def cancel_job (
275280 job_name : str ,
276281 namespace : Optional [str ],
@@ -287,9 +292,8 @@ def cancel_job(
287292 result = cancel_training_job_service .cancel_training_job (job_name , namespace )
288293 click .echo (result )
289294 except Exception as e :
290- sys .exit (
291- f"Unexpected error happens when trying to cancel training job { job_name } : { e } "
292- )
295+ logger .error (f"Unexpected error happens when trying to cancel training job { job_name } : { e } " )
296+ raise
293297
294298
295299@click .command ()
@@ -536,6 +540,7 @@ def cancel_job(
536540 is_flag = True ,
537541 help = "Enable debug mode" ,
538542)
543+ @_hyperpod_telemetry_emitter (Feature .HYPERPOD_V2 , "hyperpod_v2.start_job_cli" )
539544def start_job (
540545 config_file : Optional [str ],
541546 job_name : Optional [str ],
@@ -876,6 +881,7 @@ def start_job(
876881 help = "Optional. The namespace to use. If not specified, this command will first use the namespace wh connecting the cluster."
877882 "Otherwise if namespace is not configured when connecting to the cluster, a namespace that is managed by SageMaker will be auto discovered." ,
878883)
884+ @_hyperpod_telemetry_emitter (Feature .HYPERPOD_V2 , "hyperpod_v2.patch_job_cli" )
879885def patch_job (patch_type : str , job_name : str , namespace : Optional [str ]):
880886
881887 if patch_type not in JobPatchType .get_values ():
0 commit comments