solara icon indicating copy to clipboard operation
solara copied to clipboard

feature request: Spinner/Loader on "use_thread"

Open Lundez opened this issue 1 year ago • 4 comments

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.

Lundez avatar Jan 03 '24 12:01 Lundez

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

maartenbreddels avatar Jan 08 '24 11:01 maartenbreddels

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 avatar Jan 09 '24 06:01 Lundez

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

Lundez avatar Mar 02 '24 10:03 Lundez

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.

maartenbreddels avatar Mar 02 '24 11:03 maartenbreddels