From f8ebaceccef60a112603d290d10072ef4e938a6a Mon Sep 17 00:00:00 2001 From: pngwn Date: Thu, 6 Jun 2024 15:57:00 +0100 Subject: [PATCH] Ensure all status are reported internally when calling `predict` (#8485) * fix param name * format * fix * add changeset --------- Co-authored-by: gradio-pr-bot --- .changeset/quiet-colts-burn.md | 6 ++++++ client/js/src/client.ts | 3 ++- client/js/src/utils/predict.ts | 2 +- client/js/src/utils/submit.ts | 5 +++-- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changeset/quiet-colts-burn.md diff --git a/.changeset/quiet-colts-burn.md b/.changeset/quiet-colts-burn.md new file mode 100644 index 0000000000000..1c44613420d30 --- /dev/null +++ b/.changeset/quiet-colts-burn.md @@ -0,0 +1,6 @@ +--- +"@gradio/client": minor +"gradio": minor +--- + +feat:Ensure all status are reported internally when calling `predict` diff --git a/client/js/src/client.ts b/client/js/src/client.ts index e972d69824cb6..0d694fd7bdc09 100644 --- a/client/js/src/client.ts +++ b/client/js/src/client.ts @@ -102,7 +102,8 @@ export class Client { endpoint: string | number, data: unknown[] | Record, event_data?: unknown, - trigger_id?: number | null + trigger_id?: number | null, + all_events?: boolean ) => SubmitIterable; predict: ( endpoint: string | number, diff --git a/client/js/src/utils/predict.ts b/client/js/src/utils/predict.ts index 660cf871d6635..0d5121123cc3e 100644 --- a/client/js/src/utils/predict.ts +++ b/client/js/src/utils/predict.ts @@ -30,7 +30,7 @@ export async function predict( } return new Promise(async (resolve, reject) => { - const app = this.submit(endpoint, data); + const app = this.submit(endpoint, data, null, null, true); let result: unknown; for await (const message of app) { diff --git a/client/js/src/utils/submit.ts b/client/js/src/utils/submit.ts index fa1c55440786e..b2c02b314932a 100644 --- a/client/js/src/utils/submit.ts +++ b/client/js/src/utils/submit.ts @@ -28,7 +28,8 @@ export function submit( endpoint: string | number, data: unknown[] | Record, event_data?: unknown, - trigger_id?: number | null + trigger_id?: number | null, + all_events?: boolean ): SubmitIterable { try { const { hf_token } = this.options; @@ -87,7 +88,7 @@ export function submit( // event subscription methods function fire_event(event: GradioEvent): void { - if (events_to_publish[event.type]) { + if (all_events || events_to_publish[event.type]) { push_event(event); } }