add types for unknown jobs
This commit is contained in:
parent
28fc2082c7
commit
5a48447585
|
@ -32,6 +32,7 @@ export function ImageHistory() {
|
|||
case JobStatus.SUCCESS:
|
||||
children.push([key, <ImageCard key={`history-${key}`} image={item.image} onDelete={removeHistory} />]);
|
||||
break;
|
||||
case JobStatus.UNKNOWN:
|
||||
case JobStatus.FAILED:
|
||||
children.push([key, <ErrorCard key={`history-${key}`} image={item.image} retry={item.retry} />]);
|
||||
break;
|
||||
|
|
|
@ -10,10 +10,10 @@ import { useStore } from 'zustand';
|
|||
import { shallow } from 'zustand/shallow';
|
||||
|
||||
import { ClientContext, ConfigContext, OnnxState, StateContext } from '../../state/full.js';
|
||||
import { FailedJobResponse, RetryParams } from '../../types/api-v2.js';
|
||||
import { FailedJobResponse, JobStatus, RetryParams, UnknownJobResponse } from '../../types/api-v2.js';
|
||||
|
||||
export interface ErrorCardProps {
|
||||
image: FailedJobResponse;
|
||||
image: FailedJobResponse | UnknownJobResponse;
|
||||
retry: Maybe<RetryParams>;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export function ErrorCard(props: ErrorCardProps) {
|
|||
<Alert severity='error'>
|
||||
{t('loading.progress', image.steps)}
|
||||
<br />
|
||||
{image.error}
|
||||
{getImageErrorReason(image)}
|
||||
</Alert>
|
||||
<Stack direction='row' spacing={2}>
|
||||
<Tooltip title={t('tooltip.retry')}>
|
||||
|
@ -82,3 +82,11 @@ export function selectActions(state: OnnxState) {
|
|||
removeHistory: state.removeHistory,
|
||||
};
|
||||
}
|
||||
|
||||
export function getImageErrorReason(image: FailedJobResponse | UnknownJobResponse) {
|
||||
if (image.status === JobStatus.FAILED) {
|
||||
return image.error;
|
||||
}
|
||||
|
||||
return image.reason;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,20 @@ export interface BaseJobResponse {
|
|||
|
||||
export interface CancelledJobResponse extends BaseJobResponse {
|
||||
status: JobStatus.CANCELLED;
|
||||
|
||||
/**
|
||||
* Error message to indicate if the job was cancelled by a client, admin, or the server.
|
||||
*/
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export interface UnknownJobResponse extends BaseJobResponse {
|
||||
status: JobStatus.UNKNOWN;
|
||||
|
||||
/**
|
||||
* Error message to indicate why the job was marked as unknown, if there are extenuating circumstances.
|
||||
*/
|
||||
reason: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +171,8 @@ export type JobResponse
|
|||
| PendingJobResponse
|
||||
| RunningJobResponse
|
||||
| FailedJobResponse
|
||||
| SuccessJobResponse;
|
||||
| SuccessJobResponse
|
||||
| UnknownJobResponse;
|
||||
|
||||
/**
|
||||
* Status response from the job endpoint, with parameters to retry the job if it fails.
|
||||
|
|
Loading…
Reference in New Issue