Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow experiments table to sort by last run started #2890

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 '-';

Check warning on line 20 in frontend/src/concepts/pipelines/content/tables/experiment/renderUtils.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/tables/experiment/renderUtils.tsx#L20

Added line #L20 was not covered by tests
}

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
Loading