Open rafa-guedes opened 1 year ago
+1
+1
+1
+1
+1
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.
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)
+1
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.
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."
)
+1 !
+1!
+1
+1
@rafa-guedes Another way to make Streamlit work with latest Bokeh:
<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"
;<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.<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.
+1
+1
+1
Please update streamlit to use Bokeh 3.1.0
And please add python callback support to it. So we can update the charts without a full redraw of it.
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.
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: @.***>
@sfc-gh-jrieke, if you're polling, I'd vote to switch to Bokeh 3.
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: @.***>
Traceback (most recent call last):
File "C:\Users\PowerUser\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.
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.
+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.
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.
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)
+1
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!
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.
+1
+1
Hey, are there any news regarding the support for Bokeh in version >=3?
+1
+1
@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.
We made it a stretch goal for the upcoming quarter to look into it, but can't guarantee it yet, unfortunately.
+1
+1
+1
+1
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?
We'll update here and you can also always follow our roadmap at https://roadmap.streamlit.app/
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
+1
+1
Support for Bokeh + will be appreciated. Thanks.
Not yet??
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?