niosh-mining / obsplus

A Pandas-Centric ObsPy Expansion Pack
GNU Lesser General Public License v3.0
38 stars 8 forks source link

No longer able to pickle WaveBank #222

Closed sboltz closed 3 years ago

sboltz commented 3 years ago

Description It is going to be really fun to track down the source of this issue, but I recently created a new python environment (3.7.9) and run some code that uses the WaveBank and it raised an error about being unable to pickle a generator object. This has implications for multiprocessing.

I ran the same snippet of code on this environment and another to verify it really was a new problem and it worked fine in this other environment. My guess is that a library was updated that caused this, but at this point I'm not sure what the change is. I fell down a very deep rabbit hole to even figure out it was the WaveBank that was the source of this error in my code.

To Reproduce

In [1]: import obsplus

In [2]: import pickle

In [3]: bank = obsplus.WaveBank(".")

In [4]: with open("pickle_test", "wb") as f:
   ...:     pickle.dump(bank, f)
   ...: 
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-294477cc03b2> in <module>
      1 with open("pickle_test", "wb") as f:
----> 2     pickle.dump(bank, f)
      3 

TypeError: can't pickle generator objects

Expected behavior The expected behavior, and indeed the behavior in my other environment is that this should pickle the WaveBank without an error.

Versions (please complete the following information):

I've tried this on 4 different environments, 2 working, 2 not working:

Working 1: OS: Ubuntu 16.04 ObsPlus Version: 'v0.1.1+18.g56c674e' Python Version: 3.7.6

Working 2: OS: Ubuntu 20.04 ObsPlus Version: 'v0.1.1+20.gb2d8885' Python Version: 3.8.5

Not Working 1 OS: Ubuntu 16.04 ObsPlus Version: 'v0.1.1+16.ge94fb5b' Python Version: 3.7.9

Not Working 2 OS: Ubuntu 16.04 ObsPlus Version: 'v0.1.1+15.g5a158f6.dirty' Python Version: 3.7.6

sboltz commented 3 years ago

This has already been fixed. I just updated to the latest master and it worked: 'v0.1.1+27.g61c4db0'.