Skip to content

Commit a6cf015

Browse files
committed
Fixed type error for duration in experiment_run mcp
1 parent 82d97d3 commit a6cf015

File tree

1 file changed

+8
-11
lines changed
  • metadata-ingestion/src/datahub/ingestion/source/vertexai

1 file changed

+8
-11
lines changed

metadata-ingestion/src/datahub/ingestion/source/vertexai/vertexai.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,17 @@ def _get_experiment_run_metrics(self, run: ExperimentRun) -> List[MLMetricClass]
198198
MLMetricClass(name=k, value=str(v)) for k, v in run.get_metrics().items()
199199
]
200200

201-
def _get_run_create_time_duration(
201+
def _get_run_timestamps(
202202
self, run: ExperimentRun
203203
) -> Tuple[Optional[int], Optional[int]]:
204204
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:
210206
create_time = executions[0].create_time
211207
update_time = executions[0].update_time
212208
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
215212
else:
216213
return None, None
217214

@@ -308,7 +305,7 @@ def _gen_experiment_run_mcps(
308305
id=self._make_vertexai_experiment_name(experiment.name),
309306
)
310307
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)
312309
created_actor = "urn:li:corpuser:datahub"
313310
run_result_type = self._get_run_result_status(run.get_state())
314311

@@ -347,12 +344,12 @@ def _gen_experiment_run_mcps(
347344
status=DataProcessRunStatusClass.COMPLETE,
348345
timestampMillis=created_time,
349346
result=DataProcessInstanceRunResultClass(
350-
type=self._get_run_result_status(run.get_state()),
347+
type=run_result_type,
351348
nativeResultType=self.platform,
352349
),
353350
durationMillis=duration,
354351
)
355-
if isinstance(run_result_type, RunResultTypeClass)
352+
if is_status_for_run_event_class(run_result_type)
356353
and duration
357354
and created_time
358355
else None

0 commit comments

Comments
 (0)