Skip to content
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

dill.load_session Fails #593

Open
grach0v opened this issue May 10, 2023 · 4 comments
Open

dill.load_session Fails #593

grach0v opened this issue May 10, 2023 · 4 comments

Comments

@grach0v
Copy link

grach0v commented May 10, 2023

I tried to save and load session using dill.

import dill
dill.dump_session('stage1.db')

restart computer

import dill
dill.load_session('stage1.db')

but it gives me an error



TypeError                                 Traceback (most recent call last)
Cell In[1], line 2
      1 import dill
----> 2 dill.load_session('stage1.db')

File [c:\Users\justw\miniconda3\envs\dsenv\lib\site-packages\dill\session.py:489](file:///C:/Users/justw/miniconda3/envs/dsenv/lib/site-packages/dill/session.py:489), in load_session(filename, main, **kwds)
    487 def load_session(filename=str(TEMPDIR/'session.pkl'), main=None, **kwds):
    488     warnings.warn("load_session() has been renamed load_module().", PendingDeprecationWarning)
--> 489     load_module(filename, module=main, **kwds)

File [c:\Users\justw\miniconda3\envs\dsenv\lib\site-packages\dill\session.py:471](file:///C:/Users/justw/miniconda3/envs/dsenv/lib/site-packages/dill/session.py:471), in load_module(filename, module, **kwds)
    468         runtime_main = '__runtime__.%s' % main.__name__
    469         sys.modules[runtime_main] = main
--> 471     loaded = unpickler.load()
    472 finally:
    473     if not hasattr(filename, 'read'):  # if newly opened file

File [c:\Users\justw\miniconda3\envs\dsenv\lib\site-packages\dill\_dill.py:419](file:///C:/Users/justw/miniconda3/envs/dsenv/lib/site-packages/dill/_dill.py:419), in Unpickler.load(self)
    418 def load(self): #NOTE: if settings change, need to update attributes
--> 419     obj = StockUnpickler.load(self)
    420     if type(obj).__module__ == getattr(_main_module, '__name__', '__main__'):
    421         if not self._ignore:
    422             # point obj class to main

TypeError: Template.__new__() missing 1 required positional argument: 'source'

dill vesrion is 0.3.6
Python 3.10.11
Windows

@mmckerns
Copy link
Member

I'm not getting the same thing as you (however, I'm testing on a Mac):

Python 3.10.11 (main, Apr  8 2023, 00:55:46) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dill
>>> dill.__version__
'0.3.6'
>>> foo = lambda x:x*x
>>> bar = 4
>>> dill.dump_session('stage1.db')
>>> 
dude>$ python
Python 3.10.11 (main, Apr  8 2023, 00:55:46) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dill
>>> dill.load_session('stage1.db')
>>> foo(bar)
16
>>> 

Are you seeing the same error in all cases, or is there something in particular that triggers the error? If so, please provide a minimal test case the reproduces what you are seeing.

From the traceback, it seems like some object pickled, but failed to load.

@grach0v
Copy link
Author

grach0v commented May 10, 2023

Hm.
I have tried your example and it did work.
In my case there is a big jupyter notebook, so I will try to get the smallest example when it fails and post it here.

@mmckerns
Copy link
Member

mmckerns commented May 11, 2023

This confirms that you have an unpickleable object in your notebook, or more specifically, an object that fails upon deserialization (e.g. load).

@grach0v
Copy link
Author

grach0v commented May 12, 2023

Is there a way to make some kind of verbose load_session, so I can understand what object fails?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants