Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: move the recursive collect_asset_docs up to Device #1032

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/source/reference/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Changes
within ophyd methods.
* Deprecate ``DetectorBase.dispatch`` in favor of newly added
``DetectorBase.generate_datum``

* ``obj.collect_asset_docs`` will now recurse to children by default at the
Device level


1.6.4 (2022-04-08)
Expand Down
6 changes: 0 additions & 6 deletions ophyd/areadetector/detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ def make_data_key(self):
return dict(shape=shape, source=source, dtype='array',
external='FILESTORE:')

def collect_asset_docs(self):
file_plugins = [s for s in self._signals.values() if
hasattr(s, 'collect_asset_docs')]
for p in file_plugins:
yield from p.collect_asset_docs()


class AreaDetector(DetectorBase):
cam = C(cam.AreaDetectorCam, 'cam1:')
Expand Down
5 changes: 5 additions & 0 deletions ophyd/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,11 @@ def read(self):
res.update(component.read())
return res

def collect_asset_docs(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring would be nice!

for _, component in self._get_components_of_kind(Kind.normal):
if hasattr(component, 'collect_asset_docs'):
yield from component.collect_asset_docs()

def read_configuration(self) -> OrderedDictType[str, Dict[str, Any]]:
"""Dictionary mapping names to value dicts with keys: value, timestamp

Expand Down
7 changes: 5 additions & 2 deletions ophyd/tests/test_areadetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,14 @@ class MyDetector(SingleTrigger, SimDetector):

det.stage()
st = det.trigger()
while not st.done:
time.sleep(.1)
st.wait()
reading = det.read()
doc_count = 0
for name, d in det.collect_asset_docs():
doc_count += 1
getattr(fs2, 'insert_{name}'.format(name=name))(**d)
assert doc_count > 0

det.describe()
det.unstage()

Expand Down