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

No passing R and Python object within reticulate session in Positron #5210

Open
Tracked by #4961
ntluong95 opened this issue Oct 30, 2024 · 4 comments
Open
Tracked by #4961
Assignees
Labels
area: reticulate Issues related to the reticulate extension bug Something isn't working

Comments

@ntluong95
Copy link

System details:

Positron and OS details:

Positron Version: 2024.11.0 (system setup) build 116
Code - OSS Version: 1.93.0
Commit: 8b1688a
Date: 2024-10-28T02:47:45.218Z
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22621

Interpreter details:

R 4.3.2
Python 3.12.4

Describe the issue:

It is unable to access R object through r.object syntax and python object through py$object syntax in Positron

Steps to reproduce the issue:

  1. Create a new quarto document
  2. Create a venv through uv package or whatever way
uv init --python 3.12.4
uv add ipykernel
uv add pyarrow
  1. Run the following code
library(arrow)
library(reticulate)
use_virtualenv(here::here(".venv"))
repl_python()
import pyarrow as pa
set.seed(1234)
nrows <- 10^4
df_random <- data.frame(
  x = rnorm(nrows), 
  y = rnorm(nrows),
  subset = sample(10, nrows, replace = TRUE)
)
tb_random <- arrow_table(df_random)
df_py <- r_to_py(df_random)
tb_py <- r_to_py(tb_random)
r.df_py

r.tb_py 

Expected or desired behavior:

Be able to access the dataframe

Were there any error messages in the UI, Output panel, or Developer Tools console?

Actual output
Image

The object was converted and showed in Environment Pane
Image

Image

@dfalbel dfalbel added area: reticulate Issues related to the reticulate extension bug Something isn't working labels Oct 30, 2024
@dfalbel
Copy link
Contributor

dfalbel commented Oct 30, 2024

Thank you for reporting!

This should have been fixed with rstudio/reticulate#1681
Can you try installing the dev version of reticulate and see if the issue persists?

@ntluong95
Copy link
Author

I have tried and confirmed that it solved the problem.
But I don't know why sometimes I can import pyarrow, sometimes I can't. Not sure if anything need to be done with reticulate or python

Image

@juliasilge
Copy link
Contributor

juliasilge commented Oct 30, 2024

@dfalbel Should Positron check for the reticulate R package version? We do this in the R extension like so:

const isInstalled = await checkInstalled('renv', MINIMUM_RENV_VERSION);

@dfalbel
Copy link
Contributor

dfalbel commented Oct 30, 2024

We do check for a minimum reticulate version here:

if (!await rSession.callMethod?.('is_installed', 'reticulate', '1.39')) {
// Offer to install reticulate

But still didn't bump it up to fix this specific bug because the new release is not on CRAN yet.

@dfalbel dfalbel self-assigned this Oct 30, 2024
@petetronic petetronic added this to the Release Candidate milestone Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: reticulate Issues related to the reticulate extension bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants