vnmabus / rdata

Reader of R datasets in .rda format, in Python
https://rdata.readthedocs.io
MIT License
40 stars 2 forks source link

NotImplementedError: Type RObjectType.EXTPTR not implemented #21

Closed userLUX closed 1 year ago

userLUX commented 2 years ago

I get the following error

NotImplementedError: Type RObjectType.EXTPTR not implemented

when trying to read an rdata file through the parse function:

test = rdata.parser.parse_data("Input/my_file.RData")\

It seems that EXTPTR case is not implemented. Any suggestion to fix the error ? It is possible to implemente this Rdata type ? Otherwise, can I change the type of my Rdata file ? I do not know the differences between these RData types. Can I have some explanation ?

vnmabus commented 2 years ago

The EXTPTR object is a pointer to a resource not managed by R itself, like a database connection or a object in another programming language. I didn't implement this because I though that these weren't able to be properly restored from disk. However it seems that in some cases that is not true (https://cran.r-project.org/web/packages/future/vignettes/future-4-non-exportable-objects.html). I will have a deeper look at it. At worst, I could always ignore that with a warning and load the rest of the dataset. Can you tell me more about which kind of data are you trying to load?

userLUX commented 2 years ago

I am trying to load an RData file containing a mixed set of objects: datasets/dataframes, string values and Rfunctions

userLUX commented 2 years ago

Did you manage to implement EXTPTR ?

vnmabus commented 2 years ago

Unfortunately not. I am very busy at the moment. I tried to see how to parse R functions (just to read their names at least, I won't convert them to Python functions), but they don't use EXTPTR as far as I can see, so I have no example for that.

However, due to the nature of that object (a pointer to a external resource), I wouldn't count on being able to deserialize that in a different process, much less a different LANGUAGE.

vnmabus commented 1 year ago

@userLUX I had some time to try to tackle this. I added some code to be able to read simple R functions, and I also added support to read external pointers in #23. Note that the actual value of the pointer is never serialized (as it doesn't make sense outside of the original process), and thus reading it is only done to be able to read the rest of the dataset.

Please try using #23 when you have time to see if it solves your problem.