REditorSupport / REditorSupport/vscode-R

Session watcher not respecting reticulate delayed load, and other issues

Open
#1,466 3 comments 0 reactions 1 assignee View on GitHub

@ElianHugh is already working on this.

Since Mar 2, 2024.

bug
Dominant language
TypeScript
Stars
1.2k
Forks
139
Avg merge
2h 46m
Merged PRs (30d)
5

Description

There seems to be some weirdness happening with reticulate when working with the VSCode-R extension. It looks like VSCode-R is evaluating the reticulate/Python code in a different way than the standard R GUI console. The obvious example when using the delay_load flag when importing modules:

standard R GUI Console
library(reticulate)
start = Sys.time()
re <- import("re", delay_load = TRUE)
end = Sys.time()
end - start
#> Time difference of 0.01495004 secs
re
#> <pointer: 0x0>  # the module has not been loaded yet because delay_load = TRUE

start = Sys.time()
re$match  # trigger loading of module
#> <function match at 0x000002EA31AE8B80>
end = Sys.time()
end - start
#> Time difference of 12.2005 secs
VSCode-R Console
library(reticulate)
start = Sys.time()
re <- import("re", delay_load = TRUE)
end = Sys.time()
end - start
#> Time difference of 12.08285 secs
re
#> Module(re)  # module has been loaded

start = Sys.time()
re$match  # trigger loading of module
#> <function match at 0x000001C7AD980AF0>
end = Sys.time()
end - start
#> Time difference of 0.03116894 secs  # fast because module was already loaded

I have also been encountering cases where reticulate will throw Python errors in VSCode but not in the R GUI, and will continuously re-throw the error with every new command. However, I do not yet have a reprex for this (it most commonly occurs with the arcpy module, which is not available unless you have an ArcGIS Pro license). I'll post again here if I can reproduce the issue with a publicly-available module.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.