Skip to content

Commit 3222417

Browse files
author
srikris
committed
Addressed the following issues (from comments):
- No bump of version number. - Loading module and then class name.
1 parent 154bb78 commit 3222417

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

oss_src/unity/python/sframe/_gl_pickle.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
This software may be modified and distributed under the terms
66
of the BSD license. See the LICENSE file for details.
77
'''
8-
from . import util as _util, toolkits as _toolkits, SFrame as _SFrame, SArray as _SArray, \
9-
SGraph as _SGraph, load_graph as _load_graph
10-
8+
from . import util as _util, toolkits as _toolkits, SFrame as \
9+
_SFrame, SArray as _SArray, SGraph as _SGraph, load_graph as\
10+
_load_graph
1111
from .util import _get_aws_credentials as _util_get_aws_credentials, \
1212
cloudpickle as _cloudpickle, file_util as _file_util
1313

@@ -29,7 +29,6 @@ def _get_temp_filename():
2929
def _get_tmp_file_location():
3030
return _util._make_temp_directory(prefix='gl_pickle_')
3131

32-
3332
def _get_class_from_name(module_name, class_name):
3433
import importlib
3534

@@ -184,11 +183,11 @@ def __init__(self, filename, protocol = -1, min_bytes_to_save = 0):
184183
185184
Parameters
186185
----------
187-
filename : Name of the file to write to. This file is all you need to pickle
188-
all objects (including GLC objects).
186+
filename : Name of the file to write to. This file is all you need to
187+
pickle all objects (including GLC objects).
189188
190-
protocol : Pickle protocol (see pickle docs). Note that all pickle protocols
191-
may not be compatable with GLC objects.
189+
protocol : Pickle protocol (see pickle docs). Note: All pickle
190+
protocols may not be compatable with GLC objects.
192191
193192
min_bytes_to_save : Cloud pickle option (see cloud pickle docs).
194193
@@ -358,12 +357,13 @@ def __gl_pickle_load__(cls, filename):
358357

359358
# Save the object
360359
obj.__gl_pickle_save__(filename)
360+
type_tag = (obj.__module__, obj.__class__.__name__)
361361

362362
# Memoize.
363363
self.gl_object_memo.add(id(obj))
364364

365365
# Return the tuple (load_func, relative_filename) in archive.
366-
return (obj.__gl_pickle_load__, relative_filename, id(obj))
366+
return (type_tag, relative_filename, id(obj))
367367

368368
# Not a GLC object. Default to cloud pickle
369369
else:
@@ -562,9 +562,7 @@ def persistent_load(self, pid):
562562
class_name)
563563
obj = type_class.__gl_pickle_load__(abs_path)
564564
else:
565-
raise Exception(
566-
"Unknown version %s: Expected version in [1.0, 2.0]" \
567-
% self.version)
565+
raise Exception("Unknown version %s" % self.version)
568566
self.gl_object_memo[object_id] = obj
569567
return obj
570568

oss_src/unity/python/sframe/test/test_gl_pickler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def test_save_to_s3(self):
239239

240240
del os.environ['GRAPHLAB_UNIT_TEST']
241241

242-
@nottest
242+
#@unittest.skip("Can be run locally for testing.")
243243
def test_backward_compatibility(self):
244244

245245
# Arrange
@@ -258,7 +258,7 @@ def test_backward_compatibility(self):
258258
assert_sframe_equal(obj['foo-bar'][1], obj_ret['foo-bar'][1])
259259
self.assertEqual(obj['foo-bar'][0], obj_ret['foo-bar'][0])
260260

261-
@nottest
261+
#@unittest.skip("Can be run locally for testing.")
262262
def test_backward_compatibility_v1(self):
263263

264264
# Arrange

0 commit comments

Comments
 (0)