streamlit / streamlit

Streamlit — A faster way to build and share data apps.
https://streamlit.io
Apache License 2.0
35.21k stars 3.05k forks source link

Support bokeh 3.0.3 #5858

Open rafa-guedes opened 1 year ago

rafa-guedes commented 1 year ago

Problem

Bokeh is already in version 3.0.3 and there are a few useful changes. It would be great if streamlit could support that version. Currently streamlit raises an exception if bokeh>2.4.3 is used.

Solution

Upgrade bokeh versions supported in streamlit. Is it really necessary to raise an exception if the user tries to use a newer version? Would it be possible to still allow it and let the user deal with potential issues?

laserson commented 1 year ago

+1

Mengxicici commented 1 year ago

+1

intergalacticBasil commented 1 year ago

+1

mr-easy commented 1 year ago

+1

eliyahuA commented 1 year ago

+1

brunocastroibarburu94 commented 1 year ago

Ditto, bokeh has one of the best visualizations out there and Streamlit one of the best packages to develop web apps. it would be awesome if the latest version of Streamlit would support the latest version of Bokeh as well.

eliyahuA commented 1 year ago

I have found a way to work around this limitation.

import streamlit as st
import pandas as pd
import streamlit.components.v1 as components

from bokeh.plotting import figure, save
from bokeh.io import output_file

def use_file_for_bokeh(chart: figure, chart_height=500):
    output_file('bokeh_graph.html')
    save(chart)
    with open("bokeh_graph.html", 'r', encoding='utf-8') as f:
        html = f.read()
    components.html(html, height=chart_height)

st.bokeh_chart = use_file_for_bokeh
df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5, 6], 'y': [2, 6, 4, 6, 8, 3, 5]})

st.dataframe(df)

p = figure(x_axis_label='x', y_axis_label='y')
p.line(df.x, df.y)
st.bokeh_chart(p)
JiangJohnny commented 1 year ago

+1

brunocastroibarburu94 commented 1 year ago

Sweet, it is definitely a great work around @eliyahuA! Any ideas on how to enable the option use_container_width? I tried checking their code it seems that is set as an input to their proto object.

However this approach seems a little bit more difficult than just setting the height and width option using @eliyahuA solution.

There was an issue on getting the container but due to a lack of a use case it was closed.

Get container / column width

brunocastroibarburu94 commented 1 year ago

Would it be possible to add an additional input for bokeh_chart ? Is there any fatal error on streamlit or was just out of carefulness?

An example like the one below could be implemented as a patch as it would be backwards compatible with the current code.

# Unchanged Code ...
def bokeh_chart(self, figure, use_container_width=False, bokeh_version_check: bool = True):

# Unchanged Code ...
     if bokeh.__version__ != ST_BOKEH_VERSION and bokeh_version_check:
            raise StreamlitAPIException(
                f"Streamlit only supports Bokeh version {ST_BOKEH_VERSION}, "
                f"but you have version {bokeh.__version__} installed. Please "
                f"run `pip install --force-reinstall --no-deps bokeh=="
                f"{ST_BOKEH_VERSION}` to install the correct version."
            )
lqmike commented 1 year ago

+1 !

seanxwzhang commented 1 year ago

+1!

jay1999ke commented 1 year ago

+1

ilyalasy commented 1 year ago

+1

chenyulue commented 1 year ago

@rafa-guedes Another way to make Streamlit work with latest Bokeh:

  1. Go to <Your lib path>/site-packages/streamlit/elements/bokeh_chart.py, and replace ST_BOKEH_VERSION: Final = "2.4.3" with ST_BOKEH_VERSION: Final = "3.1.0";
  2. Go to <Your lib path>/site-packages/streamlit/static/index.html, and replace 2.4.3 in bokeh-*-.js with 3.1.0. This is important, because the python bokeh version must match the bokehjs version.
  3. Download the lastest bokehjs version, and copy the downloaded bokehjs files into <Your lib path>/site-packages/streamlit/static/vendor/bokeh

Then Streamlit works with the latest Bokeh. Enjoy it! ^_^

-------------------- Update ----------------------- The above method works for Streamlit 1.21.0, but not for Streamlit 1.22.0.

laqua-stack commented 1 year ago

+1

martinzrrl commented 1 year ago

+1

Vital-Fernandez commented 1 year ago

+1

Simba7373 commented 1 year ago

Please update streamlit to use Bokeh 3.1.0

msei99 commented 1 year ago

