def getData(self, path): """get data for track and slice. Save data in persistent cache for further use. For functions, path should be an empty tuple. """ if path: key = DataTree.path2str(path) else: key = "all" result, fromcache = None, False # trackers with options are not cached if not self.nocache and not self.tracker_options: try: result = self.cache[key] fromcache = True except KeyError: pass except RuntimeError as msg: raise RuntimeError( "error when accessing key %s from cache: %s " "- potential problem with unpickable object?" % (key, msg)) kwargs = {} if self.tracker_options: kwargs['options'] = self.tracker_options if result is None: try: result = self.tracker(*path, **kwargs) except Exception as msg: self.warn("exception for tracker '%s', path '%s': msg=%s" % (str(self.tracker), DataTree.path2str( path), msg)) if VERBOSE: self.warn(traceback.format_exc()) raise # store in cache if not self.nocache and not fromcache: # exception - do not store data frames # test with None fails for some reason self.cache[key] = result return result