shiny & Python
Overview
This app is an initial exploration into
shiny for Python which was
revealed at
rstudio::conf(2022)
earlier this summer.🐍🐍🐍
Aim
The aim of the exploration was to try out the API and
see whether I can recreate common patterns/functionalities
I use in my other apps.
The app is simple: Use the
sample data (or upload your own) to run a basic linear regression
analysis and display the resulting plot.
Functionalities
Here are the functionalities covered in the app:
- ✅ custom CSS (could you tell?) 🤣
- ✅ data processing (file upload and external files)
- ✅ creating reactive objects
- ✅ rendering UI, plots, etc
- ✅ validation with
req()
Deployment
I currently have my app running on shinylive.io which seems to be a
very promising serverless solution. You can also build your app as a
static site (locally) and serve it via github pages or netlify.🤯🤯🤯
👉 View the app served on github pages See Here👈
The one downside is that not all libraries are supported, which is understandable. I originally used the
xport
library to read SAS .xpt
files instead of .csv files in development. Winston Chang’s talk provides more detail about this and the technology in general.Future
If and when this is included (or I figure out the rsconnect deployment, which is also an option by the way), the following code can be replaced easily to read .xptimport xport
def p():
if input.file1() is None:
return "Please upload a csv file"
f: list[FileInfo] = input.file1()
with open(f[0]["datapath"], 'rb') as z:
df = xport.to_dataframe(z)
That’s about it. I plan to do a blog post summarizing the experience further and my thoughts around the news of Rstudio’s “move” into the Python space later.
🍻✌