rsnirwan / GPLVMsInFinance

Applications of Gaussian Process Latent Variable Models in Finance
11 stars 7 forks source link

An error occurred in the 'portfolio_performance.ipynb', #3

Closed hellojinwoo closed 5 years ago

hellojinwoo commented 5 years ago

Issue

Background Information

I am running your codes in the following environment:

Error message

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<timed exec> in <module>

~/anaconda3/envs/GPLVM/lib/python3.7/site-packages/ipyparallel/client/view.py in push(self, ns, targets, block, track)
    708         if not isinstance(ns, dict):
    709             raise TypeError("Must be a dict, not %s"%type(ns))
--> 710         return self._really_apply(util._push, kwargs=ns, block=block, track=track, targets=targets)
    711 
    712     def get(self, key_s):

<decorator-gen-139> in _really_apply(self, f, args, kwargs, targets, block, track)

~/anaconda3/envs/GPLVM/lib/python3.7/site-packages/ipyparallel/client/view.py in sync_results(f, self, *args, **kwargs)
     50     self._in_sync_results = True
     51     try:
---> 52         ret = f(self, *args, **kwargs)
     53     finally:
     54         self._in_sync_results = False

<decorator-gen-138> in _really_apply(self, f, args, kwargs, targets, block, track)

~/anaconda3/envs/GPLVM/lib/python3.7/site-packages/ipyparallel/client/view.py in save_ids(f, self, *args, **kwargs)
     35     n_previous = len(self.client.history)
     36     try:
---> 37         ret = f(self, *args, **kwargs)
     38     finally:
     39         nmsgs = len(self.client.history) - n_previous

~/anaconda3/envs/GPLVM/lib/python3.7/site-packages/ipyparallel/client/view.py in _really_apply(self, f, args, kwargs, targets, block, track)
    558         pf = PrePickled(f)
    559         pargs = [PrePickled(arg) for arg in args]
--> 560         pkwargs = {k: PrePickled(v) for k, v in kwargs.items()}
    561 
    562         for ident in _idents:

~/anaconda3/envs/GPLVM/lib/python3.7/site-packages/ipyparallel/client/view.py in <dictcomp>(.0)
    558         pf = PrePickled(f)
    559         pargs = [PrePickled(arg) for arg in args]
--> 560         pkwargs = {k: PrePickled(v) for k, v in kwargs.items()}
    561 
    562         for ident in _idents:

~/anaconda3/envs/GPLVM/lib/python3.7/site-packages/ipyparallel/serialize/serialize.py in __init__(self, obj)
     42     """
     43     def __init__(self, obj):
---> 44         self.buffers = serialize_object(obj)
     45 
     46 

~/anaconda3/envs/GPLVM/lib/python3.7/site-packages/ipyparallel/serialize/serialize.py in serialize_object(obj, buffer_threshold, item_threshold)
    123         buffers.extend(_extract_buffers(cobj, buffer_threshold))
    124 
--> 125     buffers.insert(0, pickle.dumps(cobj, PICKLE_PROTOCOL))
    126     return buffers
    127 

~/anaconda3/envs/GPLVM/lib/python3.7/site-packages/pystan/model.py in __getstate__(self)
    394         """
    395         state = self.__dict__.copy()
--> 396         del state['module']
    397         del state['fit_class']
    398         return state

KeyError: 'module'

Added Notice

I just found that this error occurs every .ipynb file (model_evaluation, latent_space_embedding...). How can I fix this problem?

rsnirwan commented 5 years ago

Did you activate the virtualenv before you start the cluster? Otherwise the clusters might work with a different version of the packages than main notebook. I just did a test run on Ubuntu and MacOS with python 3.7.2 in a virtualenv (with packages from requirements.txt) and every notebook is working fine.

Here are the steps I did: git clone https://github.com/RSNirwan/GPLVMsInFinance/ cd GPLVMsInFinance/ virtualenv -p python3 . . bin/activate pip install -r requirements.txt jupyter notebook

In another terminal: cd GPLVMsInFinance/ . bin/activate ipcluster start -n 4

hellojinwoo commented 5 years ago

Did you activate the virtualenv before you start the cluster? Otherwise the clusters might work with a different version of the packages than main notebook.

This tip helped me solve the 'module' problem.

I reinstalled the anaconda on my Ubuntu and as you advised, activated the virtualenv before starting clusters on the different cmd.

Thank you!