def run_metadata(self, run_id): path = self._run_meta_path(run_id) if osp.exists(path): with open(path, mode='r') as f: return json.loads(f.read()) else: raise strax.RunMetadataNotAvailable( f"No file at {path}, cannot find run metadata for {run_id}")
def run_metadata(self, run_id, projection=None): path = self._run_meta_path(run_id) if osp.exists(path): with open(path, mode='r') as f: md = json.loads(f.read(), object_hook=json_util.object_hook) return md else: raise strax.RunMetadataNotAvailable( f"No file at {path}, cannot find run metadata for {run_id}")
def run_metadata(self, run_id, projection=None): path = self._run_meta_path(run_id) if not osp.exists(path): raise strax.RunMetadataNotAvailable( f"No file at {path}, cannot find run metadata for {run_id}") with open(path, mode='r') as f: md = json.loads(f.read(), object_hook=json_util.object_hook) md = strax.flatten_run_metadata(md) if projection is not None: md = {k: v for k, v in md.items() if k in projection} return md
def run_metadata(self, run_id, projection=None): path = self._run_meta_path(run_id) if osp.exists(path): with open(path, mode='r') as f: md = json.loads(f.read(), object_hook=json_util.object_hook) if not projection: return md md = strax.flatten_dict(md, separator='.') return {k: v for k, v in md.items() if k in projection} else: raise strax.RunMetadataNotAvailable( f"No file at {path}, cannot find run metadata for {run_id}")
def run_metadata(self, run_id, projection=None) -> dict: """Return run-level metadata for run_id, or raise DataNotAvailable if this is not available :param run_id: run id to get :param projection: Selection of fields to get, following MongoDB syntax. May not be supported by frontend. """ for sf in self.storage: if not sf.provide_run_metadata: continue try: return sf.run_metadata(run_id, projection=projection) except (strax.DataNotAvailable, NotImplementedError): self.log.debug(f"Frontend {sf} does not have " f"run metadata for {run_id}") raise strax.RunMetadataNotAvailable(f"No run-level metadata available " f"for {run_id}")