From e3a6635ca20c2ef3cea26d3be5fb1b846a15f488 Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Wed, 3 Jan 2024 23:58:57 -0600 Subject: [PATCH] remove unused job type field --- api/onnx_web/server/api.py | 16 +++++++++------- gui/src/client/api.ts | 3 +-- gui/src/components/card/ErrorCard.tsx | 2 +- gui/src/types/api-v2.ts | 14 +------------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/api/onnx_web/server/api.py b/api/onnx_web/server/api.py index c9a503c4..bc8cb5e4 100644 --- a/api/onnx_web/server/api.py +++ b/api/onnx_web/server/api.py @@ -34,7 +34,7 @@ from ..utils import ( load_config_str, sanitize_name, ) -from ..worker.command import JobType +from ..worker.command import JobStatus, JobType from ..worker.pool import DevicePoolExecutor from .context import ServerContext from .load import ( @@ -105,7 +105,6 @@ def image_reply( server: ServerContext, name: str, status: str, - job_type: str, stages: Progress = None, steps: Progress = None, tiles: Progress = None, @@ -124,7 +123,6 @@ def image_reply( data = { "name": name, "status": status, - "type": job_type, "stages": stages.tojson(), "steps": steps.tojson(), "tiles": tiles.tojson(), @@ -646,11 +644,16 @@ def job_cancel(server: ServerContext, pool: DevicePoolExecutor): if len(job_list) == 0: return error_reply("at least one job name is required") - results = {} + results = [] for job_name in job_list: job_name = sanitize_name(job_name) cancelled = pool.cancel(job_name) - results[job_name] = cancelled + results.append( + { + "name": job_name, + "status": JobStatus.CANCELLED if cancelled else JobStatus.PENDING, + } + ) return multi_image_reply(results) @@ -682,7 +685,6 @@ def job_status(server: ServerContext, pool: DevicePoolExecutor): server, job_name, status, - "TODO", stages=Progress(progress.stages, 0), steps=Progress(progress.steps, 0), tiles=Progress(progress.tiles, 0), @@ -690,7 +692,7 @@ def job_status(server: ServerContext, pool: DevicePoolExecutor): metadata=metadata, ) - return image_reply(server, job_name, status, "TODO") + return image_reply(server, job_name, status) def register_api_routes(app: Flask, server: ServerContext, pool: DevicePoolExecutor): diff --git a/gui/src/client/api.ts b/gui/src/client/api.ts index 65eea73e..5aa929d9 100644 --- a/gui/src/client/api.ts +++ b/gui/src/client/api.ts @@ -42,8 +42,7 @@ export const FIXED_FLOAT = 2; export const STATUS_SUCCESS = 200; export function equalResponse(a: JobResponse, b: JobResponse): boolean { - return a.name === b.name && a.status === b.status && a.type === b.type; - // return a.outputs === b.outputs; + return a.name === b.name; } /** diff --git a/gui/src/components/card/ErrorCard.tsx b/gui/src/components/card/ErrorCard.tsx index d9f3fb96..7d2311f4 100644 --- a/gui/src/components/card/ErrorCard.tsx +++ b/gui/src/components/card/ErrorCard.tsx @@ -88,5 +88,5 @@ export function getImageErrorReason(image: FailedJobResponse | UnknownJobRespons return image.error; } - return image.reason; + return ''; } diff --git a/gui/src/types/api-v2.ts b/gui/src/types/api-v2.ts index afafcc9e..578c1294 100644 --- a/gui/src/types/api-v2.ts +++ b/gui/src/types/api-v2.ts @@ -55,7 +55,6 @@ export enum JobType { export interface BaseJobResponse { name: string; status: JobStatus; - type: JobType; stages: Progress; steps: Progress; @@ -68,16 +67,11 @@ export interface CancelledJobResponse extends BaseJobResponse { /** * Error message to indicate if the job was cancelled by a client, admin, or the server. */ - reason: string; + 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; } /** @@ -105,7 +99,6 @@ export interface FailedJobResponse extends BaseJobResponse { */ export interface SuccessTxt2ImgJobResponse extends BaseJobResponse { status: JobStatus.SUCCESS; - type: JobType.TXT2IMG; outputs: Array; metadata: Array>; } @@ -115,7 +108,6 @@ export interface SuccessTxt2ImgJobResponse extends BaseJobResponse { */ export interface SuccessImg2ImgJobResponse extends BaseJobResponse { status: JobStatus.SUCCESS; - type: JobType.IMG2IMG; outputs: Array; metadata: Array>; } @@ -125,7 +117,6 @@ export interface SuccessImg2ImgJobResponse extends BaseJobResponse { */ export interface SuccessInpaintJobResponse extends BaseJobResponse { status: JobStatus.SUCCESS; - type: JobType.INPAINT; outputs: Array; metadata: Array>; } @@ -135,7 +126,6 @@ export interface SuccessInpaintJobResponse extends BaseJobResponse { */ export interface SuccessUpscaleJobResponse extends BaseJobResponse { status: JobStatus.SUCCESS; - type: JobType.UPSCALE; outputs: Array; metadata: Array>; } @@ -145,7 +135,6 @@ export interface SuccessUpscaleJobResponse extends BaseJobResponse { */ export interface SuccessBlendJobResponse extends BaseJobResponse { status: JobStatus.SUCCESS; - type: JobType.BLEND; outputs: Array; metadata: Array>; } @@ -155,7 +144,6 @@ export interface SuccessBlendJobResponse extends BaseJobResponse { */ export interface SuccessChainJobResponse extends BaseJobResponse { status: JobStatus.SUCCESS; - type: JobType.CHAIN; outputs: Array; metadata: Array>; // TODO: could be all kinds }