Repository navigation
Add runtime provider (to register a single runtime on demand) for R - #1969
Conversation
|
Addresses #1067 by adding the implementation of the R runtime provider, to provide a single runtime on demand, for example for workspace affiliation. |
juliasilge
left a comment
There was a problem hiding this comment.
Any Python affiliated runtimes will not get started until we incorporate posit-dev/positron-python#294, but this does work right now for Zed and R.
To see it working for R, you'll need to get runtime metadata stored for the workspace, using the new improved runtimePath. Then I find the easiest way to see this work is to comment out this._proxy.$discoverLanguageRuntimes() in mainThreadLanguageRuntime.ts so you skip runtime discovery.
If you turn this on and have it run alongside runtime discovery, you will see this error in the logs; I'll address that ASAP in an additional PR.
| } | ||
| } | ||
|
|
||
| export function getRHomePath(binPath: string): string | undefined { |
There was a problem hiding this comment.
There is a bit of rearranging in this PR of existing code, so we can make an R runtime either during discovery or on demand. I believe I got this pretty well organized for these use cases, but would love any feedback on that.
|
The Python language runtime provider as set up in posit-dev/positron-python#294 is now merged in to main. ✅ |
jennybc
left a comment
There was a problem hiding this comment.
I made an inline comment and a proposal re: giving ourselves the gift of just passing full runtime metadata into createJupyterKernelSpec(), instead of rederiving path knowledge that we already have.
| }; | ||
| } | ||
|
|
||
| export function createJupyterKernelSpec(context: vscode.ExtensionContext, rHomePath: string, runtimeName: string): JupyterKernelSpec { |
There was a problem hiding this comment.
We seem to be facing some awkwardness re: which path(s) to pass in here, because different OSes have different needs:
- For macOS, we need
rHomePath, which presumably explains why that's what we pass in, given our macOS roots. - But for Windows, we need the bin path.
With this PR, createJupyterKernelSpec() is called in 2 different contexts, i.e. when
- Providing a specific runtime:
positron/extensions/positron-r/src/provider.ts
Lines 44 to 46 in 0988e25
- Discovering all possible runtimes:
positron/extensions/positron-r/src/provider.ts
Lines 197 to 199 in 0988e25
For R, at least, it would be very handy to store both the home and bin paths in the runtime metadata. Otherwise, it feels like we inevitably end up needing to re-discover one from the other, repeatedly, in various parts of the R extension.
If you want me to tag in and explore an implementation for whatever we decide, I am happy to.
There was a problem hiding this comment.
If we change the runtime metadata, that's a change for all the language packs, and Python doesn't need to carry around two paths. I was attempting to centralize this R-specific need with the new getRHomePath() function. Do you have an idea about how to improve the handling here, without changing what is in the Positron runtime metadata?
If we are going to consider that dramatic of a change across all runtimes, I do think we should do it in a separate, standalone PR.
There was a problem hiding this comment.
Yeah, if you're happy with how this works, let's move forward and open a separate issue about how to adjust the runtime metadata to better serve R's needs.
I'm opening this up in a pretty rough state because I am noticing that I need the path to the binary to make this work, and so it is very related to #1952.