Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect preview html: include Python code too? #796

Closed
nealrichardson opened this issue Oct 29, 2023 · 4 comments
Closed

Connect preview html: include Python code too? #796

nealrichardson opened this issue Oct 29, 2023 · 4 comments
Labels
feature a feature request or enhancement

Comments

@nealrichardson
Copy link

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
Copy link
Member

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:

pins-r/R/board_connect.R

Lines 365 to 367 in f6c6f50

board_deparse.pins_board_connect <- function(board, ...) {
expr(board_connect(auth = "envvar"))
}

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 juliasilge added the feature a feature request or enhancement label Nov 3, 2023
@juliasilge
Copy link
Member

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
Copy link
Member

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! 🙌

Copy link

github-actions bot commented Dec 5, 2023

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.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants