home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 403076034

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/2269#issuecomment-403076034 https://api.github.com/repos/pydata/xarray/issues/2269 403076034 MDEyOklzc3VlQ29tbWVudDQwMzA3NjAzNA== 6815844 2018-07-06T16:01:25Z 2018-07-06T16:01:25Z MEMBER

Some additional explanations

I was consulted by an onwer of a project that is using xarray inside it, the way to load xarray objects that is pickled with older-version xarray.

They does not recommend to use pickle, but some users actually do this and have troubles to restore old pickled files.

In partiular, xarray renamed Coordinate to IndexVariable in some point between v0.7 to v0.8. There might be another module/class name changes too, and these result in the (uninformed) error python UnpicklingError: NEWOBJ class argument isn't a type object

What I would like to propose here is to provide a workaround to unpickle old xarray objects. The function would look like ```python def unpickle_legacy(filename): """ Unpickle old xarray objects. """ class RenamingUnpickler(pickle.Unpickler): def find_class(self, module, name): if name == 'Coordinate': name = 'IndexVariable' return super().find_class(module, name)

with open(filename, 'rb') as f:
    return RenamingUnpickler(f).load()

``` for all the previous releases.

Continuously supporting such a function might be an additional task, but it will emphasize the robustness of our project.

Any comments are welcome.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  338662554
Powered by Datasette · Queries took 0.717ms · About: xarray-datasette