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

Provide "Select Interpreter" for R (similar to Python) #5223

Open
Tracked by #3541
juliasilge opened this issue Oct 30, 2024 · 7 comments
Open
Tracked by #3541

Provide "Select Interpreter" for R (similar to Python) #5223

juliasilge opened this issue Oct 30, 2024 · 7 comments
Assignees
Labels
area: runtimes Issues related to Language Runtimes enhancement New feature or request lang: r

Comments

@juliasilge
Copy link
Contributor

The Python extension has a nice "Select Interpreter" UI experience with a quick pick, and in some situations, it is more useful and nicer than Positron's interpreter dropdown:

Image

It is easier to see the paths, you can search, you can refresh, etc.

Let's create the equivalent experience for R interpreters as a first step. In the longer term, we may want to reconsider what each of these affordances are best suited for.

@ntluong95
Copy link

Is this also including virtual environment created by renv?

@jennybc
Copy link
Member

jennybc commented Nov 4, 2024

In my head, the renv matter is filed in a slightly different folder. I think we should be able to discover the use of renv and act more appropriately. So that feels related, but no, not exactly what this issue is about. (I don't see an issue that really captures the renv case crisply, so perhaps I should do something about that.)

@juliasilge juliasilge added this to the 2025.02.0 Pre-Release milestone Nov 4, 2024
@jennybc
Copy link
Member

jennybc commented Nov 4, 2024

In today's R meeting, I got folks to discuss the "why" of bringing the Python "Select interpreter" experience over to R. Because the facts on the ground tend to be very different, i.e. we aren't crawling the file system looking for R installations or environments.

Some of what such an interface can deliver:

  • Search, e.g. on part of the path
  • Refresh = cause discovery to happen again
  • See the whole path. The current interpreter dropdown can make it hard to tell which one you want. User often can't see a disambiguating part.
  • Organization into sections that reveals what sort of installation it is, how it was discovered, etc. This could have an interesting connection to Better UX for unsupported R versions #1397, i.e. discovered-but-unsupported versions could be presented in their own section

jennybc added a commit that referenced this issue Dec 10, 2024
…5648)

Addresses #1397 
Addresses #5220 
Continued preparation for #5223

A lot of the changes are very internal, but there are also user-facing
improvements:

* Even more effort to track the reasons (plural) why we've discovered an
R installation and, perhaps, the reason an R installation can't be used
with Positron. The richer information appears in the Positron R
Extension output channel.
* If we discover at least one R installations, but there is no usable R
installation, we put a pop-up warning. The exact details of this will be
good to discuss in the next R meeting.

### QA Notes

To experience this, you need to have at least 1 unusable R installation
around and 0 usable ones.

For rig-installed R, use `rig rm release` (or similar) to remove an R
installation. Repeat as necessary, until all usable R is gone!

Older R installers are here for macOS arm64:
https://cran.rstudio.com/bin/macosx/big-sur-arm64/base/. This makes it
easy to get R 4.1, for example, which is below our minimum supported
version.

You should see a modal telling you that all R installations are
unusable, allowing you to look at the Positron R Extension output
channel or dismiss.

---------

Signed-off-by: Jennifer (Jenny) Bryan <[email protected]>
Co-authored-by: Chris Mead <[email protected]>
Co-authored-by: Julia Silge <[email protected]>
@sharon-wang sharon-wang added the area: runtimes Issues related to Language Runtimes label Jan 20, 2025
@juliasilge
Copy link
Contributor Author

Turns out that we mostly already have this:

Image

We do this by bouncing the command back to Positron itself:

vscode.commands.registerCommand('r.selectInterpreter', async () => {
await vscode.commands.executeCommand('workbench.action.languageRuntime.select', 'r');
}),

Search works ✅ and you can see the whole path ✅

Still TODO:

  • Add an icon to refresh discovery to the existing quickpick
  • Can we provide any helpful organization with the info that Positron has in the metadata?
  • Do we need to add "Enter interpreter path" here? I tend to think not, for R users at least, and we can punt that to later
  • The R command is called r.selectInterpreter while the Python command is python.setInterpreter. Do we need to make these the same, for the multi-session work?

@juliasilge juliasilge self-assigned this Jan 29, 2025
@juliasilge
Copy link
Contributor Author

There are downsides to having this in Positron itself, as a language runtime action:

  • We don't currently have a way to kick off discovery for one language from the languageRuntimeService. In Add option to control startup behavior per language #6145 we are adding a way to exclude a language from discovery but would need to do extra work if we wanted to refresh the runtime list for one language. If this functionality lived in the extension like the Python one, we could refresh just the R interpreters.
  • We can only use the Positron-level runtime metadata to organize the quickpick, which isn't as useful as metadata that the R extension holds about R installations. Similarly we cannot show folks discovered but not available R versions, because those don't get sent over to Positron at all.

I am leaning toward implementing a more R-specific version of the quickpick in the R extension itself. If I do that, is there benefit to keeping the generic runtime command around, for possible future other language packs? If refreshing is an important part of this UI (and remember we have no other way to let users refresh discovery), then we'll probably always want this kind of functionality in language packs.

@jmcphers
Copy link
Collaborator

I think it makes the most sense for individual languages to implement interpreter selectors since (as you noted) there are often nuances or details specific to a language that make it difficult to build a generic UI that will serve everyone.

It would be helpful for there to be some sort of workflow for re-initiating discovery for a language that was driven from the Positron side, but I don't think that needs to happen here. R discovery is so fast that we could probably even do it to build the quickpick, and if the user chooses a version of R that wasn't in the set we initially delivered to Positron, we can do a just-in-time registration.

The generic interpreter selection command isn't that useful for end users, but I think it's helpful to us as a debugging tool and as a stable way of picking interpreters in test automation.

@juliasilge
Copy link
Contributor Author

The QuickPickItem doesn't currently let us show an item but make it non-clickable, i.e. grayed out or similar. That means we can't currently do work to surface the discovered but not-usable R installations; that would need to involve changes to the quickpick infrastructure.

So overall what that means is that the only thing we're really gaining at the current moment is to initiate discovery. Probably still worth doing (given that I almost have it finished), but not a huge win over the existing language agnostic workbench.action.languageRuntime.select.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtimes Issues related to Language Runtimes enhancement New feature or request lang: r
Projects
None yet
Development

No branches or pull requests

5 participants