In my script, I have a callback connected to two dropdowns, a button, and a dcc.Download object. Everything works perfectly locally. I can choose and download all four of the different file options (xlsx, csv, parquet, and a px.scatter_geo figure html).
But when I run the script online, I am only able to successfully download the xlsx and csv files, but not the parquet or px.scatter_geo figure html. When I click the button, I can see the browser loading like it does for the other two files, but then nothing happens. There are no error messages, and the application does not fail or crash at any point.
Here is a simplified version of the callback:
@app.callback(
Output("download_file", "data"),
[
State('s_drop','value'),
State('download_type_drop','value'),
],
Input("download_button", "n_clicks"),
prevent_initial_call=True,
)
def downloader(s_drop, download_type_drop, n_clicks):
df_f = df_o1.copy()
if s_drop:
df_d = df_f[df_f['s'] == s_drop]
else:
df_d = pandas.DataFrame(dict(A='none selected'), index=[0])
if n_clicks == 0 :
raise PreventUpdate
else:
if download_type_drop == 'csv': return dcc.send_data_frame(df_d.to_csv, str(s_drop) + "_data.csv")
if download_type_drop == 'xlsx': return dcc.send_data_frame(df_d.to_excel, str(s_drop) + "_data.xlsx")
if download_type_drop == 'parquet': return dcc.send_data_frame(df_d.to_parquet, str(s_drop) + "_data.parquet")
if download_type_drop == 'geo_scatter':
if not s_drop:
raise PreventUpdate
else:
fig = px.scatter_geo(df_d, lat = 'latitudeofdtc', lon = 'longitudeofdtc')
with open(cwd + r'\states_geojson.json') as i:
states_geojson = json.load(i)
fig = fig.add_trace(
go.Scattergeo(
lat=[v for sub in [np.array(f["geometry"]["coordinates"])[:, 1].tolist() + [None]
for f in states_geojson["features"]] for v in sub],
lon=[v for sub in [np.array(f["geometry"]["coordinates"])[:, 0].tolist() + [None]
for f in states_geojson["features"]] for v in sub],
line_color="black",
line_width=1,
mode="lines",
showlegend=False,
hoverinfo='skip'
)
)
return dict(content=fig.to_html(), filename=str(s_drop) + "_geo_scatter.html")
if not download_type_drop: raise PreventUpdate
I’m not sure what the problem could be, since it works perfect locally, and since the xlsx and csv files can be downloaded online without issue. Any help would be appreciated.
Thanks