And please add python callback support to it. So we can update the charts without a full redraw of it.

sfc-gh-jrieke commented 1 year ago

Hey everyone! PM on the Streamlit team here. Looking through the Bokeh 3 release notes, it seems like there were quite a lot of breaking changes. But not really a Bokeh expert myself. Do y'all think it would be ok if we simply replace Bokeh 2 with Bokeh 3 at this point? Or are there so many breaking changes that it would break a lot of old charts and be annoying?

We could also implement a way to support both Bokeh 2 and 3 but a) it would be a bit more involved and b) it would increase our dependency size quite a bit.

Simba7373 commented 12 months ago

I vote for Bokeh 3. I cannot get 2 to be stable. Any changes to the code in version 2 can cause a crash. I have been using plotly, which works well but takes a lot of time.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Johannes Rieke @.> Sent: Friday, October 20, 2023 8:45:01 AM To: streamlit/streamlit @.> Cc: Simba7373 @.>; Comment @.> Subject: Re: [streamlit/streamlit] Support bokeh 3.0.3 (Issue #5858)

Hey everyone! PM on the Streamlit team here. Looking through the Bokeh 3 release noteshttps://github.com/bokeh/bokeh/wiki/Migration-Guides#deprecations--2, it seems like there were quite a lot of breaking changes. But not really a Bokeh expert myself. Do y'all think it would be ok if we simply replace Bokeh 2 with Bokeh 3 at this point? Or are there so many breaking changes that it would break a lot of old charts and be annoying?

We could also implement a way to support both Bokeh 2 and 3 but a) it would be a bit more involved and b) it would increase our dependency size quite a bit.

— Reply to this email directly, view it on GitHubhttps://github.com/streamlit/streamlit/issues/5858#issuecomment-1772768591, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BATE3P5YMAJ25FYO7EKKD23YAJ553AVCNFSM6AAAAAAS7LYIUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZSG43DQNJZGE. You are receiving this because you commented.Message ID: @.***>

laserson commented 12 months ago

@sfc-gh-jrieke, if you're polling, I'd vote to switch to Bokeh 3.

lqmike commented 12 months ago

definitely just switch to bokeh 3!

On Fri, Oct 20, 2023 at 21:45 Johannes Rieke @.***> wrote:

Hey everyone! PM on the Streamlit team here. Looking through the Bokeh 3 release notes https://github.com/bokeh/bokeh/wiki/Migration-Guides#deprecations--2, it seems like there were quite a lot of breaking changes. But not really a Bokeh expert myself. Do y'all think it would be ok if we simply replace Bokeh 2 with Bokeh 3 at this point? Or are there so many breaking changes that it would break a lot of old charts and be annoying?

We could also implement a way to support both Bokeh 2 and 3 but a) it would be a bit more involved and b) it would increase our dependency size quite a bit.

— Reply to this email directly, view it on GitHub https://github.com/streamlit/streamlit/issues/5858#issuecomment-1772768591, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALRZQV62VFQUXIHKHJANIVLYAJ55ZAVCNFSM6AAAAAAS7LYIUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZSG43DQNJZGE . You are receiving this because you commented.Message ID: @.***>

richlysakowski commented 12 months ago

