Giter Club home page Giter Club logo

shinylive's Introduction

Shinylive

Code for deploying Shiny applications that will run completely in the browser, using Pyodide and webR (Python and R compiled to WebAssembly).

Prerequisites

Building Shinylive requires NodeJS.

Build instructions

You must first initialize the git submodules. This only needs to be done once:

make submodules

After that, you can simply run make all:

make all

To build and serve the live Python Examples page:

make serve

To build and serve the live R Examples page:

make serve-r

This will also watch the source files in src/ for changes, and will rebuild and auto-reload the web page when the files change.

To build the shinylive.tar.gz distribution file:

make dist

There is also a Quarto web site which demonstrates the shinylive components in different configurations. To build and serve the test Quarto web site with Quarto components:

make quarto
make quartoserve

This will auto-rebuild and reload the Quarto site when a .qmd file in quarto/ changes, but it will not auto-rebuild when the source TS files change.

You may occasionally need to clean out the built artifacts and rebuild:

make clean
make submodules
make all

You can see many of the make targets by just running make:

$ make
submodules             Update git submodules to commits referenced in this repository
submodules-pull        Pull latest changes in git submodules
all                    Build everything _except_ the shinylive.tar.gz distribution file
dist                   Build shinylive distribution .tar.gz file
node_modules           Install node modules
pyodide_packages_local Copy local package wheels to the pyodide directory
buildjs                Build JS resources from src/ dir
buildjs-prod           Build JS resources for production (with minification)
watch                  Build JS resources and watch for changes
serve                  Build JS resources, watch for changes, and serve site
serve-prod             Build JS resources for production, watch for changes, and serve site
buildjs-prod-r         Build JS resources for production with webR as the default engine
serve-prod-r           Build JS resources for production and serve site with webR as the default engine
serve-r                Build JS resources and serve site with webR as the default engine
packages               Build htmltools, shiny, and shinywidgets wheels
update_packages_lock   Update the shinylive_lock.json file, based on shinylive_requirements.json
update_packages_lock_local Update the shinylive_lock.json file, but with local packages only
retrieve_packages      Download packages in shinylive_lock.json from PyPI
update_pyodide_lock_json Update pyodide/pyodide-lock.json to include packages in shinylive_lock.json
create_typeshed_json   Create the typeshed.json file which will be used by the shinylive type checker
copy_pyright           Copy src/pyright files to build directory
api-docs               Build Shiny API docs
quarto                 Build Quarto example site in quarto/
quartoserve            Build Quarto example site and serve
clean-packages         Remove built wheels from the packages/ directory
clean                  Remove all build files
distclean              Remove all build files and venv/
test                   Run tests
test-watch             Run tests and watch

Pulling changes

After pulling changes to the parent repo, you may need to tell it to update submodules.

git pull
make submodules

Adding new packages or updating package versions

The shinylive_lock.json file lists specific versions of packages which will be included in the Shinylive distribution (in addition to the base Pyodide packages). This file is generated from shinylive_requirements.json.

If you add a package to shinylive_requirements.json, or want to update package versions, the lockfile must also be regenerated:

make update_packages_lock

File overview

This an overview of some of the important files and directories in this project.

├── shinylive_requirements.json # List of packages to add on top of standard Pyodide installation.
├── shinylive_lock.json    # Lockfile generated from shinylive_requirements.json.
├── build                  # Generated JS/CSS/wasm components for shinylive (not committed to repo)
├── examples               # Shiny app examples used in Examples browser
├── packages               # Git submodules for htmltools, shiny, and ipyshiny.
│   ├── py-htmltools       #   Used for building wheel files for shinylive.
│   ├── py-shiny
│   └── ipyshiny
├── quarto                 # Sources for an example Quarto site
│   └── docs               # Generated files for Quarto site
├── export_template        # Files used for deployment via `shinylive deploy`
├── scripts
│   └── pyodide_packages.py # Script for downloading PyPI packages and inserting
│                           #   package metadata into pyodide's package.json.
│
├── src                    # TypeScript source files.
├── site                   # Example web site with shinylive, served by `make serve`.
└── _shinylive             # Directory containing files that are deployed to shinylive.io.

