bluesky / hklpy

Diffractometer computation library with ophyd pseudopositioner support
https://blueskyproject.io/hklpy
BSD 3-Clause "New" or "Revised" License
2 stars 11 forks source link

BUG: list_orientation_runs(cat) fails when no primary stream exists #237

Closed prjemian closed 2 years ago

prjemian commented 2 years ago
In [1]: import databroker

In [3]: cat = databroker.catalog["training"]

In [4]: import hkl

In [5]: hkl.util.list_orientation_runs(cat)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/micromamba/envs/dev-hklpy/lib/python3.9/site-packages/intake/catalog/base.py:350, in Catalog.__getattr__(self, item)
    349 try:
--> 350     return self[item]  # triggers reload_on_change
    351 except KeyError as e:

File ~/micromamba/envs/dev-hklpy/lib/python3.9/site-packages/intake/catalog/base.py:423, in Catalog.__getitem__(self, key)
    422     return out()
--> 423 raise KeyError(key)

KeyError: 'primary'

The above exception was the direct cause of the following exception:

AttributeError                            Traceback (most recent call last)
Input In [5], in <cell line: 1>()
----> 1 hkl.util.list_orientation_runs(cat)

File ~/Documents/projects/Bluesky/hklpy/hkl/util.py:264, in list_orientation_runs(catalog, limit, *args)
    262 display_columns = default_columns + list(args)
    263 for run in catalog.v2.values():
--> 264     info = run_orientation_info(run)
    265     if len(info):
    266         scan_id = run.metadata["start"]["scan_id"]

File ~/Documents/projects/Bluesky/hklpy/hkl/util.py:300, in run_orientation_info(run)
    285 """
    286 Return a dictionary with orientation information in this run.
    287 
   (...)
    297     A Bluesky run, from databroker v2, such as ``cat.v2[-1]``.
    298 """
    299 devices = {}
--> 300 run_conf = run.primary.config
    301 for device in sorted(run_conf):
    302     conf = run_conf[device].read()

File ~/micromamba/envs/dev-hklpy/lib/python3.9/site-packages/intake/catalog/base.py:352, in Catalog.__getattr__(self, item)
    350         return self[item]  # triggers reload_on_change
    351     except KeyError as e:
--> 352         raise AttributeError(item) from e
    353 raise AttributeError(item)

AttributeError: primary

This issue discovered while investigating: