ideonate / streamlit-launchpad

Browse a folder containing multiple streamlit apps and launch them immediately
Apache License 2.0
141 stars 25 forks source link

No longer working after updating streamlit #12

Open jasonmbray opened 1 year ago

jasonmbray commented 1 year ago

Not sure if this repo is still being maintained, but worth a shot. I tested this out with an older version of streamlit, v1.9, and it was working great. When I upgraded streamlit to 1.26, streamlit-launchpad no longer works as expected. From what I could figure out, there was a significant change to the streamlit API around v1.18, which changed the way the websocket communicates. For example, the path /stream has changed to _stcore/stream. See, for example, https://github.com/streamlit/streamlit/issues/6305

I've tried to modify how the proxy handlers are defined, but without much luck. I think I was able to fix the /_stcore/stream issue I mentioned, but there are still a couple others that I can't figure out. The app is running normally on the auto-generated 8501/8502/8503 ports if I visit them directly, but the proxy isn't working and main page is just stuck on "Please wait...".

Seems like it could be an easy thing to fix for someone who understands tornado and proxy handlers better than I do. Is there anyone who has gotten this to work with a recent version of streamlit?

Current errors:

304
WEBSOCKET OPENING ON ws://localhost:8501/_stcore/stream
INCOMING URL: _stcore/allowed-message-origins
GET : http://localhost:8501/_stcore/allowed-message-origins
INCOMING URL: _stcore/health
GET : http://localhost:8501/_stcore/health
 **** response.error
HTTP 304: Not Modified
{'Connection': 'keep-alive', 'Accept': 'application/json, text/plain, */*', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.43', 'Referer': 'http://SERVER:PORT/intro.py/', 'Accept-Language': 'en-US,en;q=0.9', 'Cookie': 'ajs_user_id=35a0ee7e-7d2a-5d24-a424-f28ac6fc19c2; ajs_anonymous_id=6ea4adce-5706-4709-9df6-647004d356d0', 'If-None-Match': '"d0786c813d6e20359ab2efe015766457e23654b1"'}
HTTPResponse(_body=None,_error_is_response_code=True,buffer=<_io.BytesIO object at 0x7fa9d2607bf0>,code=304,effective_url='http://localhost:8501/_stcore/allowed-message-origins',error=HTTP 304: Not Modified,headers=<tornado.httputil.HTTPHeaders object at 0x7fa9d25d1550>,reason='Not Modified',request=<tornado.httpclient.HTTPRequest object at 0x7fa9d25d1310>,request_time=0.0035834312438964844,start_time=1696032241.574165,time_info={})
Server: TornadoServer/6.3.3
Date: Sat, 30 Sep 2023 00:04:01 GMT
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Etag: "d0786c813d6e20359ab2efe015766457e23654b1"
Vary: Accept-Encoding

304
 **** response.error
HTTP 304: Not Modified
{'Connection': 'keep-alive', 'Accept': 'application/json, text/plain, */*', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.43', 'Referer': 'http://SERVER:PORT/intro.py/', 'Accept-Language': 'en-US,en;q=0.9', 'Cookie': 'ajs_user_id=35a0ee7e-7d2a-5d24-a424-f28ac6fc19c2; ajs_anonymous_id=6ea4adce-5706-4709-9df6-647004d356d0', 'If-None-Match': '"7a85f4764bbd6daf1c3545efbbf0f279a6dc0beb"'}
HTTPResponse(_body=None,_error_is_response_code=True,buffer=<_io.BytesIO object at 0x7fa9d2606a20>,code=304,effective_url='http://localhost:8501/_stcore/health',error=HTTP 304: Not Modified,headers=<tornado.httputil.HTTPHeaders object at 0x7fa9d260bb10>,reason='Not Modified',request=<tornado.httpclient.HTTPRequest object at 0x7fa9d25d1950>,request_time=0.004466056823730469,start_time=1696032241.5743368,time_info={})
Server: TornadoServer/6.3.3
Date: Sat, 30 Sep 2023 00:04:01 GMT
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Etag: "7a85f4764bbd6daf1c3545efbbf0f279a6dc0beb"
Vary: Accept-Encoding
rsheftel commented 1 year ago

I have contributed to this repo in the past and agree it was great before Streamlit had built in capabilities for multiple apps. I still think the was this repo did it was better. That said, I don't think the maintainer of this package is doing any more updates.

danlester commented 1 year ago

Thanks for the posts. Yes, I'm not personally focusing on this package because it seems like something that should be offered by Streamlit these days.

But if it's important to anyone, I can accept PRs or hand over the package.

jasonmbray commented 1 year ago

Appreciate the responses. If I figure out a workaround, I'll be happy to share, but it may be beyond me. I don't know if Streamlit will really build in this functionality, since it's kind of what they created their community cloud for. This still seems like the best tool around for what I'm looking to accomplish.

ohjho commented 8 months ago

@jasonmbray I am interested in the workaround if you'd be so kind to share!

jasonmbray commented 8 months ago

Unfortunately, I don't have a full working solution. I think there are maybe multiple changes to streamlit that need to be addressed here. The obvious one that I think I fixed is changing main.py line 126 from

(rf"^/{appname}/stream(.*)", ProxyWSHandler, {'proxy_url': url + 'stream'}, appname + 'ws'),

to

(rf"^/{appname}/_stcore/stream(.*)", ProxyWSHandler, {'proxy_url': url + '_stcore/stream'}, appname + 'ws'),

Feel free to start from there if you think you can figure out the remaining problems (noted above in my original post).