I have an error when trying to deploy a new python app in shiny for the first time. I was following along with the Getting Started docs, but my app won't run. It displays the input fields properly in the browser, but the window says "disconnected" immediately and doesn't show output. If I reload, it again says "disconnected". The error log doesn't show an error message:
2022-10-26T05:03:25.387463+00:00 shinyapps[7422716]: Bootstrapping environment using Python "3.8.13 (default, Sep 27 2022, 22:36:19) [GCC 9.4.0]" at "/srv/connect/venv/bin/python"
2022-10-26T05:03:25.387537+00:00 shinyapps[7422716]: Running as user: shiny
2022-10-26T05:03:25.387553+00:00 shinyapps[7422716]: Running content using the current Python environment
2022-10-26T05:03:25.624885+00:00 shinyapps[7422716]: Running content using Python "3.8.13 (default, Sep 27 2022, 22:36:19) [GCC 9.4.0]" at "/srv/connect/venv/bin/python"
2022-10-26T05:03:25.624923+00:00 shinyapps[7422716]: Loading code from "app"
2022-10-26T05:03:26.819275+00:00 shinyapps[7422716]: App type is "App"
2022-10-26T05:03:26.819310+00:00 shinyapps[7422716]: Starting server...
2022-10-26T05:03:26.819431+00:00 shinyapps[7422716]: /srv/connect/venv/lib/python3.8/site-packages/statsmodels/tsa/base/tsa_model.py:7: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
2022-10-26T05:03:26.819456+00:00 shinyapps[7422716]: from pandas import (to_datetime, Int64Index, DatetimeIndex, Period,
2022-10-26T05:03:26.819463+00:00 shinyapps[7422716]: /srv/connect/venv/lib/python3.8/site-packages/statsmodels/tsa/base/tsa_model.py:7: FutureWarning: pandas.Float64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
2022-10-26T05:03:26.819480+00:00 shinyapps[7422716]: from pandas import (to_datetime, Int64Index, DatetimeIndex, Period,
I added a print statement at the beginning of my output; the print statement doesn't show up in the window or logs, so maybe I have an issue before that. When running from localhost, the console shows one hint:
_send_error_response: name 'render' is not defined
what does that mean? I do have a decorator @render.text
before my function. Here is the entire function:
from shiny import App, ui
import statsmodels.api as sms
# Part 1: ui ----
app_ui = ui.page_fluid(
ui.input_numeric("n1", "N1 (group 1 size):", value=10, max=1000, min=1),
ui.input_numeric("ngood1", "Good1 (group 1 good units):", value=9, max=1000, min=1),
ui.output_text_verbatim("txt")
)
# Part 2: server ----
def server(input, output, session):
@output
@render.text
def txt():
n1 = input.n1()
ngood1 = input.ngood1()
print(n1)
ci_l, ci_u = sms.stats.proportion_confint(ngood1, n1, alpha=0.05, method='agresti_coull')
txt = f"Group 1: {ngood1}/{n1} point estimate {ngood1/n1*100:.1f}% CI95=({ci_l*100:.1f}%,
return txt
# Combine into a shiny app.
# Note that the variable must be "app".
app = App(app_ui, server, debug=True)