通过 Heroku 使用面板服务部署 Holoviews 应用程序时,为什么我会收到空白页面?

问题描述 投票:0回答:0

我已将我的 github 存储库连接到 Heroku,并使用它从我的主分支部署一个名为 main.py 的文件。 main.py中的代码如下

# In[29]:


# In[30]:


import pandas as pd
import numpy as np
import panel as pn
import holoviews as hv
import holoviews.plotting.bokeh
from bokeh.models import HoverTool
from holoviews.selection import link_selections
from holoviews import dim, opts

#from holoviews.operation.datashader import datashade, rasterize, shade, dynspread, spread
#import holoviews.operation.datashader as hd



# In[31]:


#Post stats
views_df = pd.read_csv("data/wh1_public_views_imps_8345346.csv")
comments_df = pd.read_csv("data/qrc_8345346_responses.csv")


# In[32]:


#Profile / User stats
profiles_df = pd.read_csv("data/rallypoint_production_profiles_7-19-23.csv")
users_df = pd.read_csv("data/rallypoint_production_users_7-19-23.csv")



# In[36]:


users_df["easting"], users_df["northing"] = hv.Tiles.lon_lat_to_easting_northing(
users_df["longitude"], users_df["latitude"]
)



# In[37]:


#Concat the users and profiles df on user id column

users_profiles_df = users_df.merge(profiles_df, on='user_id', how='left')


# In[38]:


#Filter users_profiles_df to just logged in users who have viewed the post, and then drop duplicate viewers

filtered_users_profiles_df = users_profiles_df.merge(views_df, on='profile_id', how='inner')
filtered_users_profiles_df.drop_duplicates(subset='profile_id', inplace=True, ignore_index=True)


# In[39]:


filtered_users_profiles_df['birth_year'] = filtered_users_profiles_df.birth_year.replace(0, np.nan)

filtered_users_profiles_df.drop(columns=['gender.1', 'marital_status.1'], inplace=True)




# In[40]:


#Dataframe for commenter engagement

comments_filtered_df = users_profiles_df.merge(comments_df, on='profile_id', how='inner')
comments_filtered_df.drop_duplicates(subset='profile_id', inplace=True, ignore_index=True)


# In[41]:


filtered_users_profiles_df['created_at'] = pd.to_datetime(filtered_users_profiles_df.created_at)
filtered_users_profiles_df['created_at_year'] = filtered_users_profiles_df['created_at'].dt.year


# In[42]:


hv.extension('bokeh')

ls = link_selections.instance()

plot_research_dataset = hv.Dataset(filtered_users_profiles_df)

open_street_map = hv.Tiles('https://tile.openstreetmap.org/{Z}/{X}/{Y}.png', name="OSM").opts(width=600, height=550)
points = hv.Points(plot_research_dataset, ['easting', 'northing'], ['birth_year'])

tooltips = [
    ('birth_year', '@birth_year')]

hover = HoverTool(tooltips=tooltips)

data_points = points.opts(opts.Points(tools=[hover], size=5))

#table = hv.Table(plot_research_dataset, ['INSTNM_cleaned', 'keywords'])
branch_histogram = hv.operation.histogram(plot_research_dataset, dimension='branch_id', normed=False)
profile_created_at_histogram = hv.operation.histogram(plot_research_dataset, dimension='created_at_year', normed=False)



#data_map = rasterize(points, x_sampling=1, y_sampling=1, cmap=cc.fire, width=900, height=480).opts(tools=[hover], fontsize=5)


overlay = open_street_map * data_points

show_plot = ls(overlay) + ls(branch_histogram) + ls(profile_created_at_histogram)
#show_plot

pn.panel(show_plot).servable(title='Updated Holovews App')

当我使用“bokehserve --show main.py”在虚拟环境中本地运行相同的文件时,所有内容都会在 http://localhost:5006/main 处按应有的方式呈现。但是当通过 Heroku 提供服务时,我只得到一个空白的白页。当我将鼠标悬停在浏览器选项卡上时收到“更新的 Holoviews 应用程序”文本时,存储库连接正确。由于 Heroku 应用程序日志中没有错误,我猜测这是我的 Holoviews/Bokeh 语句服务于情节的问题,而不是 Heroku 问题。 Heroku应用日志如下:

“2023-08-03T18:17:31.485568+00:00 应用程序[web.1]: 2023-08-03T18:17:31.485568+00:00 应用程序[web.1]: sys.exit(main()) 2023-08-03T18:17:31.487031+00:00 app[web.1]: 2023-08-03 18:17:31,486 启动 Bokeh 服务器版本 3.2.1(在 Tornado 6.3.2 上运行) 2023-08-03T18:17:32.764914+00:00 app[web.1]: 2023-08-03 18:17:32,764 未提供用户身份验证挂钩(默认用户启用) 2023-08-03T18:17:32.770631+00:00 app[web.1]: 2023-08-03 18:17:32,770 Bokeh 应用程序运行于:http://0.0.0.0:55173/main 2023-08-03T18:17:32.770704+00:00 app[web.1]: 2023-08-03 18:17:32,770 启动 Bokeh 服务器,进程 ID:2 2023-08-03T18:17:33.086521+00:00 heroku[web.1]:状态从启动变为启动 2023-08-03T18:17:41.000000+00:00 app[api]: 构建成功 2023-08-03T18:18:48.344006 + 00:00 heroku [路由器]:at =信息方法= GET路径=“/”主机=rp-bokeh-test-baf37200c9e5.herokuapp.com request_id=44007d18-bf9a-494a- 8104-e45e89a8b080 fwd="98.115.41.108" dyno=web.1 连接=0ms 服务=1ms 状态=302 字节=183 协议=https 2023-08-03T18:18:56.350991 + 00:00 heroku [路由器]:at =信息方法= GET路径=“/ main”主机= rp-bokeh-test-baf37200c9e5.herokuapp.com request_id = c137514f-ad1d-42ff -b18b-bf319a69d3ec fwd =“98.115.41.108”dyno = web.1连接= 0ms服务= 7959ms状态= 200字节= 5086协议= https“

任何指导将不胜感激!

干杯,

编辑:上面代码中的“data”文件夹包含存储在 GitHub LFS 中的文件。我知道 LFS 和 Heroku 在其原生状态下不能很好地协同工作。我正在使用 here 找到的 GitHub LFS 构建包。它没有抛出任何错误,所以我认为这不是问题,但我很可能是错的。

python heroku bokeh panel holoviews
© www.soinside.com 2019 - 2024. All rights reserved.