shinylive's People

Contributors

wch avatar georgestagg avatar nstrayer avatar jcheng5 avatar cpsievert avatar schloerke avatar gshotwell avatar github-actions[bot] avatar karangattu avatar polkas avatar

Stargazers

Peter Wilkinson avatar Brayden Youngberg avatar Allan Irvine avatar Bob avatar  avatar Jerry Wu avatar Dongho Park avatar Jonathan Barnes avatar João Cavalcante avatar George C. G. Barbosa avatar Gaurav avatar Ayomide Akinwande avatar James Goldie avatar Julien Desclodure avatar Everton Colling avatar Ali Mhdian avatar Max Todaro avatar treecko avatar  avatar ypa y yhm avatar Josh Gonzales avatar Michael Sumner avatar  avatar Kamil Mielczarek avatar Joel Federer-Gsponer avatar Sammi Rosser avatar Miles Smith avatar Jone Keat Lim avatar Gustavo Velásquez avatar Adam Howes avatar  avatar Win Cowger, PhD avatar  avatar Francisco Rodriguez-Sanchez avatar Manuel Girbal avatar Yuta Nishimori avatar Turgut avatar  avatar Ute Hahn avatar Dony Indiarto avatar Xilin Chen avatar Christoph Pahmeyer avatar Steve Huguenin avatar  avatar Philipp avatar Mohammed OE Abdallah avatar Kundan K. Rao avatar liudonghua avatar  avatar Ned Letcher avatar Michael Walshe avatar  avatar Daniel Tan avatar Okiki Ojo avatar JL avatar Johannes Breuer avatar  avatar Pedro Rafael avatar George G. Vega Yon avatar Lesley Duff avatar Yousuf Ali avatar June Young Lee avatar Xianying Tan avatar  avatar Felix MIL avatar Christian avatar Jose Toledo avatar David Granjon avatar Mayank Agrawal avatar Jacci Ziebert avatar Jeffrey Girard avatar Petros Morfiris avatar John Anderson avatar Srikanth K S avatar Daniel Molitor avatar  avatar Lydia King avatar McCrea Cobb avatar Steve Hummel avatar Shivani Srivastava avatar Rishi Yadav avatar Matias Diez avatar Justin Millar avatar Leon Di Stefano avatar luca avatar Greg T. Chism avatar Frederiek - Maarten Kerckhof avatar Kevin Kunzmann avatar Parker Barnes avatar Michael McCarthy avatar  avatar alek avatar MWypych avatar Loukas Theodosiou avatar  avatar MD ZAWHARUL ISLAM avatar Hsincho avatar Nicola Rennie avatar Veerle van Leemput avatar  avatar

Watchers

Andrew Holz avatar  avatar timelyportfolio avatar Neal Richardson avatar Tareef Kawaf avatar  avatar  avatar Garrick Aden-Buie avatar Leon Di Stefano avatar Peter Wilkinson avatar Derrick Kearney avatar Philipp avatar Matt Richard avatar  avatar

shinylive's Issues

ability to write to postgres db?

It seems like we can only get data from api's, is this true? or will shinylive only ever fetch and render?

Would it be possible to send data? ex - a s3 bucket or a hosted postgres db?

It seems like having the ability to send data would make this an amazing and simple webapp framework.

thoughts?

Remove local build of plotnine

After posit-dev/py-shiny#999 was merged into py-shiny, plotnine no longer needed a custom build for shinylive.

However, we are not able right now to use the current release version of plotnine (0.12.4), because it requires matplotlib>=3.6.0, and the version of Pyodide we are currently using includes matplotlib 3.5.2

After updating Pyodide, we will be able to switch to the newer version of plotnine.

