From 56108dafa8c8227194da33fbd55a8194f735fe02 Mon Sep 17 00:00:00 2001 From: Dipanshu Gupta Date: Fri, 7 Jun 2024 22:29:45 +0530 Subject: [PATCH] Allow experiments table to sort by last run started --- frontend/src/__mocks__/mockExperimentKF.ts | 1 + .../src/concepts/pipelines/content/tables/columns.ts | 5 +++++ .../content/tables/experiment/ExperimentTableRow.tsx | 5 ++++- .../content/tables/experiment/renderUtils.tsx | 12 ++++++++++++ frontend/src/concepts/pipelines/kfTypes.ts | 3 ++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/frontend/src/__mocks__/mockExperimentKF.ts b/frontend/src/__mocks__/mockExperimentKF.ts index fb3a410146..c75df06d24 100644 --- a/frontend/src/__mocks__/mockExperimentKF.ts +++ b/frontend/src/__mocks__/mockExperimentKF.ts @@ -7,6 +7,7 @@ export const buildMockExperimentKF = (experiment?: Partial): Exp description: 'All runs created without specifying an experiment will be grouped here.', created_at: '2024-01-31T15:46:33Z', storage_state: StorageStateKF.AVAILABLE, + last_run_created_at: '2024-01-31T15:46:33Z', ...experiment, }); diff --git a/frontend/src/concepts/pipelines/content/tables/columns.ts b/frontend/src/concepts/pipelines/content/tables/columns.ts index b232fc6e4a..0c0a04fe79 100644 --- a/frontend/src/concepts/pipelines/content/tables/columns.ts +++ b/frontend/src/concepts/pipelines/content/tables/columns.ts @@ -76,6 +76,11 @@ export const experimentColumns: SortableData[] = [ field: 'created_at', sortable: true, }, + { + label: 'Last run started', + field: 'last_run_created_at', + sortable: true, + }, { label: 'Last 5 runs', field: 'last_5_runs', diff --git a/frontend/src/concepts/pipelines/content/tables/experiment/ExperimentTableRow.tsx b/frontend/src/concepts/pipelines/content/tables/experiment/ExperimentTableRow.tsx index af730b7c56..1ca7ac4cfb 100644 --- a/frontend/src/concepts/pipelines/content/tables/experiment/ExperimentTableRow.tsx +++ b/frontend/src/concepts/pipelines/content/tables/experiment/ExperimentTableRow.tsx @@ -7,7 +7,7 @@ import { ExperimentKFv2, StorageStateKF } from '~/concepts/pipelines/kfTypes'; import { CheckboxTd } from '~/components/table'; import { experimentRunsRoute } from '~/routes'; import { usePipelinesAPI } from '~/concepts/pipelines/context'; -import { ExperimentCreated, LastExperimentRuns } from './renderUtils'; +import { ExperimentCreated, LastExperimentRuns, LastExperimentRunsStarted } from './renderUtils'; type ExperimentTableRowProps = { isChecked: boolean; @@ -43,6 +43,9 @@ const ExperimentTableRow: React.FC = ({ + + + diff --git a/frontend/src/concepts/pipelines/content/tables/experiment/renderUtils.tsx b/frontend/src/concepts/pipelines/content/tables/experiment/renderUtils.tsx index 8de348eef8..eeb8d77b71 100644 --- a/frontend/src/concepts/pipelines/content/tables/experiment/renderUtils.tsx +++ b/frontend/src/concepts/pipelines/content/tables/experiment/renderUtils.tsx @@ -12,6 +12,18 @@ export const ExperimentCreated: ExperimentUtil = ({ experiment }) => { return ; }; +export const LastExperimentRunsStarted: ExperimentUtil = ({ experiment }) => { + const lastRunCreatedAt = experiment.last_run_created_at; + + // Check if last_run_created_at is not set or has a default invalid date + if (!lastRunCreatedAt || lastRunCreatedAt === '1970-01-01T00:00:00Z') { + return '-'; + } + + const lastRunStarted = new Date(lastRunCreatedAt); + return Number.isNaN(lastRunStarted) ? '-' : ; +}; + export const LastExperimentRuns: ExperimentUtil = ({ experiment }) => { const [runs] = usePipelineRunsByExperiment(experiment.experiment_id, { sortDirection: 'desc', diff --git a/frontend/src/concepts/pipelines/kfTypes.ts b/frontend/src/concepts/pipelines/kfTypes.ts index 90fb1c1448..0df0175525 100644 --- a/frontend/src/concepts/pipelines/kfTypes.ts +++ b/frontend/src/concepts/pipelines/kfTypes.ts @@ -664,6 +664,7 @@ export type ExperimentKFv2 = { created_at: string; namespace?: string; storage_state: StorageStateKF; + last_run_created_at: string; }; export type ListExperimentsResponseKF = PipelineKFCallCommon<{ @@ -697,7 +698,7 @@ export type CreatePipelineVersionKFData = Omit< export type CreateExperimentKFData = Omit< ExperimentKFv2, - 'experiment_id' | 'created_at' | 'namespace' | 'storage_state' + 'experiment_id' | 'created_at' | 'namespace' | 'storage_state' | 'last_run_created_at' >; export type CreatePipelineRunKFData = Omit< PipelineRunKFv2,