@@ -198,20 +198,17 @@ def _get_experiment_run_metrics(self, run: ExperimentRun) -> List[MLMetricClass]
198
198
MLMetricClass (name = k , value = str (v )) for k , v in run .get_metrics ().items ()
199
199
]
200
200
201
- def _get_run_create_time_duration (
201
+ def _get_run_timestamps (
202
202
self , run : ExperimentRun
203
203
) -> Tuple [Optional [int ], Optional [int ]]:
204
204
executions = run .get_executions ()
205
- # When no execution context started, start time and duration was not available
206
- if len (executions ) == 0 :
207
- return None , None
208
- # When one execution context started, start time and duration will be calculated
209
- elif len (executions ) == 1 :
205
+ if len (executions ) == 1 :
210
206
create_time = executions [0 ].create_time
211
207
update_time = executions [0 ].update_time
212
208
duration = update_time .timestamp () * 1000 - create_time .timestamp () * 1000
213
- return int (create_time .timestamp () * 1000 ), duration
214
- # When multiple execution context stared, impossible to know which context to use for create_time and duration
209
+ return int (create_time .timestamp () * 1000 ), int (duration )
210
+ # When no execution context started, start time and duration are not available
211
+ # When multiple execution contexts stared on a run, not unable to know which context to use for create_time and duration
215
212
else :
216
213
return None , None
217
214
@@ -308,7 +305,7 @@ def _gen_experiment_run_mcps(
308
305
id = self ._make_vertexai_experiment_name (experiment .name ),
309
306
)
310
307
run_urn = self ._make_experiment_run_urn (experiment , run )
311
- created_time , duration = self ._get_run_create_time_duration (run )
308
+ created_time , duration = self ._get_run_timestamps (run )
312
309
created_actor = "urn:li:corpuser:datahub"
313
310
run_result_type = self ._get_run_result_status (run .get_state ())
314
311
@@ -347,12 +344,12 @@ def _gen_experiment_run_mcps(
347
344
status = DataProcessRunStatusClass .COMPLETE ,
348
345
timestampMillis = created_time ,
349
346
result = DataProcessInstanceRunResultClass (
350
- type = self . _get_run_result_status ( run . get_state ()) ,
347
+ type = run_result_type ,
351
348
nativeResultType = self .platform ,
352
349
),
353
350
durationMillis = duration ,
354
351
)
355
- if isinstance (run_result_type , RunResultTypeClass )
352
+ if is_status_for_run_event_class (run_result_type )
356
353
and duration
357
354
and created_time
358
355
else None
0 commit comments