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

feature request: Spinner/Loader on "use_thread" #439

Open
Lundez opened this issue Jan 3, 2024 · 4 comments
Open

feature request: Spinner/Loader on "use_thread" #439

Lundez opened this issue Jan 3, 2024 · 4 comments

Comments

@Lundez
Copy link
Contributor

Lundez commented Jan 3, 2024

Hi!

I suggest that we add a mode where a spinner is automatically applied whenever one uses use_thread. This could potentially be

  1. An input variable
  2. A new function (e.g. use_thread_and_load)

I write a lot of code where I wrap this, i.e.

    df = solara_run_inference.use_thread(
        Path(model),
        Path(file),
        aggregate_duration=10,
    )

    if df.state == solara.ResultState.RUNNING:
        Progress("Running...")
    elif df.state == solara.ResultState.FINISHED:
        DfSelector(df.value, file)

and it's starting to be quite ugly as it's in multiple places.

@maartenbreddels
Copy link
Contributor

Hi Hampus,

we totally recognize this boilerplate issue, but I didn't yet come up with a solution that was satisfying and something I would feel comfortable in solara.
What about a custom component that takes the function to run in the thread as an argument? Would that work?

Regards,

Maarten

@Lundez
Copy link
Contributor Author

Lundez commented Jan 9, 2024

Hi Hampus,

we totally recognize this boilerplate issue, but I didn't yet come up with a solution that was satisfying and something I would feel comfortable in solara.
What about a custom component that takes the function to run in the thread as an argument? Would that work?

Regards,

Maarten

Hi!

That's a sound approach. The Streamlit approach is also a smooth one (using with context), alas it isn't compatible with the Solara way of execution.
I'll see if I can make a mini-component to share 👍

BR,
Hampus

@Lundez
Copy link
Contributor Author

Lundez commented Mar 2, 2024

Still not fully solved, but at least task is an improvement. Closing for now. 👍

@Lundez Lundez closed this as completed Mar 2, 2024
@maartenbreddels
Copy link
Contributor

Sorry for keeping this open. We've been working on this internally a bit, but it was difficult to make something general. Keeping it open for a reminder, I think it would be good to have a good pattern for this.

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