MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / fetch_run_info

Function fetch_run_info

pyxrf/model/load_data_from_db.py:143–182  ·  view source on GitHub ↗

Fetches key data from start document of the selected run Parameters ---------- run_id_uid: int or str Run ID (positive or negative int) or UID (str, full or short) of the run. catalog_name: str or None Name of the catalog (e.g. `"srx"`). The function attempts to

(run_id_uid, catalog_name=None)

Source from the content-addressed store, hash-verified

141
142
143def fetch_run_info(run_id_uid, catalog_name=None):
144 """
145 Fetches key data from start document of the selected run
146
147 Parameters
148 ----------
149 run_id_uid: int or str
150 Run ID (positive or negative int) or UID (str, full or short) of the run.
151 catalog_name: str or None
152 Name of the catalog (e.g. `"srx"`). The function attempts to determine the catalog
153 name automatically if the parameter is not specified or `None`.
154
155 Returns
156 -------
157 int or str
158 Run ID (always positive int) or Run UID (str, always full UID). Returns
159 `run_id=-1` and `run_uid=""` in case of failure.
160
161 Raises
162 ------
163 RuntimeError
164 failed to fetch the run from Databroker
165 """
166 try:
167 if catalog_name:
168 catalog = get_catalog(catalog_name)
169 else:
170 catalog = db
171 hdr = catalog[run_id_uid]
172
173 hdr = catalog[run_id_uid]
174 run_id = hdr.start["scan_id"]
175 run_uid = hdr.start["uid"]
176 except Exception:
177 if isinstance(run_id_uid, int):
178 msg = f"ID {run_id_uid}"
179 else:
180 msg = f"UID '{run_id_uid}'"
181 raise RuntimeError(f"Failed to find run with {msg}.")
182 return run_id, run_uid
183
184
185def fetch_data_from_db(

Callers 2

render_data_to_guiFunction · 0.90
make_hdfFunction · 0.85

Calls 1

get_catalogFunction · 0.85

Tested by

no test coverage detected