Feature Request: Store edited apps in browser storage

It'd be helpful if Shinylive could store the app code in browser storage and making the user apps available in a My Apps menu.

Currently it's very easy to lose work by accidentally navigating away from the page, while many apps don't quite rise to the level of needing to be saved locally. A user scratch area saved locally would serve as a nice middle ground.

Export dependency resolution missing optional dependencies

Have an app that uses pandas which has an optional dependency on Jinja2 for styling the tables.

When exporting this application, the jinja2 dependency is missed unless imported explicitly.

minimal reprex:

# explicit import of jinja2 required for shinylive 0.0.7?
# fails on viewing static site result of shinylive export
# if this import is commented out, fine if import is there
# import jinja2

import pandas as pd
from shiny import ui, App, render

app_ui = ui.page_fluid(
  ui.output_table("table")
)

def server(input, output, session):
  @output
  @render.table
  def table():
    df = pd.DataFrame({"a": [0,1], "b": [0,1]})
    return df
  
app = App(app_ui, server)

Editor not mobile friendly

Currently, the side-by-side editor goes past the edge on narrow displays. (not necessarily a big issue, would be useful to tackle if we expect people to read docs on their phones).

Registering service worker ES module shinylive-sw.js fails behind authentication

I am hosting a shinylive app on self hosted GitHub Enterprise. All HTTP requests to GitHub need to be authenticated. IE a valid session cookie needs to be included with the HTTP request.

Using macOS Chrome Version 113.0.5672.92 (Official Build) (arm64) I have this experience -
The issue is that load-shinylive-sw.js cannot register shinylive-sw.js because the HTTP request forshinylive-sw.js does not include the session cookie.

All other HTTP requests include the session cookie.

I cannot reproduce this on Safari.

webR fails to install packages

I've created a shinylive app using shinylive R package. When running it using either httpuv or another local webserver numerous errors abound. Here all of the R packages fail to be installed.
image

Additionally sometimes the service worker cannot be found. Are there additional npm requirements that we should handle after "exporting" the app?
image

R shinylive: Who can view the app?

When utilising shinylive.io/r to develop an app, the question arises: "Who has access to view the app?" After generating the application URL, it is disseminated exclusively to a chosen group of users. Can it be guaranteed that only these specifically selected individuals have the ability to view the app?

`Example page`: Plotly app fails to render

If you navigate to the Plotly example app over here

Observe the server logs showing the installation of plotly package.
Once the installation is finished, observe the error which stops the app from rendering

>>> Installing plotly ...
Unhandled error: can't start new thread

Drag-to-resize doesn't work with touch-based inputs

Currently the drag-to-resize functionality of the editor is built using mouse events which makes it unusable with touch based interfaces. This should be as simple as replacing things like onMouseDown with onPointerDown etc..

`Example page`: Extra packages app is stuck trying to install listed package

If you navigate to the Extra packages example app over here, you will observe that the server logs stop progressing during the tabulate package.

If you observe the server logs, it will show

Installing isodate ...
Installing attrs==21.4.0 ...
Installing https://files.pythonhosted.org/packages/ca/80/7c0cad11bd99985cfe7c09427ee0b4f9bd6b048bd13d4ffb32c6db237dfb/tabulate-0.8.9-py3-none-any.whl ...

This gives the illusion that the package is still being downloaded, but even after a couple of mins, there is no change in the server logs.

File upload example - python 3.8 - TypeError: 'type' object is not subscriptable

when I ran the https://shinylive.io/py/examples/#file-upload example with python 3.8, noticed below

...
...
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/srv/shiny-server/pyshiny/05_file_upload/app.py", line 64, in <module>
    def group_into_blocks(x: list[str], blocksize: int):
TypeError: 'type' object is not subscriptable

With being not very sure of python typing hints work; Derrick tried changing list[str] to List[str] from https://github.com/rstudio/py-shinylive/blob/main/examples/file_upload/app.py#L64 with an import List and then the example ran as expected.

