Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

~~[Widgets] Don't call api inference if output exists~~ #1017

Closed
wants to merge 0 commits into from

Conversation

mishig25
Copy link
Collaborator

@mishig25 mishig25 commented Oct 11, 2023

Superceded by #1063

Closes #1011
Follow up to #979

#979 correctly implemented behaviour for the previewInputSample function here. Which is: don't call api-inference if sample.output exists

The same should be the case for applyInputSample and onMount example (which is this PR). Don't call api-inference if sample.output exists. #1011 happened because api-inference was called and there was no cached example although sample.output was in the repo

Wdyt of the proposed solution? I've only implemented for AudioClassificationWidget.svelte. If others agree with the design, will implement for other widgets as well

** for the clarification, previewInputSample function gets called when you hover over different input samples. applyInputSample function gets called when you end up clicking/selecting inout sample

Order of merge operations

  1. Merge [Widgets] Refactor examples running #1023
  2. Then merge ~~[Widgets] Don't call api inference if output exists~~ #1017 (this PR)
  3. Then merge [Widgets] Handle display logic #1019

Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this looks good to me, though the code (not specific to this PR) looks a bit hard to reason about for me...


async function getOutput({ withModelLoading = false, isOnLoadCall = false, sampleOutput = undefined }: GetOutputOptions = {}) {
// don't call api-inference if sample output already exists
if(isValidOutputLabels(sampleOutput)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(code needs formatting)

@SBrandeis
Copy link
Contributor

Logic sounds good to me too

@mishig25 mishig25 changed the title Don't call api inference if output exists [Widgets] Don't call api inference if output exists Oct 16, 2023
Copy link
Contributor

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@mishig25 mishig25 force-pushed the don_compute_output_exists branch from 6c8db96 to 2cc7ec1 Compare October 30, 2023 11:23
@mishig25 mishig25 closed this Oct 30, 2023
@mishig25 mishig25 force-pushed the don_compute_output_exists branch from 2cc7ec1 to cd15b19 Compare October 30, 2023 11:27
@mishig25 mishig25 changed the title [Widgets] Don't call api inference if output exists ~~[Widgets] Don't call api inference if output exists~~ Oct 30, 2023
@mishig25
Copy link
Collaborator Author

Superceded by #1063

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show static widget output on load
4 participants