quarto-ext / shinylive

Quarto extension to embed Shinylive for Python applications
https://quarto-ext.github.io/shinylive/
MIT License
141 stars 8 forks source link

Repeated downloads of the same WASM package #61

Closed pawelru closed 1 week ago

pawelru commented 1 month ago

I have noticed that there are multiple WASM downloads of the same package (of the same version). Is that desirable? Can it be optimised - e.g. cache on the project level?

Just for the record, full log here.

I have multilevel project structure as follows:

book/
├── lvl1/
│   ├── lvl1.1/
│   │   ├── 1-1-1.qmd
│   │   ├── 1-1-2.qmd
│   │   └── ...
│   ├── lvl1.2/
│   │   ├── 1-2-1.qmd
│   │   ├── 1-2-2.qmd
│   │   └── ...
│   └── ...
├── lvl2/
│   ├── lvl2.1/
│   │   ├── 2-1-1.qmd
│   │   ├── 2-1-2.qmd
│   │   └── ...
│   ├── lvl2.2/
│   │   ├── 2-2-1.qmd
│   │   ├── 2-2-2.qmd
│   │   └── ...
│   └── ...
└── ...

Each of the quarto article has a single shinylive-r code chunk.

During the render process, there are multiple .quarto temp dirs created to which there is a separate download process. That means that I am downloading the same package multiple times as well as the whole project consumes a lot of disk space.

After the render it looks more or less like this:

book/
├── lvl1/
│   ├── lvl1.1/
│   │   ├── .quarto/
│   │   │   └── webr/
│   │   │       ├── appdir/
│   │   │       │   └── app.R
│   │   │       └── destdir/
│   │   │           └── shinylive/
│   │   │               └── webr/
│   │   │                   └── packages/
│   │   │                       └── A LOT OF DIRS!!!
│   │   ├── 1-1-1.qmd
│   │   ├── 1-1-2.qmd
│   │   └── ...
│   ├── lvl1.2/
│   │   ├── .quarto/
│   │   │   └── webr/
│   │   │       ├── appdir/
│   │   │       │   └── app.R
│   │   │       └── destdir/
│   │   │           └── shinylive/
│   │   │               └── webr/
│   │   │                   └── packages/
│   │   │                       └── A LOT OF DIRS!!!
│   │   ├── 1-2-1.qmd
│   │   ├── 1-2-2.qmd
│   │   └── ...
│   └── ...
├── lvl2/
│   ├── lvl2.1/
│   │   ├── .quarto/
│   │   │   └── webr/
│   │   │       ├── appdir/
│   │   │       │   └── app.R
│   │   │       └── destdir/
│   │   │           └── shinylive/
│   │   │               └── webr/
│   │   │                   └── packages/
│   │   │                       └── A LOT OF DIRS!!!
│   │   ├── 2-1-1.qmd
│   │   ├── 2-1-2.qmd
│   │   └── ...
│   ├── lvl2.2/
│   │   ├── .quarto/
│   │   │   └── webr/
│   │   │       ├── appdir/
│   │   │       │   └── app.R
│   │   │       └── destdir/
│   │   │           └── shinylive/
│   │   │               └── webr/
│   │   │                   └── packages/
│   │   │                       └── A LOT OF DIRS!!!
│   │   ├── 2-2-1.qmd
│   │   ├── 2-2-2.qmd
│   │   └── ...
│   └── ...
└── ...

Luckily, .quarto dir is gitignored by default so it keeps my git storage safe. My main concern here is the performance.

In my case it was repeated (at least) 14 times:

georgestagg commented 2 weeks ago

Indeed this is not desirable. I would personally consider this a form of bug.

I think this will need to be handled in https://github.com/posit-dev/r-shinylive/blob/main/R/quarto_ext.R, as it is this file that makes the writes to .quarto/....