Shiny for Python app fails to load

Hi,

I try to run a Shiny for Python app on ShinyProxy 2.6.1.

While the Docker container works fine locally (and when run on the server directly as well), I just get a “Container did not respond in time” on ShinyProxy.

The Dockerfile, I use to create the image is

FROM <CUSTOM-BASE-IMAGE>

USER docker
WORKDIR /home/docker 
COPY requirements.txt /home/docker
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
RUN pip3 install gunicorn
COPY . /home/docker
EXPOSE 8080
CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:8080", "-k", "uvicorn.workers.UvicornWorker"]

and the app configuration for ShinyProxy looks like:

  - id: pyshiny-demo
    container-image: <REGISTRY>/shinyproxy-pyshiny-airmass
    port: 8080
    container-env:
      SCRIPT_NAME: "#{proxy.getRuntimeValue('SHINYPROXY_PUBLIC_PATH').replaceFirst('/$','')}"
    target-path: "#{proxy.getRuntimeValue('SHINYPROXY_PUBLIC_PATH')}"

Using uvicorn as recommended in the docs didn’t work either.

Any idea how to debug further?

Hi

We tested Shiny For Python in ShinyProxy and this is working for us. You can see the demo code here: https://github.com/openanalytics/shinyproxy-shiny-for-python-demo .
I think that the main difference with your setup is that we didn’t add the SCRIPT_NAME and target-path settings.

Can you let us know whether your app works with the above demo code?

Thanks for the example, that works fine from e. But unfortunately I get a “Unsupported upgrade request.” from the airmass app still. Other apps working though, so not sure what actually causes that particular issue.
Thanks again for helping!

That’s weird, this app is working fine for me.
I’m using this Dockerfile:

FROM python:3.10

WORKDIR /app

EXPOSE 8080

COPY . .

RUN pip3 install gunicorn
RUN pip3 install -r requirements.in

CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:8080", "-k", "uvicorn.workers.UvicornWorker"]

Note that I had to install the dependencies from the requirements.in file, since it seems a wrong Shiny version is pinned in the requirements.txt file (and python would give an error at startup).

I pushed this image to Docker hub using ledfan/airmass, can you test the following config:

proxy:
  title: Open Analytics Shiny Proxy
  logo-url: https://www.openanalytics.eu/shinyproxy/logo.png
  landing-page: /
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  port: 8080
  authentication: simple
  admin-groups: scientists
  users:
  - name: jack
    password: password
    groups: scientists
  - name: jeff
    password: password
    groups: mathematicians
  specs:
  - id: pyshiny-demo
    container-image: ledfan/airmass
    port: 8080
logging:
  file:
    shinyproxy.log

Finally, I see that this example is downloading a file from the internet, maybe this fails? Can you check the logs of the container when it fails, e.g. using docker ps -a, docker logs -f <id>