R bridge replacement#271
Open
AndrewIOM wants to merge 38 commits intofslaborg:masterfrom
Open
Conversation
- Removed old interception loggers; now defaults to file-based logging.
…her than namespace packages
Collaborator
Author
|
Running dotnet fsi build.fsx works fine locally on macos. However, the packing of the type provider files doesn't seem to work correctly in github runners, despite everything being equal from what I can tell. I have spent a long time trying to fix this but can't figure it out. The typeproviders folder isn't added to the nuget. Here is a locally built nuget: RProvider.3.0.0-alpha1.nupkg.zip |
This was
linked to
issues
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
R.NET is not maintained and is a complex codebase including substantial overhead that is not required by RProvider. This draft PR utilises a far smaller, F# R interop layer (RBridge), which only implements the raw interop and structural elements required by RProvider. See #270
Types of changes
What types of changes does your code introduce to RProvider?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
In this PR, I have replaced R.NET entirely. In removing R.NET and replacing with the smaller bridge layer, I have made a clearer distinction between the raw native R C API and structural elements of the R language (which sit in RBridge and RBridge.Extensions), and placed a newer semantic layer into RProvider itself. This means RProvider has full control over its form, operator overrides etc.
For the bridging layer, I have mostly been following the latest embedded R docs rather than referring to R.NET, which should help us to clear up some of the very old bugs.
Key changes
Minimum (tested) supported versions
Moves minimum versions to R v4.5.0 and .NET 8. However, the type provider may work with older versions of R but these are not fully tested. (R exports different bindings between versions and between platforms, and since 4.5 are working to establish a modern public C API).
Type provider SDK
Uses the latest SDK and moves to the latest nuget packaging format. To accomodate this, I refactored to remove the dependency that design-time used to have on the runtime.
NA support
The RBridge has NA support to and from R through the F# option type. I revised RProvider to use this layer. The structural converters to request values from R to .NET values (i.e. using _.FromR<'t>() and _.TryFromR<'t>()) do allow access directly to non-options (e.g. float[]), but if there are NA values in the data it will not return any value or throw. Addresses #179 .
Semantic types layer
There is now a new semantic types layer within RProvider, in the RTypes module. This includes scalars, vectors, data frames, and factors. The semantic types keep data in R memory and support mathematical operators where appropriate.
The type provider now has a new root erased type (RExpr) and from this you can access the semantic layer with .AsTyped, .TryAsTyped, and similarly .AsDataFrame, .AsList, etc. or .Try* versions also.
Plugin system
I have removed the old plugin system, as it no longer fit with current F# scripting practices, and was very brittle. Also, the Deedle plugin has been recently removed from Deedle, which was the main plugin that existed. Now, the approach should be to explicitly convert from types in the semantic layer (i.e. R DataFrame -> Deedle).
Dependencies
By slimming the R<->.NET conversion system and the bridge layer, most dependencies have been removed.
Testing
The test project is now using Expecto, and consumes a locally-built nuget package specifically built for the purposes of running tests. The required nuget is built in the FAKE build script. All tests pass.
Status
All tests pass. Documentation is now very out of date and requires an overhaul. I suggest that this can continue in subsequent PRs.
All building and testing and packing works fine locally on macos. However, I cannot get the github runner to do the same. The runner is for some reason not packing the typeprovider folder within the nuget package; it seems to not be seeing the type provider SDK targets.
I have yet to test the provider on windows. Any issues will arise from R initialisation within RBridge, where changes will need to be made.
Smaller changes made as part of conversion process