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

resolve problems with unit test workflow #317

Closed prjemian closed 5 months ago

prjemian commented 6 months ago
prjemian commented 6 months ago

Caught up with #314

prjemian commented 6 months ago

The remaining problems do not happen with databroker 1.2. The CI uses databroker v2.0.0b31 (at this time). All of these problems are related to storing the UB matrix (and other information) in the run as a detector.

FAILED hkl/tests/test_save_restore_UB.py::test_fourc_orientation_save - assert 0 == 1
FAILED hkl/tests/test_save_restore_UB.py::test_fourc_run_orientation_info - AssertionError: assert 'fourc' in {}
FAILED hkl/tests/test_save_restore_UB.py::test_list_orientation_runs - AttributeError: 'DataFrame' object has no attribute 'scan_id'
FAILED hkl/tests/test_save_restore_UB.py::test_no_primary_stream - AttributeError: 'DataFrame' object has no attribute 'scan_id'
FAILED hkl/tests/test_save_restore_UB.py::test_missing_energy_key - assert 0 == 1
FAILED hkl/tests/test_save_restore_UB.py::test_restore_orientation - KeyError: 'fourc'
FAILED hkl/tests/test_save_restore_UB.py::test_restore_sample - KeyError: 'fourc'
FAILED hkl/tests/test_util.py::test_issue215 - assert 0 == 1
prjemian commented 6 months ago

It's clear that the hkl.util.restore_orientation_info() function needs some serious attention before it can find the information known to be available from a run that was saved before this branch was started. That's a new problem with databroker v2+. Reverting the workflow to databroker 1.2.5 and tiled 0.1.0a96.

prjemian commented 6 months ago

ALL CI passes. Next, move the new pins from test settings to packaging requirements.

prjemian commented 6 months ago

With databroker 2.0.0b31 (and tiled 0.1.0a110), this line fails with a KeyError: https://github.com/bluesky/hklpy/blob/aa1e0c59bdda8013fc5a50a55fc2aff189686160/hkl/util.py#L348

and that is very suspicious since the key was just offered on the previous line: https://github.com/bluesky/hklpy/blob/aa1e0c59bdda8013fc5a50a55fc2aff189686160/hkl/util.py#L347

prjemian commented 6 months ago

An alternative to pinning databroker and tiled is to raise an exception (?ValueError?) in run_orientation_info() when type(run).__name__ != "Catalog" (an intake catalog).

prjemian commented 6 months ago

As an upgrade, the configuration could be saved using the newer DiffractometerConfiguration class. Still, that would not resolve the problem reported in #318 when using run_configuration_info() to recover previously-saved configurations.

prjemian commented 6 months ago

Using local command: sphinx-build -M html "source" "build" -v 2>&1 | tee /tmp/log.txt, sphinx complained that the chardet package could not be imported. Adding that to env-dev.yml next.

prjemian commented 6 months ago

Still:

2023-12-23T21:48:26.2424512Z [autodoc] from hkl.configuration import DCConfiguration.canonical_axes
2023-12-23T21:48:26.2427010Z [autodoc] import hkl.configuration => <module 'hkl.configuration' from '/home/runner/work/hklpy/hklpy/hkl/configuration.py'>
2023-12-23T21:48:26.2428908Z [autodoc] getattr(_, 'DCConfiguration')
2023-12-23T21:48:26.2430174Z [autodoc] => <class 'hkl.configuration.DCConfiguration'>
2023-12-23T21:48:26.2431422Z [autodoc] getattr(_, 'canonical_axes')
2023-12-23T21:48:26.2433439Z [app] emitting event: 'build-finished'(TypeError("traceback_exception_init() got an unexpected keyword argument 'max_group_width'"),)

Switch to Py311 for this build

prjemian commented 6 months ago

Locally, docs fail 30 times on lines such as these examples:

autodoc: failed to import attribute 'DCConfiguration.canonical_axes' from module 'hkl.configuration'; the following exception was raised:
autodoc: failed to import attribute 'DCConfiguration.constraints' from module 'hkl.configuration'; the following exception was raised:
autodoc: failed to import attribute 'DCConfiguration.energy_keV' from module 'hkl.configuration'; the following exception was raised:
autodoc: failed to import attribute 'DCConfiguration.engine' from module 'hkl.configuration'; the following exception was raised:

All are classes using the @dataclass property.

prjemian commented 6 months ago

This SO post is helpful. When using type annotations and @dataclass property, need to help Sphinx out by being more explicit about how to describe the docs.

prjemian commented 6 months ago

Issue in trio repository related to this persistent error. This is trio 0.19.0. Our error starts with:

2023-12-23T22:42:31.9288016Z [autodoc] => <class 'hkl.configuration.DCConfiguration'>
2023-12-23T22:42:31.9289251Z [autodoc] getattr(_, 'geometry')
2023-12-23T22:42:31.9298270Z [app] emitting event: 'build-finished'(TypeError("traceback_exception_init() got an unexpected keyword argument 'max_group_width'"),)
2023-12-23T22:42:31.9300360Z 
2023-12-23T22:42:31.9338927Z Error in sys.excepthook:
2023-12-23T22:42:31.9339203Z Traceback (most recent call last):
2023-12-23T22:42:31.9340648Z   File "/home/runner/micromamba/envs/documentation/lib/python3.11/site-packages/dask/base.py", line 71, in wrapper
2023-12-23T22:42:31.9341217Z     return func(exc_type, exc.with_traceback(tb), tb)
2023-12-23T22:42:31.9342102Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-12-23T22:42:31.9343323Z   File "/home/runner/micromamba/envs/documentation/lib/python3.11/site-packages/trio/_core/_multierror.py", line 447, in trio_excepthook
2023-12-23T22:42:31.9344046Z     for chunk in traceback.format_exception(etype, value, tb):
2023-12-23T22:42:31.9346975Z                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-12-23T22:42:31.9348181Z   File "/home/runner/micromamba/envs/documentation/lib/python3.11/traceback.py", line 139, in format_exception
2023-12-23T22:42:31.9348894Z     te = TracebackException(type(value), value, tb, limit=limit, compact=True)
2023-12-23T22:42:31.9351416Z          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-12-23T22:42:31.9353171Z   File "/home/runner/micromamba/envs/documentation/lib/python3.11/site-packages/trio/_core/_multierror.py", line 393, in traceback_exception_init
prjemian commented 6 months ago

Locally, trio 0.23.2, which is latest release.

prjemian commented 6 months ago

@padraic-shafer @mrakitin This is ready now.

prjemian commented 6 months ago

@mrakitin @padraic-shafer - Anything else?

prjemian commented 6 months ago

Absent additional comments to be addressed, I plan to merge this PR by the end of 2024-01-10.

prjemian commented 6 months ago

@padraic-shafer @mrakitin : added the pipefail to the CI -- all tests pass at this time