def load(self,dataset,report_func=None): """Load dataset from cache file""" options = self._options if not dataset or not options.switch_cache or not exists(dataset): return # get profile from timeseries file if exists profile = self._get_file_profile(dataset,options.profile) _accounting['cache.load.profile'] = profile d = options.cache_date if not d: d = datetime.today().isoformat()[:10] c = self._make_cachedir() f = self.filename(dataset) _accounting['cache.load.file'] = f # logger.debug('trying pickling results from %s',f) result = None if exists(f): # logger.debug('pickle file %s exists',f) result = DataSet() p = pickle.load(open(f,'r')) for k,v in p.items(): if k=="_MISSING": result.add_missing(*v) else: if v[0]==0: # Timeseries result[k]=Timeseries(data=v[1],metadata=v[2],name=k) elif v[0]==1: # Numpy Array result[k]=v[1] _accounting['cache.load.missing'] = ','.join(result.missing) _accounting['cache.load.series'] = ','.join(result.keys()) # Report if report_func: # logger.debug(dictview(_accounting)) report_func("load",f,result,self,_accounting) _accounting.clear() else: # logger.debug('no pickle file %s',f) if options.cache_date: logger.error('Requested date (%s) does not exists',d) sys.exit(-1) return result