from typing import List
...
def group_into_blocks(x: List[str], blocksize: int):

It seems like a known issue in general (and may be specifically with python 3.8) while looking at the following online resources

https://www.datasciencelearner.com/typeerror-type-object-is-not-subscriptable-fix/
https://akashmittal.com/type-object-not-subscriptable/

plotly working example?

hi,
I haven't been able to find a good plotly example. could you please provide one?

is it simply a
@output
@render_widget

or do you need to use register_widget()?

app stuck on loading screen when run through Docker image

Hi, I'm trying to run a shinylive app from inside a Docker image but the app doesn't go beyond the honeycomb loading screen. I'm a bit out of my depth here so not sure where the problem lies.

To create the Docker image I followed these instructions (at the bottom). I also tried alternative webservers (nginx, busybox) but that didn't work either. There are no errors in the logging that can help.

I'd appreciate any suggestions or fixes I could try.

Proposal: allow `runApp()` to accept object with `engine`

Currently, when you call runApp() and pass in some files, you do this:

runApp(el, "viewer", { startFiles: files }, "r")

Where files has type Array<FileContent>.

But I think it makes as much sense for the object that's passed to runApp to contain information about which engine to use. Instead of just an array of files, it would also provide info about how to run the app. So the structure would be something like:

type AppSpec = {
  engine: AppEngine,
  files: Array<FileContent>
}

// This could be loaded from JSON
const app = { engine: "r", files = [ ... ] };

runApp(el, "viewer", { appSpec: app })

Unlike some of the other options engine seems inherent to the app; viewerHeight, for example, seems incidental to the app.

Add maplibre package

It would be nice if you could add the maplibre package to the build.
I alread tried to use micropip.install, but there is some conflict.

`shinylive export` should print manifest

To reduce the chances that a user will unwittingly export data or code that should be kept confidential, shinylive export should do the following:

  • Print a list of the files that are being included in the bundle.
  • Print a message saying that anyone who can see the app can also see the contents of these files.

And we can add an option to suppress this message.

Maximum message rate seems to be low

I was testing a new slider component in Shiny for Python and in Shinylive, and I found that I seem to be hitting a limit on how quickly messages can be sent to and from the "server" in Shinylive.

This is a slider with debouncing disabled. My mouse is sending events at (I think) 60Hz. With regular Shiny (not Shinylive), the response is instantaneous:

Screen.Recording.2023-06-14.at.3.38.46.PM-half.mp4

However, on Shinylive, it seems to hit a limit, and the slider seems to be updating at a slower speed than the mouse events, maybe 30Hz.

Screen.Recording.2023-06-14.at.3.39.10.PM-half.mp4

ZoneInfo('UTC') doesn't work

ZoneInfo('UTC') doesn't function.

does this solution that is two weeks old may apply also for shiny-py ?
jupyterlite/xeus-python-demo#7 (comment)

>>> from zoneinfo import ZoneInfo
utc = ZoneInfo('UTC')
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tzdata'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<exec>", line 2, in <module>
  File "/lib/python3.10/zoneinfo/_zoneinfo.py", line 43, in __new__
    instance = cls._weak_cache.setdefault(key, cls._new_instance(key))
  File "/lib/python3.10/zoneinfo/_zoneinfo.py", line 70, in _new_instance
    file_obj = _common.load_tzdata(key)
  File "/lib/python3.10/zoneinfo/_common.py", line 24, in load_tzdata
    raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key UTC'

image

Direct link to Editor or reframe page to default to the editor

It feels weird that the landing page is on "Basic App" example. I don't mind the code but it gives me an odd feeling when I click the button to share the app when on the "Basic App"'s example page.

"Am I sharing the 'Basic App' example?" ... "Or am I sharing my code?" ... "Will my shared code have a title of 'Basic Example'?"

