-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make GLPickle more extensible. #180
base: master
Are you sure you want to change the base?
Conversation
@@ -62,6 +62,8 @@ | |||
from .version_info import version | |||
from .version_info import __VERSION__ | |||
|
|||
from _gl_pickle import GLPickler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For PY3 support, you'll also need to always use relative imports:
from ._gl_pickle import GLPickler
from ._gl_pickle import GLUnpickler
Notice the periods.
@srikris Can you do a merge with master again? |
@ylow Done. |
Instead you should just save the module import path to the load method and find it on deserialization. |
@srikris progress on this? |
This will go in right after 1.9. I plan to fix it soon. |
Summary of changes ------------------ - Made GLPickle more extensible - Used the extensibility mechanism to implement things for Model, SGraph, SFrame, and SArray. - Added some additional tests for the same. Details ------- Previously, GLPickle could not be extended without making changes directly to it. Now, we added a mechanism to extend it by implementing 2 simple methods: 1. __gl_pickle_save__: Save your object to a filename (not handle) given to you. 2. __gl_pickle_load__: Load your object from a filename (not handle) given to you. As an example, here is a simple class that was extended to be pickled via GLPickle. class SampleClass(object): def __init__(self, member): self.member = member def __gl_pickle_save__(self, filename): with open(filename, 'w') as f: f.write(self.member) @staticmethod def __gl_pickle_load__(filename): with open(filename, 'r') as f: member = f.read().split() return SampleClass(member)
- No bump of version number. - Loading module and then class name.
3111093
to
4ccfd09
Compare
Summary of changes
SFrame, and SArray.
Details
Previously, GLPickle could not be extended without making changes directly to
it. Now, we added a mechanism to extend it by implementing 2 simple
methods:
As an example, here is a simple class that was extended to be pickled via
GLPickle.