Panel app works fine locally but doesn't render template properly when using .servable() on heroku

Hello,

I am running into a really strange bug, when running off my local machine for deploying, I was using .show() and this renders my app perfectly (see below screenshot)

However, I followed the deployment steps for heroku, I removed .show() and replaced it with .servable() and the app successfully builds, but for some reason, the dashboard is completely different. It seems to renders at least part of the template but ignores all content and I have no idea why, literally the only change is from the show to servable.

Does anyone have any idea how to fix this? I feel like I’ve tried every single variation of deployment I can find, adjusting the Procfile, moving .servable() on the end of the template = pn… call, nothing is working

code for the deployed app is here:

Thank you in advance, any help would be fantastic.

1 Like

I’ve still not had any luck with this, does anyone have any ideas? I think it might be a potential bug, or am I missing something?

Have you followed this guide Server Deployment — Panel v0.14.4?

@Hoxbro Hey, thanks for the reply! :slight_smile:

Yes, I followed the instructions to a tee, as you can see the app is deployed Panel Application

but the template just isn’t loading right, you can see the title is loading in one of the broken boxes.

Procfile:

web: panel serve  --address="0.0.0.0" --port=$PORT deploy.py --allow-websocket-origin=stopwatch-tracker.herokuapp.com

It had to use some older versions of Panel and Pydeck to get it running without any errors.

Requirements.txt

numpy==1.24.2
pandas==1.5.3
geopandas==0.12.2
pydeck===0.7.1
panel==0.14.1
panel_highcharts
matplotlib
folium
hvplot
js2py
jupyterlab

This is the error I get when running locally and on heroku when using the latest versions of panel and pydeck.

2023-04-28T13:07:54.705260+00:00 app[web.1]: Traceback (most recent call last):

2023-04-28T13:07:54.705269+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/tornado/web.py", line 1786, in _execute

2023-04-28T13:07:54.705269+00:00 app[web.1]:     result = await result

2023-04-28T13:07:54.705271+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/panel/io/server.py", line 338, in get

2023-04-28T13:07:54.705271+00:00 app[web.1]:     session = await self.get_session()

2023-04-28T13:07:54.705272+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/bokeh/server/views/session_handler.py", line 144, in get_session

2023-04-28T13:07:54.705272+00:00 app[web.1]:     session = await self.application_context.create_session_if_needed(session_id, self.request, token)

2023-04-28T13:07:54.705273+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/bokeh/server/contexts.py", line 243, in create_session_if_needed

2023-04-28T13:07:54.705273+00:00 app[web.1]:     self._application.initialize_document(doc)

2023-04-28T13:07:54.705273+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/panel/io/server.py", line 301, in initialize_document

2023-04-28T13:07:54.705273+00:00 app[web.1]:     template.server_doc(title=template.title, location=True, doc=doc)

2023-04-28T13:07:54.705274+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/panel/template/base.py", line 348, in server_doc

2023-04-28T13:07:54.705274+00:00 app[web.1]:     return self._init_doc(doc, title=title, location=location)

2023-04-28T13:07:54.705275+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/panel/template/base.py", line 575, in _init_doc

2023-04-28T13:07:54.705275+00:00 app[web.1]:     document = super()._init_doc(doc, comm, title, notebook, location)

2023-04-28T13:07:54.705275+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/panel/template/base.py", line 197, in _init_doc

2023-04-28T13:07:54.705275+00:00 app[web.1]:     if self._apply_hooks not in obj._hooks:

2023-04-28T13:07:54.705275+00:00 app[web.1]: AttributeError: 'FastGridTemplate' object has no attribute '_hooks'

Can you try upgrading to panel to 1.14.4?

UPDATE: It should be 0.14.4

Hey, yeah on version 1.14.4, when I initialise any pyplot functions, I get this error. However if I don’t use pyplot it works fine


AttributeError: 'FastGridTemplate' object has no attribute '_hooks'

I think there is some broken functionality between pyplot and the fast grid template in the latest versions of the packages. This error is why I downgraded packages to begin with.

When I use pn.serve(template) I get a blank “Bokeh Application” page, but if I use template.servable() is when I get the server error.

Try to remove functions and dependencies and see what the underlying problem is.

You can also create a new environment and install the packages to see if that works.

Hi @bencowley

Try removing template="fast" from pn.extension("highchart", template="fast", sizing_mode="stretch_width").

You cannot use both template="fast" and then use template =pn.template.Fast...;template.servable().

What happens is that you create one Fast template and then try to add the second template to the first one. This results in Panel visualizing the second template by showing the templates parameters.

I’ve made a Feature Request to raise an exception when a user does this. See Issue #4754

ps. Your app looks awesome. Cannot wait to see it deployed.

1 Like