I'd like something (a button) near the top left that is similar to "Open Editor" or "Editor" that takes you directly to https://shinylive.io/py/editor/ . TypeScript has a query parameter for which example is being run, similar to our hash. They're default is a Playground landing page which can populate with known examples. If you click in the url bar, the code content is updated, just like our editor does. By landing on the editor/playground page, it is clearer to me that the goal is to write code and share it, not edit pre-existing examples.

I'd like the interaction to feel closer to "I'm editing app code, not I'm editing the Example". (I don't mind defaulting the base code to be the "Basic App" code... I'd just like to not be editing code that belongs to the "Basic App".)

Related:

cc @gregswinehart

`Example Page`: Pyllusion example app is unable to render due to `Typeerror`

If you navigate to the PyIllusion Example app, once the app is rendered you will observe a 'float' object cannot be interpreted as an integer
Shiny_examples

The server logs show this error

  File "/lib/python3.10/site-packages/pyllusion/Delboeuf/delboeuf_image.py", line 21, in _delboeuf_image
    image = PIL.Image.new("RGB", (width, height), color=background)
  File "/lib/python3.10/site-packages/PIL/Image.py", line 2785, in new
    return im._new(core.fill(mode, size, color))
TypeError: 'float' object cannot be interpreted as an integer

This error is caused because img.to_image (Line 129) does not convert the float object to Integer before returning.

This can be fixed by adding an explicit type conversion as shown below:

return img.to_image(width=int(width), height=int(height))

Consider setting `R_CONFIG_ACTIVE` environment variable to `"shinylive"`

In posit-dev/r-shinylive#45 we briefly discussed adding environment variables to signal that an app is running on shinylive.

In that issue I mentioned considering setting R_CONFIG_ACTIVE, which is used by the config R package and is often used by Shiny apps to choose setting based on context.

Regarding environment variables, another interesting option to consider is setting R_CONFIG_ACTIVE to something like "shinylive" in a shinylive context. This env var is consulted by the config package and is set by Posit Connect.

Cannot use other locales even though changing `LC_TIME`

Hi,

Thank you for this incredible package that will change so many things in the R ecosystem 🤩.

I have a shinylive app running on httpuv::runStaticServer() (and soon on GHpages), which works as intended.

However, the app has a UI in French when run from RStudio, but in English when run from the httpuv server.
Despite my many efforts, I was not able to switch the latter to French.

As a (hopefully) reproducible example, you can add the following code anywhere in the minimal example of shinylive.
I put the output read in the JS console as comments.
Note that I'm running RStudio desktop on Windows 10 on a French computer.

library(lubridate)
print(Sys.getlocale("LC_ALL"))  #"fr_FR.UTF-8"
wday(today(), label=TRUE) |> print()  #Friday
wday(today(), label=TRUE), locale="French" |> print() #Friday

Sys.setlocale("LC_ALL", locale="French_France.1252")
print(Sys.getlocale("LC_ALL")) #"French_France.1252"
wday(today(), label=TRUE) |> print() #Friday

"French_France.1252" is the output of Sys.getlocale("LC_ALL") when run locally in the R console. Of note, "fr_FR.UTF-8" is not recognized as a correct locale in the R console.

Additionally, the different dateInputs are in English, regardless of Sys.setlocale and of Sys.setenv(LANGUAGE="fr").
I get some JS warning from bootstrap (bootstrap-datepicker.min.js:1) that might be related:

Details

DEPRECATED: This filename doesn't follow the convention, use bootstrap-datepicker.en-CA.js instead.
DEPRECATED: The language code "kh" is deprecated and will be removed in 2.0. For Khmer support use "km" instead.
DEPRECATED: The language code "kr" is deprecated and will be removed in 2.0. For korean support use "ko" instead.
DEPRECATED: This language code "rs-latin" is deprecated (invalid serbian language code) and will be removed in 2.0. For Serbian latin support use "sr-latin" instead.
DEPRECATED: This language code "rs" is deprecated (invalid serbian language code) and will be removed in 2.0. For Serbian support use "sr" instead.

