Skip to content

Remove versioning from loadpkl #3019

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

Merged
merged 1 commit into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions nipype/utils/filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,12 +670,12 @@ def load_json(filename):

def loadcrash(infile, *args):
if infile.endswith('pkl') or infile.endswith('pklz'):
return loadpkl(infile, versioning=True)
return loadpkl(infile)
else:
raise ValueError('Only pickled crashfiles are supported')


def loadpkl(infile, versioning=False):
def loadpkl(infile):
"""Load a zipped or plain cPickled file."""
infile = Path(infile)
fmlogger.debug('Loading pkl: %s', infile)
Expand All @@ -700,9 +700,6 @@ def loadpkl(infile, versioning=False):
fmlogger.info('Successfully loaded pkl in compatibility mode.')
# Unpickling problems
except Exception as e:
if not versioning:
raise e

if pkl_metadata and 'version' in pkl_metadata:
from nipype import __version__ as version
if pkl_metadata['version'] != version:
Expand Down
9 changes: 4 additions & 5 deletions nipype/utils/tests/test_filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def test_versioned_pklization(tmpdir):
with mock.patch('nipype.utils.tests.test_filemanip.Pickled', PickledBreaker), \
mock.patch('nipype.__version__', '0.0.0'):

loadpkl('./pickled.pkz', versioning=True)
loadpkl('./pickled.pkz')


def test_unversioned_pklization(tmpdir):
Expand All @@ -569,7 +569,7 @@ def test_unversioned_pklization(tmpdir):

with pytest.raises(Exception):
with mock.patch('nipype.utils.tests.test_filemanip.Pickled', PickledBreaker):
loadpkl('./pickled.pkz', versioning=True)
loadpkl('./pickled.pkz')


def test_Path_strict_resolve(tmpdir):
Expand All @@ -589,11 +589,10 @@ def test_Path_strict_resolve(tmpdir):
assert '%s/somefile.txt' % tmpdir == '%s' % testfile.resolve(strict=True)


@pytest.mark.parametrize("load_versioning", [True, False])
@pytest.mark.parametrize("save_versioning", [True, False])
def test_pickle(tmp_path, save_versioning, load_versioning):
def test_pickle(tmp_path, save_versioning):
testobj = 'iamateststr'
pickle_fname = str(tmp_path / 'testpickle.pklz')
savepkl(pickle_fname, testobj, versioning=save_versioning)
outobj = loadpkl(pickle_fname, versioning=load_versioning)
outobj = loadpkl(pickle_fname)
assert outobj == testobj