-
Notifications
You must be signed in to change notification settings - Fork 83
Deploying on Connect
Currently, it's possible though slightly tricky to deploy on Connect. Neither Connect nor rsconnect-python are specifically designed to host PyShiny apps yet, but due to PyShiny being built as a Starlette extension, you can use the "fastapi" publishing option. This doesn't give us SockJS or reconnecting and may not even have sticky enough load balancing for some features, but it's a start.
A second complication is the fact that our packages are not yet on PyPI. We currently work around this by hosting wheel files on GitHub Pages (see the section on requirements.txt below).
If you don't already have the rsconnect
command line tool installed:
pip3 install rsconnect-python
Assuming you have publishing rights on an RStudio Connect instance, log into that instance and create an API key (instructions). Copy the newly created API key to the clipboard.
From the terminal, register the Connect server and your account by running:
rsconnect add -n <server-nickname> -s <server-url> -k <api-key>
For example, I might run the following to register connect.rstudioservices.com under the nickname "rstudioservices":
rsconnect add -n rstudioservices -s https://connect.rstudioservices.com/ -k <api-key>
Next to your app.py, include a requirements.txt that might look something like (this isn't optimal but it seems to work):
https://rstudio.github.io/prism/shiny-0.0.0.9000-py2.py3-none-any.whl
https://rstudio.github.io/prism/htmltools-0.0.1-py3-none-any.whl
packaging
uvicorn==0.14.0
matplotlib==3.4.2
fastapi==0.70.0
contextvars==2.4
websockets==10.0
typing_extensions==4.0.1
python-multipart
To actually deploy the app, cd
to the app directory and run:
rsconnect deploy fastapi . --entrypoint app:app
(You may or may not need to add -n <server-nickname
to the above to successfully publish)