I don't get notable errors, except the following, which are already described in other issues and don't seem to cause any trouble

shinylive.js:34938 preload error:wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.
shinylive.js:34938 preload error:falling back to ArrayBuffer instantiation
preload error:Warning in install(dep, repos, info, lib, quiet, mount) :
preload error:  Requested package curl not found in webR binary repo.

Unable to import GDAL module

Hi! On the Shinylive page, it says that gdal should come with the distribution, but I'm unable to import it. When exporting my site, inside the site/shinylive/pyodide folder, there is a gdal-3.5.1.zip file, but I'm not sure if there is something I need to do to access it. I also tried doing it on shinylive.io, but I couldn't do it there either. If there is anything I need to do, please let me know, thank you!
image
image

running help(App) in web python console raises SyntaxError

running the following lines in the web python consoles raises a SyntaxError:

>>> from shiny import App
>>> help(App)
Help on class App in module shiny._app:
class App(builtins.object)
 |  App(ui: Union[htmltools._core.Tag, htmltools._core.TagList], server: Optional[Callable, *, static_asset
s: Union[str, ForwardRef('os.PathLike[str]'), NoneType] = None, debug: bool = False) -> None
 |  
 |  Create a Shiny app instance.
 |  
 |  Parameters
 |  ----------
 |  ui
 |      The UI definition for the app (e.g., a call to :func:`~shiny.ui.page_fluid`
 |      with nested controls).
 |  server
 |      A function which is called once for each session, ensuring that each app is
 |      independent.
 |  static_assets
 |      An absolute directory containing static files to be served by the app.
 |  debug
 |      Whether to enable debug mode.
 |  
 |  Example
 |  -------
 |  
 |  .. code-block:: python
-- more --
 |  
 |      from shiny import *
 |  
 |      app_ui = ui.page_fluid("Hello Shiny!")
 |  
 |      def server(input: Inputs, output: Outputs, session: Session):
 |          pass
 |  
 |      app = App(app_ui, server)
 |  
 |  Methods defined here:
 |  
 |  async __call__(self, scope: MutableMapping[str, Any], receive: Callable], send: Callable, Awaitable[Non
eType]]) -> None
 |      Call self as a function.
 |  
 |  __init__(self, ui: Union[htmltools._core.Tag, htmltools._core.TagList], server: Optional[Callable, *, s
tatic_assets: Union[str, ForwardRef('os.PathLike[str]'), NoneType] = None, debug: bool = False) -> None
 |      Initialize self.  See help(type(self)) for accurate signature.
 |  
 |  async call_pyodide(self, scope: MutableMapping[str, Any], receive: Callable], send: Callable, Awaitable
[NoneType]]) -> None
 |      Communicate with pyodide.
 |      
 |      Warning
 |      -------
 |      This method is not intended for public usage. It's exported for use by
-- more --
 |      shinylive.
 |  
 |  init_starlette_app(self)
 |  
 |  run(self, **kwargs: object) -> None
 |      Run the app.
 |      
 |      Parameters
 |      ----------
 |      kwargs
 |          Keyword arguments passed to :func:`~shiny.run_app`.
 |  
 |  async stop(self) -> None
 |      Stop the app (i.e., close all sessions).
 |      
 |      See Also
 |      --------
 |      ~shiny.Session.close
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
-- more --
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  __annotations__ = {'lib_prefix': <class 'str'>, 'sanitize_error_msg': ...
 |  
 |  lib_prefix = 'lib/'
 |  
 |  sanitize_error_msg = 'An error has occurred. Check your logs or contac...
 |  
 |  sanitize_errors = False
  File "<exec>", line 1
    shiny.session._session.Inputs, shiny.session._session.Outputs, shiny.session._session.Session], NoneTyp
e
                                                                                                 ^
