Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5173#discussion_r27180520
  
    --- Diff: python/pyspark/cloudpickle.py ---
    @@ -732,76 +593,20 @@ def inject_numpy(self):
                 return
             self.dispatch[numpy.ufunc] = self.__class__.save_ufunc
     
    -    numpy_tst_mods = ['numpy', 'scipy.special']
         def save_ufunc(self, obj):
             """Hack function for saving numpy ufunc objects"""
             name = obj.__name__
    -        for tst_mod_name in self.numpy_tst_mods:
    +        numpy_tst_mods = ['numpy', 'scipy.special']
    +        for tst_mod_name in numpy_tst_mods:
                 tst_mod = sys.modules.get(tst_mod_name, None)
    -            if tst_mod:
    -                if name in tst_mod.__dict__:
    -                    self.save_reduce(_getobject, (tst_mod_name, name))
    -                    return
    -        raise pickle.PicklingError('cannot save %s. Cannot resolve what 
module it is defined in' % str(obj))
    -
    -    def inject_timeseries(self):
    -        """Handle bugs with pickling scikits timeseries"""
    -        tseries = sys.modules.get('scikits.timeseries.tseries')
    -        if not tseries or not hasattr(tseries, 'Timeseries'):
    -            return
    -        self.dispatch[tseries.Timeseries] = self.__class__.save_timeseries
    -
    -    def save_timeseries(self, obj):
    -        import scikits.timeseries.tseries as ts
    -
    -        func, reduce_args, state = obj.__reduce__()
    -        if func != ts._tsreconstruct:
    -            raise pickle.PicklingError('timeseries using unexpected 
reconstruction function %s' % str(func))
    -        state = (1,
    -                         obj.shape,
    -                         obj.dtype,
    -                         obj.flags.fnc,
    -                         obj._data.tostring(),
    -                         ts.getmaskarray(obj).tostring(),
    -                         obj._fill_value,
    -                         obj._dates.shape,
    -                         obj._dates.__array__().tostring(),
    -                         obj._dates.dtype, #added -- preserve type
    -                         obj.freq,
    -                         obj._optinfo,
    -                         )
    -        return self.save_reduce(_genTimeSeries, (reduce_args, state))
    -
    -    def inject_email(self):
    -        """Block email LazyImporters from being saved"""
    -        email = sys.modules.get('email')
    -        if not email:
    -            return
    -        self.dispatch[email.LazyImporter] = self.__class__.save_unsupported
    +            if tst_mod and name in tst_mod.__dict__:
    +                return self.save_reduce(_getobject, (tst_mod_name, name))
    +        raise pickle.PicklingError('cannot save %s. Cannot resolve what 
module it is defined in'
    +                                   % str(obj))
     
         def inject_addons(self):
             """Plug in system. Register additional pickling functions if 
modules already loaded"""
             self.inject_numpy()
    --- End diff --
    
    only `numpy.ufunc` is useful for us.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to