Open MarcSkovMadsen opened 3 years ago
Hi @danmaty
My comments to your example are
Could we make a "real" example solving some problem that uses unsync?
How do we know that recommending this approach is a good idea? is unsync
a robust, well maintained library? And can we expect it to stay that?
Hi @MarcSkovMadsen
I can't confirm whether or not Unsync is well maintained. That might be a question for @alex-sherman to answer.
I've made another very simple example with longer background processes utilizing Pandas + IMDB data and Pandas-profiling + Numpy.
To me Panel apps are always about user experience. How does the app feel and look. In my opinion a very obvious goal for the tool should be to make it possible to style it easily and to achieve a more dynamic feel. It's already possible to do these to some extent but not necessarily in a straightforward way.
So this example has three tabs. App initial load time is quick because it renders without value/object on the second and third tab and the first one is essentially just distraction. This is to provide more ideas on how to utilize Unsync to prevent Panel's potentially long initial load and to keep the app responsive / alive while contents are being generated in the background obviously in the most ideal/prioritized order. So the user can experience on-demand data as much as it is possible.
See attached code. Not sure how to highlight...
import panel as pn
import param
import pandas as pd
import numpy as np
from pandas_profiling import ProfileReport
from unsync import unsync
from time import time as tt
pn.config.sizing_mode='stretch_both'
pn.extension('tabulator')
@unsync
def make_html():
start = tt()
df = pd.DataFrame(np.random.rand(100, 5), columns=["a", "b", "c", "d", "e"])
profile = ProfileReport(df, title="Pandas Profiling Report", explorative=False)
html = profile.to_html()
html_pane.object = html
print('make_html', tt() - start)
@unsync
def make_table():
start = tt()
link = 'https://datasets.imdbws.com/title.ratings.tsv.gz'
link2 = 'https://datasets.imdbws.com/title.episode.tsv.gz'
df = pd.read_csv(link, compression='gzip', sep='\t').describe()
tabulator_pane.value = df
print('make_table', tt() - start)
html_pane = pn.pane.HTML()
tabulator_pane = pn.widgets.Tabulator()
str_pane = pn.pane.Str('Blah blah blah')
make_html()
make_table()
tabulator_pane = pn.widgets.Tabulator()
pn.layout.Tabs(('Intro', str_pane), ('Table', tabulator_pane), ('HTML', html_pane)).show()
Unsync certainly looks interesting but there are many different such solutions and I do not think such an example belongs in Panel itself. We'd be happy to host such an example on https://github.com/pyviz-topics/examples or somewhere else and link it from the Panel user guide and gallery however. Do not want to make this decision unilaterally however. Any thoughts @maximlt and @jbednar ?
I'd be very happy to have a solid, performant, and ambitious async Panel app to host on examples.pyviz.org!
is
unsync
a robust, well maintained library? And can we expect it to stay that?
Yeah I think it's well maintained, but obviously biased. It hasn't changed for quite some time, and I only expect to get occasional bugs from new Python versions etc. Realistically it's <200 lines so not much to maintain anyway 😉
As your experience with Panel grows you start to want to make highly performant Panel apps. There is not so much information on this out there.
Panel provides the guide Async and Concurrency.
An approach that can combine async, threading and multiprocessing seems to be unsync.
It is discussed here https://discourse.holoviz.org/t/async-and-concurrency-for-dummies/2546.
@danmaty and I are discussing if we could provide something useful for Panel like a Gallery Example.
Marc Wishes
Example
From https://discourse.holoviz.org/t/async-and-concurrency-for-dummies/2546/9?u=marc
https://user-images.githubusercontent.com/42288570/135205265-7dea5251-1e8f-4fb6-bd30-cc2fb083650f.mp4
App Ideas