Skip to content

Commit 93656a4

Browse files
authored
[Feature]: Include priority to the list of runs and sort runs by priority (#2768)
* [Feature]: Include priority to the list of runs and sort runs by priority #2740 * [Feature]: Include priority to the list of runs and sort runs by priority #2740
1 parent 9565045 commit 93656a4

9 files changed

Lines changed: 66 additions & 13 deletions

File tree

frontend/src/libs/run.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export const getRunError = (run: IRun): string | null => {
7070
return error ? capitalize(error) : null;
7171
};
7272

73+
export const getRunPriority = (run: IRun): number | null => {
74+
return run.run_spec.configuration?.priority ?? null;
75+
};
76+
7377
export const getExtendedModelFromRun = (run: IRun): IModelExtended | null => {
7478
if (!run?.service?.model) return null;
7579

frontend/src/locale/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@
334334
"workflow_name": "Workflow",
335335
"configuration": "Configuration",
336336
"instance": "Instance",
337+
"priority": "Priority",
337338
"provider_name": "Provider",
338339
"status": "Status",
339340
"submitted_at": "Submitted",

frontend/src/pages/Runs/Details/Jobs/List/hooks.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ import {
2020
getJobTerminationReason,
2121
} from './helpers';
2222

23-
export const useColumnsDefinitions = ({ projectName, runId }: { projectName: string; runId: string }) => {
23+
export const useColumnsDefinitions = ({
24+
projectName,
25+
runId,
26+
runPriority,
27+
}: {
28+
projectName: string;
29+
runId: string;
30+
runPriority?: number | null;
31+
}) => {
2432
const { t } = useTranslation();
2533

2634
const columns = [
@@ -53,6 +61,11 @@ export const useColumnsDefinitions = ({ projectName, runId }: { projectName: str
5361
);
5462
},
5563
},
64+
{
65+
id: 'priority',
66+
header: t('projects.run.priority'),
67+
cell: () => runPriority,
68+
},
5669
{
5770
id: 'error',
5871
header: t('projects.run.error'),

frontend/src/pages/Runs/Details/Jobs/List/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import { useColumnsDefinitions } from './hooks';
1010
export interface Props {
1111
projectName: string;
1212
runId: string;
13+
runPriority?: number | null;
1314
jobs: IRun['jobs'];
1415
}
1516

16-
export const JobList: React.FC<Props> = ({ jobs, projectName, runId }) => {
17+
export const JobList: React.FC<Props> = ({ jobs, projectName, runId, runPriority }) => {
1718
const { t } = useTranslation();
18-
const { columns } = useColumnsDefinitions({ projectName, runId });
19+
const { columns } = useColumnsDefinitions({ projectName, runId, runPriority });
1920

2021
const { items, collectionProps, paginationProps } = useCollection(jobs, {
2122
pagination: { pageSize: 20 },

frontend/src/pages/Runs/Details/RunDetails/index.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import { format } from 'date-fns';
77
import { Box, ColumnLayout, Container, Header, Loader, StatusIndicator } from 'components';
88

99
import { DATE_TIME_FORMAT } from 'consts';
10-
import { getRunError, getRunStatusMessage, getStatusIconColor, getStatusIconType } from 'libs/run';
10+
import { getRunError, getRunPriority, getRunStatusMessage, getStatusIconColor, getStatusIconType } from 'libs/run';
1111
import { useGetRunQuery } from 'services/run';
1212

13+
import { finishedRunStatuses } from 'pages/Runs/constants';
14+
1315
import {
1416
getRunListItemBackend,
1517
getRunListItemInstanceId,
@@ -24,7 +26,6 @@ import { Logs } from '../Logs';
2426
import { getJobSubmissionId } from '../Logs/helpers';
2527

2628
import styles from './styles.module.scss';
27-
import { finishedRunStatuses } from 'pages/Runs/constants';
2829

2930
export const RunDetails = () => {
3031
const { t } = useTranslation();
@@ -48,8 +49,12 @@ export const RunDetails = () => {
4849

4950
if (!runData) return null;
5051

51-
const status = finishedRunStatuses.includes(runData.status) ? runData.latest_job_submission?.status ?? runData.status : runData.status;
52-
const terminationReason = finishedRunStatuses.includes(runData.status) ? runData.latest_job_submission?.termination_reason : null;
52+
const status = finishedRunStatuses.includes(runData.status)
53+
? runData.latest_job_submission?.status ?? runData.status
54+
: runData.status;
55+
const terminationReason = finishedRunStatuses.includes(runData.status)
56+
? runData.latest_job_submission?.termination_reason
57+
: null;
5358

5459
return (
5560
<>
@@ -169,7 +174,14 @@ export const RunDetails = () => {
169174
/>
170175
)}
171176

172-
{runData.jobs.length > 1 && <JobList projectName={paramProjectName} runId={paramRunId} jobs={runData.jobs} />}
177+
{runData.jobs.length > 1 && (
178+
<JobList
179+
projectName={paramProjectName}
180+
runId={paramRunId}
181+
jobs={runData.jobs}
182+
runPriority={getRunPriority(runData)}
183+
/>
184+
)}
173185
</>
174186
);
175187
};

frontend/src/pages/Runs/List/Preferences/consts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ export const DEFAULT_PREFERENCES: CollectionPreferencesProps.Preferences = {
66
{ id: 'run_name', visible: true },
77
{ id: 'resources', visible: true },
88
{ id: 'spot', visible: true },
9+
{ id: 'hub_user_name', visible: true },
910
{ id: 'price', visible: true },
1011
{ id: 'submitted_at', visible: true },
1112
{ id: 'status', visible: true },
1213
{ id: 'error', visible: true },
1314
{ id: 'cost', visible: true },
1415
// hidden by default
16+
{ id: 'priority', visible: false },
1517
{ id: 'finished_at', visible: false },
1618
{ id: 'project', visible: false },
17-
{ id: 'hub_user_name', visible: false },
1819
{ id: 'repo', visible: false },
1920
{ id: 'instance', visible: false },
2021
{ id: 'region', visible: false },

frontend/src/pages/Runs/List/Preferences/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const Preferences: React.FC = () => {
2727
{ id: 'error', label: t('projects.run.error') },
2828
{ id: 'cost', label: t('projects.run.cost') },
2929
// hidden by default
30+
{ id: 'priority', label: t('projects.run.priority') },
3031
{ id: 'finished_at', label: t('projects.run.finished_at') },
3132
{ id: 'project', label: t('projects.run.project') },
3233
{ id: 'hub_user_name', label: t('projects.run.hub_user_name') },

frontend/src/pages/Runs/List/hooks/useColumnsDefinitions.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ import { format } from 'date-fns';
55
import { NavigateLink, StatusIndicator } from 'components';
66

77
import { DATE_TIME_FORMAT } from 'consts';
8-
import { getRepoNameFromRun, getRunError, getRunStatusMessage, getStatusIconColor, getStatusIconType } from 'libs/run';
8+
import {
9+
getRepoNameFromRun,
10+
getRunError,
11+
getRunPriority,
12+
getRunStatusMessage,
13+
getStatusIconColor,
14+
getStatusIconType,
15+
} from 'libs/run';
916
import { ROUTES } from 'routes';
1017

18+
import { finishedRunStatuses } from 'pages/Runs/constants';
19+
1120
import {
1221
getRunListItemBackend,
1322
getRunListItemInstance,
@@ -16,7 +25,6 @@ import {
1625
getRunListItemResources,
1726
getRunListItemSpotLabelKey,
1827
} from '../helpers';
19-
import { finishedRunStatuses } from 'pages/Runs/constants';
2028

2129
export const useColumnsDefinitions = () => {
2230
const { t } = useTranslation();
@@ -66,8 +74,12 @@ export const useColumnsDefinitions = () => {
6674
id: 'status',
6775
header: t('projects.run.status'),
6876
cell: (item: IRun) => {
69-
const status = finishedRunStatuses.includes(item.status) ? item.latest_job_submission?.status ?? item.status : item.status;
70-
const terminationReason = finishedRunStatuses.includes(item.status) ? item.latest_job_submission?.termination_reason : null;
77+
const status = finishedRunStatuses.includes(item.status)
78+
? item.latest_job_submission?.status ?? item.status
79+
: item.status;
80+
const terminationReason = finishedRunStatuses.includes(item.status)
81+
? item.latest_job_submission?.termination_reason
82+
: null;
7183

7284
return (
7385
<StatusIndicator
@@ -84,6 +96,11 @@ export const useColumnsDefinitions = () => {
8496
header: t('projects.run.error'),
8597
cell: (item: IRun) => getRunError(item),
8698
},
99+
{
100+
id: 'priority',
101+
header: t('projects.run.priority'),
102+
cell: (item: IRun) => getRunPriority(item),
103+
},
87104
{
88105
id: 'cost',
89106
header: `${t('projects.run.cost')}`,

frontend/src/types/run.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,18 @@ declare interface IJob {
128128

129129
declare interface IDevEnvironmentConfiguration {
130130
type: 'dev-environment';
131+
priority?: number | null
131132
}
132133

133134
declare interface ITaskConfiguration {
134135
type: 'task';
136+
priority?: number | null
135137
}
136138

137139
declare interface IServiceConfiguration {
138140
type: 'service';
139141
gateway: string | null;
142+
priority?: number | null
140143
}
141144
declare interface IRunSpec {
142145
configuration: IDevEnvironmentConfiguration | ITaskConfiguration | IServiceConfiguration;

0 commit comments

Comments
 (0)