Skip to content

Add runtime provider (to register a single runtime on demand) for R - #1969

Merged
juliasilge merged 9 commits into
mainfrom
runtime-provider-for-r
Jan 5, 2024
Merged

juliasilge merged 9 commits into
mainfrom
runtime-provider-for-r

Conversation

@juliasilge

Copy link
Copy Markdown
Member

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.

Comment thread extensions/positron-r/src/provider.ts Resolved
@juliasilge

Copy link
Copy Markdown
Member Author

Addresses #1067 by adding the implementation of the R runtime provider, to provide a single runtime on demand, for example for workspace affiliation.

@juliasilge juliasilge left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@juliasilge
juliasilge marked this pull request as ready for review December 21, 2023 03:19
@juliasilge
juliasilge requested a review from jennybc December 21, 2023 04:20
@juliasilge

Copy link
Copy Markdown
Member Author

The Python language runtime provider as set up in posit-dev/positron-python#294 is now merged in to main. ✅

@jennybc jennybc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

@jennybc jennybc Jan 5, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #2022

@juliasilge
juliasilge merged commit 0c8a8b6 into main Jan 5, 2024
@juliasilge
juliasilge deleted the runtime-provider-for-r branch January 5, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants