rstudio / pins-r

Pin, Discover and Share Resources
https://pins.rstudio.com
Other
301 stars 62 forks source link

Connect preview html: include Python code too? #796

Closed nealrichardson closed 7 months ago

nealrichardson commented 8 months ago

If you make a pin with the R package, you get https://github.com/rstudio/pins-r/blob/main/inst/preview/index.html created with it, which tells the Connect user how to load the data. But it only has R code there, even though you can totally use pins-python to read it (right?)

It would be nice if the code example was tabbed and had Python and R example code. (Assuming you agree, there should also be the same done to pins-python, https://github.com/rstudio/pins-python/blob/main/pins/rsconnect/html/index.html is Python only).

juliasilge commented 8 months ago

Yeah, thanks for bringing this back up; you absolutely can roundtrip a pin through R and Python, as long as you use a file format that is amenable (i.e. not RDS, not joblib, etc).

We did talk about this when we first started the Python package. The main challenge, as I remember it, is running the Python board_deparse() from R and vice versa. Right now, it is pretty simple. Here is what Python would need to do for R:

https://github.com/rstudio/pins-r/blob/f6c6f50969e0ab9be091c838075cd619570f70b3/R/board_connect.R#L365-L367

but we are tracking changes that need to be made in #726. Also doesn't look so bad for what R would need to do for Python.

We had other concerns at the time about trying to stay consistent with different versions of the R and Python packages but I am not so worried about that now, as that basic read/write interface is pretty solid. Also, we would need to check the metadata before generating the HTML to know if this file can be read from the other language.

juliasilge commented 7 months ago

We've got this implemented in the R package now and I have opened up rstudio/pins-python#222 to get it done in Python.

juliasilge commented 7 months ago

This is now merged into both the Python and R packages and will be in the next releases of each. Thanks again for surfacing this @nealrichardson! 🙌

github-actions[bot] commented 7 months ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.