Skip to content

Commit 80e154a

Browse files
author
srikris
committed
Make GLPickle more extensible.
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)
1 parent a15453b commit 80e154a

7 files changed

Lines changed: 230 additions & 124 deletions

File tree

oss_src/unity/python/sframe/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
from .version_info import version
6363
from .version_info import __VERSION__
6464

65+
from _gl_pickle import GLPickler
66+
from _gl_pickle import GLUnpickler
6567

6668
class DeprecationHelper(object):
6769
def __init__(self, new_target):

0 commit comments

Comments
 (0)