SyntaxError: unmatched ']'
  File "<exec>", line 1
    ], Awaitable[MutableMapping[str, Any
    ^
SyntaxError: unmatched ']'
  File "<exec>", line 1
    MutableMapping[str, Any
                  ^
SyntaxError: '[' was never closed
  File "<exec>", line 1
    shiny.session._session.Inputs, shiny.session._session.Outputs, shiny.session._session.Session], NoneTyp
e
                                                                                                 ^
SyntaxError: unmatched ']'
  File "<exec>", line 1
    ], Awaitable[MutableMapping[str, Any
    ^
SyntaxError: unmatched ']'
  File "<exec>", line 1
    MutableMapping[str, Any
                  ^
SyntaxError: '[' was never closed

py-shinylive_help_app_syntax_error_20220719_1
py-shinylive_help_app_syntax_error_20220719_2

Robj construction for this JS object is not yet supported

I am having trouble starting the app on my local machine. The error message says Error starting the app! Robj construction for this JS object is not yet supported. There is no indication of which js object it is. I have some very standard components in my app, just 2 data tables, 2 plots, 2 action buttons, a download button, and some plain text. What could be the reason of this issue?

Shiny express app with trailing comma shows weird text output

[httpuv] runStaticServer function is not available

I am trying to run the example on the readme, and I got the following error:

httpuv::runStaticServer("site", port=8008)
Error: 'runStaticServer' is not an exported object from 'namespace:httpuv'

It seems that the runStaticServer function does not available on the CRAN (1.6.11) docs or namespace. I tried to install directly from the package Github and got the same error:

packageVersion("httpuv")
[1] ‘1.6.11.9000

Thanks!

Failure to load service worker in Workbench (and possibly in Connect)

I used Workbench to generate a shinylive exported site, and viewed index.html using the Files pane. The request for shinylive-sw.js was redirected to the login page, because no cookies were attached to that request. I found this SO question asking about this behavior, with a clue that it only happens if the registration happens within <script type="module"> (???).

I'm wondering whether this might also be a problem with Connect--I know we've published these to Connect somehow but have we tried it with content permissions set to private?

Should migrate hosting of shinylive.io to AWS

shinylive.io is currently hosted on Netlify, which has a maximum file size of 26MB. With #82, the shiny disk image size is 33MB, which means that we can't deploy it to Netlify. Moving to AWS will solve this.

Shinylive Export does not set window/tab title

After a shinylive export the index.html file does not have the <title> tags set properly. Perhaps there could be an argument to export or otherwise analyzing the ui.page_opts to properly set this?

I can work around this by manually editing the index.html file for now.

Access DOM in Shiny Live

Hi,

I cannot access the DOM document object provided by Pyodide in a Shiny Live example. The code is here.

I created an issue in the Pyodide project asking about this. It seems the reason is that the Shiny Live Python code is running in a Web worker.

May I ask please if there is way, or a plan to create a way, to acess DOM from within ShinyPy? Such a mechansim will have the benefit of enabling a large part of the web components ecosystem for Shiny Live.

Many thanks
Best

Deployment Example Error

I'm using Ubuntu 20.04 and Python 3.8.10.

On Shiny For Python's site (https://shiny.rstudio.com/py/docs/shinylive.html#deploying-shinylive-applications) there is an example for deploying shinylive apps:

shiny create myapp
shiny static myapp site

The second line of code throws an error:

$ shiny static myapp site
Creating directory /home/gordon/.cache/shiny/shinylive
Traceback (most recent call last):
  File "/home/gordon/.local/bin/shiny", line 8, in <module>
    sys.exit(main())
  File "/home/gordon/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/gordon/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/gordon/.local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/gordon/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gordon/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/gordon/.local/lib/python3.8/site-packages/shiny/_main.py", line 393, in static
    _static.deploy_static(
  File "/home/gordon/.local/lib/python3.8/site-packages/shiny/_static.py", line 55, in deploy_static
    shinylive_bundle_dir = _ensure_shinylive_local(version=version)
  File "/home/gordon/.local/lib/python3.8/site-packages/shiny/_static.py", line 270, in _ensure_shinylive_local
    destdir.mkdir()
  File "/usr/lib/python3.8/pathlib.py", line 1288, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/gordon/.cache/shiny/shinylive'

External files or multifile app does not work

Hi. Just started testing shinylive and I have a quick question. I need either a small json file for my app.py or an external module (not pip install just a local wordlist.py file). When I wanted to use shinylive for my app (and files) inside app/ folder and I want to export the outputs to docs/ folder. I use the following command.

shinylive export app docs

When I serve it on the localhost with python3 -m http.server --directory docs --bind localhost 8008 I get the following result.

Screenshot 2023-11-13 at 14 36 09

I know it can be done due to this example: https://shinylive.io/py/examples/#regularization

Perhaps I missed a documentation for multi-file shinylive apps. I can do a workaround with a bloated app.py but knowing how to work with multiple files will be incredible.

Thanks for such an awesome package. It will get better and better I presume.

how to make plotnine work ? (if ever possible)

how can I "redirect" Matplotlib so plotnine do work ?

import pandas as pd
import numpy as np

from plotnine import *

df = pd.DataFrame({
    'variable': ['gender', 'gender', 'age', 'age', 'age', 'income', 'income', 'income', 'income'],
    'category': ['Female', 'Male', '1-24', '25-54', '55+', 'Lo', 'Lo-Med', 'Med', 'High'],
    'value': [60, 40, 50, 30, 20, 10, 25, 25, 40],
})
df['variable'] = pd.Categorical(df['variable'], categories=['gender', 'age', 'income'])
df['category'] = pd.Categorical(df['category'], categories=df['category'])

 (ggplot(df, aes(x='variable', y='value', fill='category'))
 + geom_col()
)

gives this


/lib/python3.10/site-packages/plotnine/ggplot.py:862: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
<ggplot: (-2141397610)>
>>> /lib/python3.10/site-packages/plotnine/ggplot.py:862: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

Strange behavior in editor - adding/deleting extra characters, flagging

With the editor in Shinylive for Python, in some cases it will add or delete extra characters, or show text that isn't really there.

In the video below, there is some code that has very weird syntax -- it calls a function using a named argument before using the spread operator on a list. In the recording, I try to move the cursor one step at at a time, and then add commas and delete them one at a time. Then when I move the cursor, it shows some of the text duplicated, and then it goes away.

shinylive-weird-compressed.mp4
def f(a, *args, z):
    return [*args, z]


f(z=2, *[2, 3])

Live example

I am pretty sure this is due Pyright: if I add # type: ignore to the end of that line, then the weird behavior stops.

I think it's also because we are using a very old version of Pyright. I have not been able to reproduce this in VS Code with recent versions of Pylance.

run-python-blocks.ts doesn't recognize code blocks in Reveal.js

Here's what code blocks look like in format: html:

<pre class="shinylive-r" data-engine="r"><code>#| standalone: true

Here's what code blocks look like in `format: revealjs':

<div class="sourceCode" id="cb1" data-engine="r"><pre class="sourceCode numberSource shinylive-r number-lines code-with-copy"><code class="sourceCode"><span id="cb1-1"><a href="#cb1-1"></a>#| standalone: true</span>

Relevant code: https://github.com/posit-dev/shinylive/blob/ff9d728298e1bf570418267fe1d91cc1b58dfc2e/src/run-python-blocks.ts#L13C1-L20

editor-cell layout appears to be broken

Here is an example code cell in a quarto document:

```{shinylive-python}
#| components: [editor, cell]

from shiny import ui
ui.div("Hello!")
```

It should display the text representation of the object, but it isn't working. It looks like this:

image

This is on this page: https://pr-156--pyshiny.netlify.app/docs/ui-html.html

You should also be able to put in something like 1+1 and it will print the result, but it doesn't do that either.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.