posit-dev / py-shiny

Shiny for Python
https://shiny.posit.co/py/
MIT License
1.16k stars 69 forks source link

Add `shiny deploy` to CLI #521

Open nealrichardson opened 1 year ago

nealrichardson commented 1 year ago

I made a fun little app that I want to share. I want shiny deploy my-app to just work. Something along the lines of quarto publish. I'd like to have the complexity of configuring rsconnect-python, connecting to shinyapps.io or Posit Connect, or even bundling and pushing to shinylive to be handled for me as much as possible.

gshotwell commented 1 year ago

I liked that idea, I'm a bit worried about recommending multiple deployment workflows. We do need to keep the rsconnect one because that's how people deploy other python applications to Posit Connect and Cloud. Can you say more about the complexity you found with rsconnect, maybe we can improve that package and have shiny deploy just be a pass through.

nealrichardson commented 1 year ago

Right, I think shiny deploy would wrap rsconnect-python to deploy to the targets that use it.

Can you say more about the complexity you found with rsconnect

I started reading the docs and gave up without trying. Not to say that I won't give it a try later--I'm just wearing my impatient new user hat on, and when I run into friction, I take it as a sign that we need to reduce friction.

wch commented 1 year ago

If it's a little app, you can use the shinylive share button, which encodes the app in a URL:

image

But there are limitations to this, in terms of what kinds of apps will work on shinylive.

Regarding deployment, I agree that it would be great to have super easy app deployment -- I think rsconnect can be a bit much for new users to figure out.

nealrichardson commented 1 year ago

@wch that's nice, but that only works if I'm already at shinylive.io developing. Suppose shiny deploy shinylive would generate that link? (is it just b64encoding the app file(s)?)

wch commented 1 year ago

@nealrichardson I can imagine a workflow like this:

Or, without VS Code:

Other commands for shinylive could be:

I'm writing this as though these would use the shinylive command from the Python shinylive package. I think it conceptually makes sense to have the command be there, but on the other hand, that's one more thing the user would have to install, and if it were instead a shiny command, that would remove one step that the user would need to do.


I think the CLI command is a good idea, but one more thing that might be useful for you now: the shinylive.io editor page has a button to load all files from a directory on disk (works in Chrome only, I think).

wch commented 1 year ago

The URL encoding is pretty simple. It uses the JS lz-string library to encode a simple data structure. This is where it does the encoding: https://github.com/rstudio/shinylive/blob/a2e4accd496e1db3908ddebedef493a6e4556c84/src/Components/share.ts#L7-L21

And this is the data structure: https://github.com/rstudio/shinylive/blob/a2e4accd496e1db3908ddebedef493a6e4556c84/src/Components/filecontent.ts#L12-L24

nealrichardson commented 1 year ago

I'm writing this as though these would use the shinylive command from the Python shinylive package. I think it conceptually makes sense to have the command be there, but on the other hand, that's one more thing the user would have to install

We could put it in shinylive, have shiny depend on shinylive (or does that create a circular dependency problem?), and have shiny deploy shinylive call out to shinylive to render?

gadenbuie commented 2 months ago

Two recent updates regarding moving from local files to shinylive apps:

  1. shinylive now supports "deploying" an app to shinylive.io by creating a shinylive.io URL from local files. The command is shinylive url encode.
  2. The Shiny VS Code extension also supports deploying to shinylive with two commands
    1. For single-file apps, e.g. app.py or app.R, run the Create ShinyLive Link from Active File from the command palette with the app file open and active.
    2. For multi-file apps, select all of the files or directories in the Explorer pane that you want to include in your Shinylive app. Then right click on the selection and choose Create ShinyLive Link from Selected Files.

Both also allow you to go from shinylive URL to local files via shinylive url decode or the Save App from Shinylive Link in the VS Code extension.