Bioconductor / AnVILPublish

https://bioconductor.org/packages/AnVILPublish
0 stars 6 forks source link

propagate static images used by vignettes? #7

Open vjcitn opened 2 years ago

vjcitn commented 2 years ago

I have a vignette in a package that uses

![](images/bodymap.jpg)

to include a graphic. I used the terra "files", "upload" process to create folder "images", and upload the jpg. Now AnVIL::avfiles_ls() shows that the images folder is resident with the .ipynb files. In the running notebook,

library(AnVIL)
avfiles_ls("notebooks/images")

shows the .jpg file is present. I used avfiles_restore() within the notebook to bring the images/bodymap.jpg into the filesystem visible to the notebook, and the notebook then incorporated the .jpg file.

Is there a convention that should be used so that AnVILPublish will propagate static images? pkgdown will make use of files in man/figures, or in vignettes.

mtmorgan commented 2 years ago

If I understand, your package had vignettes/images/bodymap.jpg.

It sounds like you'd copied the images to the workspace bucket under gs://<bucket>/notebooks/images/bodymap.jpg.

It sounds like there is still another step, requiring that the image be localized to the runtime for it to be displayed in the notebook. I think you did something like avfiles_restore("notebooks/images", getwd(), recursive = TRUE), where getwd() returns "notebooks/"? So there is still an additional step required?

What happens when one 'previews' the notebook? I guess the images do not show up...

vjcitn commented 2 years ago

Yes, vignettes/images/bodymap.jpg

Yes, avfiles_restore was used as described; interestingly in playground mode the image does not display, but when the notebook environment is restarted it displays. That's the answer to your "preview" question, I think.

The man/figures convention is just for pkgdown and I think we can ignore that. It seems that in a galaxy interactive tool deployment the image files are assumed to be in ./images relative to the .ipynb

I have not tried type="both", need to look at that. I shared https://anvil.terra.bio/#workspaces/use-strides/Bioconductor-Package-YESCDS/notebooks and the source repo is https://github.com/vjcitn/YESCDS

mtmorgan commented 2 years ago

Kayla and I have investigated two approaches.

The first is to copy the images to the workspace bucket. The images then need to be localized, manually, to the correct location on the persistent disk (a simple one-liner when the appropriate avfiles_restore() command is known; this could be included as the first command in a notebook). Theimages then appear in the jupyter notebook or Rnw in Rstudio. They do not appear in the 'preview', and images in the README.md (with as_workspace(..., use_readme = TRUE) are not updated.

The second is to base64 encode the image in a <img src=...> tag in the markdown document; this is similar to how rmarkdown creates a stand-alone HTML file. The images then appear in the jupyter preview as well as notebook, and in RStudio. Images in the README.md elicit an error from Terra about "Data truncation: Data too long for column 'value_string'" -- I guess there is a maximum size for the dashboard.

Perhaps really the best way forward is to change local references ![coggle map](man/figures/YESCDS_map.png) to online references to the version-controlled image ![coggle map](https://github.com/vjcitn/YESCDS/blob/main/man/figures/YESCDS_map.png)? I think the prefix for Bioconductor packages would be https://code.bioconductor.org/browse/{{{package}}}/blob/{{{branch}}}