Skip to content

Commit

Permalink
Merge pull request #2890 from dpanshug/experiment-lastrun
Browse files Browse the repository at this point in the history
Allow experiments table to sort by last run started
  • Loading branch information
openshift-merge-bot[bot] authored Jun 12, 2024
2 parents 74513a0 + 56108da commit 6b6e9d8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions frontend/src/__mocks__/mockExperimentKF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const buildMockExperimentKF = (experiment?: Partial<ExperimentKFv2>): 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,
});

Expand Down
5 changes: 5 additions & 0 deletions frontend/src/concepts/pipelines/content/tables/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export const experimentColumns: SortableData<ExperimentKFv2>[] = [
field: 'created_at',
sortable: true,
},
{
label: 'Last run started',
field: 'last_run_created_at',
sortable: true,
},
{
label: 'Last 5 runs',
field: 'last_5_runs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,6 +43,9 @@ const ExperimentTableRow: React.FC<ExperimentTableRowProps> = ({
<Td dataLabel="Created">
<ExperimentCreated experiment={experiment} />
</Td>
<Td dataLabel="Last run started">
<LastExperimentRunsStarted experiment={experiment} />
</Td>
<Td dataLabel="Last 5 runs">
<LastExperimentRuns experiment={experiment} />
</Td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ export const ExperimentCreated: ExperimentUtil = ({ experiment }) => {
return <PipelinesTableRowTime date={createdDate} />;
};

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) ? '-' : <PipelinesTableRowTime date={lastRunStarted} />;
};

export const LastExperimentRuns: ExperimentUtil = ({ experiment }) => {
const [runs] = usePipelineRunsByExperiment(experiment.experiment_id, {
sortDirection: 'desc',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/concepts/pipelines/kfTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ export type ExperimentKFv2 = {
created_at: string;
namespace?: string;
storage_state: StorageStateKF;
last_run_created_at: string;
};

export type ListExperimentsResponseKF = PipelineKFCallCommon<{
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6b6e9d8

Please sign in to comment.