Skip to content

Commit

Permalink
Ensure all status are reported internally when calling predict (#8485)
Browse files Browse the repository at this point in the history
* fix param name

* format

* fix

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
pngwn and gradio-pr-bot committed Jun 6, 2024
1 parent c796394 commit f8ebace
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/quiet-colts-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/client": minor
"gradio": minor
---

feat:Ensure all status are reported internally when calling `predict`
3 changes: 2 additions & 1 deletion client/js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export class Client {
endpoint: string | number,
data: unknown[] | Record<string, unknown>,
event_data?: unknown,
trigger_id?: number | null
trigger_id?: number | null,
all_events?: boolean
) => SubmitIterable<GradioEvent>;
predict: (
endpoint: string | number,
Expand Down
2 changes: 1 addition & 1 deletion client/js/src/utils/predict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions client/js/src/utils/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export function submit(
endpoint: string | number,
data: unknown[] | Record<string, unknown>,
event_data?: unknown,
trigger_id?: number | null
trigger_id?: number | null,
all_events?: boolean
): SubmitIterable<GradioEvent> {
try {
const { hf_token } = this.options;
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit f8ebace

Please sign in to comment.