bluesky / tiled

API to structured data
https://blueskyproject.io/tiled
BSD 3-Clause "New" or "Revised" License
53 stars 48 forks source link

`run.summary` has an AttributeError exeption when `.start` and `.stop` work #214

Open ambarb opened 2 years ago

ambarb commented 2 years ago

CODE TO REPRODUCE:

import tiled ### to get version later
from databroker.queries import TimeRange
from tiled.client import from_uri
c = from_uri("https://tiled-demo.blueskyproject.io/api")
csx = c["csx"]["raw"]

runs = csx.search(TimeRange(since = "2022-02-10 20:35:47", until = "2022-02-10 22:29:24")) #16 entries no large data

print(tiled.__version__)
print(list(runs[0].metadata))
runs[0].summary

OUTPUT:

0.1.0a61
['start', 'stop', 'summary']
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [34], in <cell line: 3>()
      1 print(tiled.__version__)
      2 print(list(runs[0].metadata))
----> 3 runs[0].summary

File /srv/conda/envs/notebook/lib/python3.9/site-packages/databroker/client.py:100, in BlueskyRun.__getattr__(self, key)
     98 if key in self:
     99     return self[key]
--> 100 raise AttributeError(key)

AttributeError: summary

The run.metadata object does return all three dictionary keys and their nested values. Just showing the values for summary for clarity.

 'summary': {'datetime': datetime.datetime(2022, 2, 11, 3, 29, 4, 768110, tzinfo=datetime.timezone.utc),
             'duration': 10.249870538711548,
             'plan_name': 'rel_grid_scan',
             'scan_id': 151875,
             'stream_names': ['baseline', 'primary'],
             'timestamp': 1644550144.7681098,
             'uid': '2a4b0ac5-e2de-41bd-8324-6989ab163954'}}
ambarb commented 2 years ago

should say that dictionary key works so data is still accessible.

print(list(runs[0].metadata))
runs[0].metadata["summary"]

Just didn't expect for only run.start and run.stop to work and run.summary to not work.

danielballan commented 2 years ago

This is an interesting question. I considered run.start and run.stop "grandfathered" in since people are familiar with h.start and h.stop. But it would be reasonable to expend the pattern to any new keys (like run.summary) for consistency. Good feedback.

ambarb commented 2 years ago

I think also run.metadata.start works but run.metadata.summary does not.