-
Notifications
You must be signed in to change notification settings - Fork 1
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
Use configured R in Positron #2126
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This did not work for me.
I got setup using rig
and have R version 4.3.1
(already installed pre rig
setup) and then installed 4.4.1
with rig
.
I installed the VSIX
built from this branch into Positron and it always used 4.3.1.
regardless of the R interpreter I had selected. Perhaps I'm missing something about how I should have this setup but:
- I did not see configurations created with the differing versions of R
- I did not see the R version change in the Posit Publisher output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't verified, but it looks like Jordan hit a problem there.
The code itself looks good, just a file naming request.
I reproduced what Jordan had seen.
I see this error:
I can also encounter the error when I create a new deployment...
|
This can happen if runtimes are still being discovered:
So we may need to hold off availability of some features until we know the R interpreter. |
Summary of what I saw with changes:
In all cases, the output log seems to indicate that we are executing the proper version of R: for R 4.3.3:
for R 4.4.1:
After chatting with Mike, this appears to be the expected behavior.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest code looks good and with it, the functionality is working as we expect it to.
Is the expectation that the R version in our Configuration would match the selected R version in Positron if there is no If that is the expectation that isn't what I'm seeing with the current build on this PR. Just double checking. |
Agreed with @dotNomad, I've verified what he's reporting. Inspection seems to be invoked with the correct version, but the config doesn't get that version
Looks like the correct R version isn't being passed in accurately (it has changed back to the other version) within the PUT configuration API:
|
This PR is on hold as we determine what we're going to do on the open questions - updated title. |
Here is the behavior that I'm expecting. @jonkeane can you validate them as reasonable expectations from an R Data Scientist? When using Positron and selecting a specific R Version from multiple installed:
When using VSCode or Positron with only one R version (basically R is located on path):
Notes:
For functionality verification, we'll need to verify |
The latest commits on this branch are ready for review (previous commits were already reviewed), and the branch is ready for re-verification. Commits: |
To support the decisions needed, I have documented an overview of which language interpreters are used when inspecting, package scanning, or deploying content within the current publisher code base. For R:
For Python:
For Quarto:
Observations:
|
After documenting the version usage, I now feel we should move forward with this PR as it is the first step of multiples which will respect the user's working environment within Positron. Most of the code was written by @mmarchetti, with some minor bug fixes added with my updates. @marcosnav Can you please take a look at this PR? |
@sagerb The bats test issue in this PR is different from the one on the Nightly runs. Seems this one requires a minor update to an expected error message. |
// Small number of retries, because getPreferredRuntime | ||
// has its own internal retry logic. | ||
const retries = 3; | ||
const retryInterval = 1000; | ||
|
||
for (let i = 0; i < retries + 1; i++) { | ||
try { | ||
runtime = await api.runtime.getPreferredRuntime("r"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, if getPreferredRuntime
has it's own retry logic, is it worth having that extra check again here? In which cases could it fail and then succeed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure of Mike's intentions. I'll take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getPreferredRuntime
is an API that executes within Positron. They retry to handle queries during the initialization of Positron when the info is not yet available. Our testing showed that our query to them required additional retries to be reliable, so Mike added additional ones.
I'm checking with Mike for further clarification, but currently I don't think any change is required here.
@@ -0,0 +1,109 @@ | |||
// Copyright (C) 2024 by Posit Software, PBC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to pushing on having more tests on the extension code, this file contains a few methods for which it is worth having tests for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be adding tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I investigated implementing vitests
for this utility, using a few different techniques, but all were unsuccessful. Attempts to run the tests failed as they attempted to resolve the vscode
imports, in which they could not resolve the type definition into an import.
We also discussed the two techniques I investigated (mocking the extension runtime environment and injection pattern for removing the extension runtime dependencies). We concluded that going this route would be very costly to mock the entire runtime environment of VSCode extension and do it correctly where it would accurately represent the actual runtime environment.
Instead, we quickly looked back at the guidelines provided by Microsoft on how to best test the extensions. (https://code.visualstudio.com/api/working-with-extensions/testing-extension).
We already have the Extension Test Runner setup in our project, with one simple test. It is executed with npm run test
. While there are some changes that we'll probably want to make (like switching from mocha
to jest
), this appears to follow the best practices for testing functionality within the extension's runtime environment.
I propose that we go in this direction and that it is outside of the scope of this PR. I'd recommend we move forward with this PR, merge it, and then implement some simple tests for the detection of the preferred R and Python versions using the extension test runner.
@dotNomad I think this summarizes our discussion?
@marcosnav Let's discuss at our next opportunity, if you have any questions or concerns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the @vscode/test-*
utilities sound great, I do think we should definitely use that and it would be great to have more test running on it. At the same time, that is one element to have a full circle in a testing strategy, more on the side of integration testing. Having to run a VSCode instance to test a single function feels a bit off.
This is definitely worth a future discussion. I'm ok on making these efforts outside of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great write up @sagerb thanks for putting that down in a comment.
Intent
This PR implements an
r
parameter in the inspection, R package scanning, and publishing APIs, similar to the existingpython
parameter, that allows the extension to specify which R interpreter to use. The extension detects the active R interpreter in Positron, if available, and passes that in. The default/fallback is the current behavior of running R from PATH.Fixes #1968
Type of Change
Automated Tests
Existing tests have been updated.
Directions for Reviewers
Inspect projects, scan for R packages, and deploy R projects from VSCode and Positron. Install multiple versions of R for Positron (I used
rig
).Checklist