diff --git a/frontend/src/libs/run.ts b/frontend/src/libs/run.ts index b1a626bf82..8dd8be3af6 100644 --- a/frontend/src/libs/run.ts +++ b/frontend/src/libs/run.ts @@ -4,6 +4,7 @@ import { StatusIndicatorProps } from '@cloudscape-design/components'; import { capitalize } from 'libs'; import { finishedRunStatuses } from '../pages/Runs/constants'; +import { getJobProbesStatuses } from '../pages/Runs/Details/Jobs/List/helpers'; import { IModelExtended } from '../pages/Models/List/types'; @@ -75,6 +76,16 @@ export const getRunError = (run: IRun): string | null => { return error ? capitalize(error) : null; }; +export const getRunProbe = (run: IRun): string | null => { + const job = run.jobs[0]; + + if (!job) { + return '-'; + } + + return getJobProbesStatuses(run.jobs[0]); +}; + export const getRunPriority = (run: IRun): number | null => { return run.run_spec.configuration?.priority ?? null; }; diff --git a/frontend/src/locale/en.json b/frontend/src/locale/en.json index 342ce0cdd7..7cf3187722 100644 --- a/frontend/src/locale/en.json +++ b/frontend/src/locale/en.json @@ -402,6 +402,7 @@ "priority": "Priority", "provider_name": "Provider", "status": "Status", + "probe": "Probes", "submitted_at": "Submitted", "finished_at": "Finished", "metrics": { diff --git a/frontend/src/pages/Runs/Details/Jobs/List/helpers.ts b/frontend/src/pages/Runs/Details/Jobs/List/helpers.ts index 71247dce6a..6855c45804 100644 --- a/frontend/src/pages/Runs/Details/Jobs/List/helpers.ts +++ b/frontend/src/pages/Runs/Details/Jobs/List/helpers.ts @@ -48,6 +48,31 @@ export const getJobStatus = (job: IJob) => { return job.job_submissions?.[job.job_submissions.length - 1].status; }; +export const getJobSubmissionProbes = (job: IJob) => { + return job.job_submissions?.[job.job_submissions.length - 1].probes; +}; + +export const getJobProbesStatuses = (job: IJob) => { + const status = getJobStatus(job); + const probes = getJobSubmissionProbes(job); + + if (!probes?.length || status !== 'running') { + return null; + } + + return probes + ?.map((probe, index) => { + if (job.job_spec?.probes?.[index] && probe.success_streak >= job.job_spec.probes[index].ready_after) { + return '✓'; + } else if (probe.success_streak > 0) { + return '~'; + } else { + return '×'; + } + }) + .join(''); +}; + export const getJobTerminationReason = (job: IJob) => { return job.job_submissions?.[job.job_submissions.length - 1].termination_reason ?? '-'; }; diff --git a/frontend/src/pages/Runs/Details/Jobs/List/hooks.tsx b/frontend/src/pages/Runs/Details/Jobs/List/hooks.tsx index a5fabd5a2f..b7ebbdb74f 100644 --- a/frontend/src/pages/Runs/Details/Jobs/List/hooks.tsx +++ b/frontend/src/pages/Runs/Details/Jobs/List/hooks.tsx @@ -15,6 +15,7 @@ import { getJobListItemRegion, getJobListItemResources, getJobListItemSpot, + getJobProbesStatuses, getJobStatus, getJobStatusMessage, getJobSubmittedAt, @@ -67,6 +68,11 @@ export const useColumnsDefinitions = ({ ); }, }, + { + id: 'probe', + header: t('projects.run.probe'), + cell: (item: IJob) => getJobProbesStatuses(item), + }, { id: 'priority', header: t('projects.run.priority'), diff --git a/frontend/src/pages/Runs/Details/RunDetails/index.tsx b/frontend/src/pages/Runs/Details/RunDetails/index.tsx index 24e5c2718d..5de6bb9a02 100644 --- a/frontend/src/pages/Runs/Details/RunDetails/index.tsx +++ b/frontend/src/pages/Runs/Details/RunDetails/index.tsx @@ -7,7 +7,7 @@ import { format } from 'date-fns'; import { Box, ColumnLayout, Container, Header, Loader, NavigateLink, StatusIndicator } from 'components'; import { DATE_TIME_FORMAT } from 'consts'; -import { getRunError, getRunPriority, getRunStatusMessage, getStatusIconColor, getStatusIconType } from 'libs/run'; +import { getRunError, getRunPriority, getRunProbe, getRunStatusMessage, getStatusIconColor, getStatusIconType } from 'libs/run'; import { ROUTES } from 'routes'; import { useGetRunQuery } from 'services/run'; @@ -122,6 +122,13 @@ export const RunDetails = () => { + {runData.jobs.length <= 1 && ( +
+ {t('projects.run.probe')} +
{getRunProbe(runData)}
+
+ )} +
{t('projects.run.error')}
{getRunError(runData) ?? '-'}
diff --git a/frontend/src/types/run.d.ts b/frontend/src/types/run.d.ts index 452d3a9f41..2e17206a05 100644 --- a/frontend/src/types/run.d.ts +++ b/frontend/src/types/run.d.ts @@ -171,6 +171,17 @@ declare interface IAppSpec { url_query_params?: { [key: string]: string }; } +declare interface IJobProbe { + type: 'http'; + url: string; + method?: 'head' | 'post' | 'put' | 'patch' | 'delete' | 'get'; + headers?: Array<{ name: string; value: string }>; + body?: string; + timeout: number; + interval: number; + ready_after: number; +} + declare interface IJobSpec { app_specs?: IAppSpec; commands: string[]; @@ -181,6 +192,7 @@ declare interface IJobSpec { job_num: number; max_duration?: number; working_dir: string; + probes?: IJobProbe[]; } declare interface IGpu { @@ -234,6 +246,7 @@ declare interface IJobSubmission { exit_status?: number | null; status_message?: string | null; error?: string | null; + probes?: Array<{ success_streak: number }>; } declare interface IJob {