Traceback (most recent call last): File "C:\Users\PowerUser\-Tutorials-NBs\HolovizApp_Fluid_Jet_Striking_Curved_Vane\Fluid_Jet_Hitting_Curved_VaneStreamlit-vUnknown.py", line 53, in st.bokeh_chart(bokeh_plot) File "C:\ProgramData\Anaconda3\envs\\lib\site-packages\streamlit\runtime\metrics_util.py", line 367, in wrapped_func result = non_optional_func(*args, **kwargs) File "C:\ProgramData\Anaconda3\envs\\lib\site-packages\streamlit\elements\bokeh_chart.py", line 85, in bokeh_chart raise StreamlitAPIException( streamlit.errors.StreamlitAPIException: Streamlit only supports Bokeh version 2.4.3, but you have version 3.2.2 installed. Please run pip install --force-reinstall --no-deps bokeh==2.4.3 to install the correct version.

################################################### Streamlit must update to Bokeh v3.x

I have some applications that REQUIRE Bokeh v3.x NOW.

Bokeh predates Streamlit by many years, and has provided interactive plotting long before Streamlit existed.

Come'on Streamlit ... please support ALL mainstream FOSS packages (like Pandas, Matplotlib, Bokeh, Holoviews, Scikit-Learn, Plotly and others) !!!!!

Now I MUST switch to Flask or another rapid prototyping framework until this gets fixed. Not looking forward to the extra work.

Thanks in advance for your efforts on fixing this.

brunocastroibarburu94 commented 12 months ago

Hey @richlysakowski this is an open source package, literally they are giving out this for free, if you have a financial application and are benefiting economically and this is so critical put an MR or reach their team privately and pay them to put a patch forward (like any company receiving a service).

I also worked in finance and creating a patch for this using bokeh 3 was a 10 minutes patch, just because you are under pressure is no reason to address the streamlit team this way, particularly on an open forum.

Streamlit guys, your package is awesome, supporting Bokeh 3 would be great but is understandable that prioritization of features and restricted manpower can leave stuff behind.

crypticintent commented 12 months ago

+1 for Streamlit coming up to date with Bokeh.
Bokeh is my preferred visualization method. I'll take a peek under the hood later if I can get it running. Still amazed at what is coming down the pipe in streamlit though.

crypticintent commented 12 months ago

I have found a way to work around this limitation.

import streamlit as st
import pandas as pd
import streamlit.components.v1 as components

from bokeh.plotting import figure, save
from bokeh.io import output_file

def use_file_for_bokeh(chart: figure, chart_height=500):
    output_file('bokeh_graph.html')
    save(chart)
    with open("bokeh_graph.html", 'r', encoding='utf-8') as f:
        html = f.read()
    components.html(html, height=chart_height)

st.bokeh_chart = use_file_for_bokeh
df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5, 6], 'y': [2, 6, 4, 6, 8, 3, 5]})

st.dataframe(df)

p = figure(x_axis_label='x', y_axis_label='y')
p.line(df.x, df.y)
st.bokeh_chart(p)

And thank you for this. Works well enough for my testing and rapid prototyping.

OSuwaidi commented 11 months ago

A cleaner work around (without unnecessary I/O) to use latest Bokeh version with latest Streamlit version:

from bokeh.embed import file_html
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource
import streamlit.components.v1 as components
import pandas as pd

df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5, 6], 'y': [2, 6, 4, 6, 8, 3, 5]})
p = figure(x_axis_label='x', y_axis_label='y')
p.line('x', 'y', source=ColumnDataSource(df))

components.html(file_html(p, 'cdn', ), height=800)
dustinstansbury commented 10 months ago

+1

ChristophNa commented 10 months ago

An even cleaner workaround would be creating a component. I tried to update the streamlit-bokeh-events component from ash2shukla (which would then come with bokeh3 and many additional interactive features). It already works with bokeh3 in development mode. If an expert could help me getting the npm build running, I will create a pip package. For more information and the updated repository visit streamlit-bokeh3-events Any help appreciated!

ChristophNa commented 10 months ago

The streamlit-bokeh3-events component is now available via pip. You can now use streamlit with bokeh 3 and have bi-directional communication :). Feel free to install and try it out! Or just try it out yourself in my example streamlit app.

philipmathieuKM commented 8 months ago

+1

DonYum commented 8 months ago

+1

PiotrDerewonko commented 8 months ago

Hey, are there any news regarding the support for Bokeh in version >=3?

phonosync commented 6 months ago

+1

Vital-Fernandez commented 5 months ago

+1

u3Izx9ql7vW4 commented 5 months ago

@sfc-gh-jrieke Any updates on this? It's been a several months since your question and there've been pretty consistent feedback from the community.

jrieke commented 5 months ago

We made it a stretch goal for the upcoming quarter to look into it, but can't guarantee it yet, unfortunately.

Henrydw commented 4 months ago

+1

parmentelat commented 4 months ago

+1

CyrilJl commented 4 months ago

+1

Xaego commented 4 months ago

+1

tommycarstensen commented 3 months ago

We made it a stretch goal for the upcoming quarter to look into it, but can't guarantee it yet, unfortunately.

Where can one track the work item if one exists?

jrieke commented 3 months ago

We'll update here and you can also always follow our roadmap at https://roadmap.streamlit.app/

tkoskela commented 3 months ago

The supported version 2.4.3 of bokeh doesn't work with the new release numpy/2.0.0. Support for bokeh 3 would be really nice

KevinLloyd commented 1 month ago

+1

SergioGonzalezSevilla commented 1 month ago

+1

ChowSJ commented 2 weeks ago

Support for Bokeh + will be appreciated. Thanks.

Kasprutz commented 1 week ago

Not yet??