From 4af04bbda481b787e8f421383256dc5deabe479b Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Dec 2023 00:55:57 -0600 Subject: [PATCH 01/38] ENV #316 more suitcases --- environment.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/environment.yml b/environment.yml index b573ab49..c6c1e425 100644 --- a/environment.yml +++ b/environment.yml @@ -25,6 +25,10 @@ dependencies: - pygobject - pyRestTable - spec2nexus + - suitcase-jsonl + - suitcase-mongo + - suitcase-msgpack + - suitcase-utils - tqdm - pip: - coveralls From b007ceefa44b08cd3e12d8585686c2b1b5c5ee4d Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Dec 2023 01:10:08 -0600 Subject: [PATCH 02/38] MNT #316 convert ResultTuple to ordinary tuple --- hkl/calc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hkl/calc.py b/hkl/calc.py index 9594d918..89940e2c 100644 --- a/hkl/calc.py +++ b/hkl/calc.py @@ -800,6 +800,11 @@ def __repr__(self): def __str__(self): return repr(self) + @property + def _cfg_reciprocal(self): + """Return reciprocal lattice to save as configuration.""" + return tuple(list(self.sample.reciprocal)) + class CalcE4CH(CalcRecip): """Geometry: E4CH""" From ce219d591cda1ae602ba6e6e8c269f466e907e57 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Dec 2023 01:10:36 -0600 Subject: [PATCH 03/38] MNT #316 can JSON serialize a tuple --- hkl/diffract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hkl/diffract.py b/hkl/diffract.py index 67bcb312..3911e549 100644 --- a/hkl/diffract.py +++ b/hkl/diffract.py @@ -168,7 +168,7 @@ class (using `calc_kw`) to instantiate a new one. lattice_reciprocal = Cpt( # fmt: off AttributeSignal, - attr="calc.sample.reciprocal", + attr="calc._cfg_reciprocal", doc="Reciprocal lattice", # fmt: on ) From d863efc619bc2904e061cecd3e364649ced238b7 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Dec 2023 01:26:21 -0600 Subject: [PATCH 04/38] MNT #303 type annotations for py38 --- hkl/configuration.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/hkl/configuration.py b/hkl/configuration.py index 1ca88756..c56bb546 100644 --- a/hkl/configuration.py +++ b/hkl/configuration.py @@ -38,6 +38,8 @@ from dataclasses import asdict from dataclasses import dataclass from dataclasses import field +from typing import Dict +from typing import List import numpy import pyRestTable @@ -187,13 +189,13 @@ def values(self): class DCReflection: """(internal) Configuration of one orientation reflection.""" - reflection: dict[str, float] + reflection: Dict[str, float] """ Reciprocal-space axis positions. Keys must match in the list of ``reciprocal_axes``. """ - position: dict[str, float] + position: Dict[str, float] """ Real-space axis positions. Keys must match in the list of ``canonical_axes``. @@ -233,17 +235,18 @@ class DCSample: lattice: DCLattice """Crystal lattice parameters (angstroms and degrees)""" - reflections: list[DCReflection] + reflections: List[DCReflection] """List of orientation reflections.""" - UB: list[list[float]] + UB: List[List[float]] """ Orientation matrix (3 x 3). U is the crystal orientation matrix relative to the diffractometer and B is the transition matrix of a non-orthonormal (the reciprocal of the crystal) in an orthonormal system. """ - U: list[list[float]] = field(default_factory=list[list[float]]) + # TODO: Once py38 is dropped, re-enable the default value setting + U: List[List[float]] # = field(default_factory=list[list[float]]) """ Orientation matrix (3 x 3) of the crystal relative to the diffractometer. (optional) @@ -337,14 +340,14 @@ class DCConfiguration: diffractometer to restore. """ - canonical_axes: list[str] + canonical_axes: List[str] """ List of the diffractometer real-space axis names. Both the exact spelling and order are defined by the back-end computation library. MUST match diffractometer to restore. """ - real_axes: list[str] + real_axes: List[str] """ User-defined real-space axis names. MUST match diffractometer to restore. The length and order of this list must be the same as the @@ -352,7 +355,7 @@ class DCConfiguration: names in this file. """ - reciprocal_axes: list[str] + reciprocal_axes: List[str] """ List of names of the diffractometer reciprocal-space (pseudo) axes. Both the exact spelling and order are defined by the back-end computation @@ -360,13 +363,13 @@ class DCConfiguration: MUST match diffractometer to restore. """ - constraints: dict[str, DCConstraint] + constraints: Dict[str, DCConstraint] """ Limits to be imposed on the real-space axes for operations and computations. Keys must match in the list of ``canonical_axes``. """ - samples: dict[str, DCSample] + samples: Dict[str, DCSample] """ Crystalline samples (lattice and orientation reflections). The sample name is used as the key in the dictionary. @@ -410,7 +413,7 @@ class DCConfiguration: Name of the Python class that defines this diffractometer. (optional) """ - other: dict[str, typing.Any] = field(default_factory=dict) + other: Dict[str, typing.Any] = field(default_factory=dict) """ *Any* other content goes into this dictionary (comments, unanticipated keys, ...) (optional) From 824108386a810f6359565ffd4fc97ab7faabc9e5 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Dec 2023 01:32:48 -0600 Subject: [PATCH 05/38] CI #316 hints --- .github/workflows/conda_unit_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index cb22b0b2..e914b1f0 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -71,6 +71,6 @@ jobs: - name: Test with coverage and pytest shell: bash -l {0} run: | - coverage run --concurrency=thread --parallel-mode -m pytest -vvv + coverage run --concurrency=thread --parallel-mode -m pytest -vvv # --exitfirst . coverage combine - coverage report + coverage report--precision 3 From e0ba082db35120efa7d01b60af74fad419ce8d84 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Tue, 19 Dec 2023 01:34:16 -0600 Subject: [PATCH 06/38] DOC #316 --- RELEASE_NOTES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index c08ec4ad..66df6036 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -38,6 +38,7 @@ New Features and/or Enhancements Fixes ----- +* Resolved under-reported problems in CI unit tests. * ``util.restore_reflections()`` use renamed motor axes if so defined. Maintenance From 7fe8b47ffa4bd0cdd65220a975440fde876e920b Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Fri, 22 Dec 2023 17:08:47 -0600 Subject: [PATCH 07/38] TST #316 more diagnostic tools --- hkl/tests/tools.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/hkl/tests/tools.py b/hkl/tests/tools.py index 7e0f6e24..f002540f 100644 --- a/hkl/tests/tools.py +++ b/hkl/tests/tools.py @@ -7,6 +7,7 @@ import logging import numpy +from tiled.utils import safe_json_dump from ..util import new_lattice @@ -16,6 +17,18 @@ TWO_PI = 2 * numpy.pi +class DocsCollector: + """Collect representative documents from the RE.""" + + def __init__(self) -> None: + self.raw = {} + self.safe_json = {} + + def receiver(self, key, doc): + self.raw[key] = doc + self.safe_json[key] = safe_json_dump(doc) + + def new_sample(diffractometer, name, lattice): return diffractometer.calc.new_sample(name, lattice=lattice) @@ -36,3 +49,32 @@ def sample_vibranium(diffractometer): a0 = TWO_PI cubic = new_lattice(a0) return new_sample(diffractometer, "vibranium", lattice=cubic) + + +def validate_descriptor_doc_content(gname, descriptor): + """Validate the descriptor document content.""" + assert isinstance(descriptor, dict) + + config = descriptor.get("configuration") + assert isinstance(config, dict) + + diffractometer_config = config.get(gname) + assert isinstance(diffractometer_config, dict) + + assert "data" in diffractometer_config + data = diffractometer_config.get("data") + assert isinstance(data, dict) + + assert isinstance(data[f"{gname}_sample_name"], str) + assert isinstance(data[f"{gname}_lattice"], (numpy.ndarray, list)) + assert isinstance(data[f"{gname}_lattice_reciprocal"], (tuple, list)) + assert isinstance(data[f"{gname}_U"], (numpy.ndarray, list)) + assert isinstance(data[f"{gname}_UB"], (numpy.ndarray, list)) + assert isinstance(data[f"{gname}_reflections_details"], list) + assert isinstance(data[f"{gname}__pseudos"], (tuple, list)) + assert isinstance(data[f"{gname}__reals"], (tuple, list)) + assert isinstance(data[f"{gname}__constraints"], (numpy.ndarray, list)) + assert isinstance(data[f"{gname}_ux"], float) + assert isinstance(data[f"{gname}_uy"], float) + assert isinstance(data[f"{gname}_uz"], float) + assert isinstance(data[f"{gname}_orientation_attrs"], list) From 9ad8e040d0659e7f75b0e43d79d4a19d0421ecb2 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Fri, 22 Dec 2023 17:11:19 -0600 Subject: [PATCH 08/38] TST #316 --- hkl/tests/test_util.py | 89 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/hkl/tests/test_util.py b/hkl/tests/test_util.py index 967e5e13..f7cc8a71 100644 --- a/hkl/tests/test_util.py +++ b/hkl/tests/test_util.py @@ -1,7 +1,18 @@ +"""Test the hkl.util module.""" + +import json +import time + +import databroker import pytest +from bluesky import plans as bp +from bluesky.run_engine import RunEngine from packaging import version +from tiled.utils import safe_json_dump -import hkl.util +from .. import util +from .tools import DocsCollector +from .tools import validate_descriptor_doc_content NO_SUCH_PACKAGE_NAME = "no-such-package" @@ -78,9 +89,9 @@ def crystal_setup(diffractometer): def test__package_info_states(): - assert hkl.util._package_info is None - hkl.util.get_package_info("hkl") - assert hkl.util._package_info is not None + assert util._package_info is None + util.get_package_info("hkl") + assert util._package_info is not None @pytest.mark.parametrize( @@ -95,7 +106,7 @@ def test__package_info_states(): ], ) def test_get_package_info(package_name, minimum_version): - v = hkl.util.get_package_info(package_name) + v = util.get_package_info(package_name) if v is None: assert package_name in ("hklpy", NO_SUCH_PACKAGE_NAME) else: @@ -120,9 +131,9 @@ def test_get_package_info(package_name, minimum_version): # fmt: on ) def test_software_versions_default_list(case): - v = hkl.util.software_versions(case) + v = util.software_versions(case) assert isinstance(v, dict) - expected = sorted(hkl.util.DEFAULT_PACKAGE_LIST) + expected = sorted(util.DEFAULT_PACKAGE_LIST) assert sorted(v.keys()) == expected @@ -138,7 +149,7 @@ def test_software_versions_default_list(case): ], ) def test_software_versions_items(package_name, minimum_version): - v = hkl.util.software_versions([package_name]) + v = util.software_versions([package_name]) if package_name in v: v_string = v[package_name] v_package = version.parse(v_string) @@ -174,10 +185,11 @@ def test_issue215(cat, RE, fourc): assert len(cat) == 0 uids = RE(bp.count([fourc])) + time.sleep(1) assert len(uids) == 1 assert len(cat) == 1 - orientation = hkl.util.run_orientation_info(cat[-1]) + orientation = util.run_orientation_info(cat[-1]) assert isinstance(orientation, dict) assert fourc.name in orientation # assert list(orientation.keys()) == [] @@ -191,7 +203,64 @@ def test_issue215(cat, RE, fourc): success = False try: # since it is just a problem of motor names in reflections ... - hkl.util.restore_reflections(orient, fourc) + util.restore_reflections(orient, fourc) success = True finally: assert success, "Could not restore orientation reflections." + + +@pytest.mark.parametrize("use_refl", [None, "short", "long"]) +def test_RE_documents(use_refl, e4cv): + """Issue #316.""" + + docs = DocsCollector() # capture the raw document stream directly + assert len(docs.raw) == 0 + + # add a reflection? + if use_refl == "short": + e4cv.calc.sample.add_reflection(1, 2, 3, (40, 0, 0, 60)) + elif use_refl == "long": + # fmt: off + e4cv.calc.sample.add_reflection( + 1, 2, 3, + position=e4cv.calc.Position(tth=60, omega=40, chi=0, phi=0), + ) + # fmt: on + refs = e4cv.reflections.get() + assert isinstance(refs, list) + assert len(refs) == len(e4cv.calc.sample.reflections) + if len(refs) > 0: + assert list(refs[0]) == [1.0, 2.0, 3.0] + + safe = safe_json_dump(refs) + assert isinstance(safe, bytes) + + assert isinstance(safe_json_dump(e4cv.reflections_details.get()), bytes) + # assert f"{refs=!r}" == "debug" + + RE = RunEngine() + cat = databroker.temp().v2 + RE.subscribe(cat.v1.insert) + + uids = RE(bp.count([e4cv]), docs.receiver) + assert len(uids) == 1 + assert len(docs.raw) == 4 + + # Get the configuration from the raw document stream + validate_descriptor_doc_content(e4cv.name, docs.raw.get("descriptor")) + + # Get the configuration from the safe_json version of the document stream + # difference: np.ndarray --> list + # difference: tuple --> list + descriptor = docs.safe_json.get("descriptor") + assert isinstance(descriptor, bytes) + validate_descriptor_doc_content(e4cv.name, json.loads(docs.safe_json.get("descriptor"))) + + # Get the configuration from the databroker document stream + for key, doc in cat.v1[uids[0]].documents(): + if key == "descriptor": + validate_descriptor_doc_content(e4cv.name, doc) + + orientation = util.run_orientation_info(cat[uids[0]]) + assert isinstance(orientation, dict) + assert e4cv.name in orientation From dfb7f1861a7462d30d3847f166e66361f90ad8a5 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Fri, 22 Dec 2023 17:11:50 -0600 Subject: [PATCH 09/38] MNT #316 refactor to use a list --- hkl/diffract.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hkl/diffract.py b/hkl/diffract.py index 3911e549..0a9b5595 100644 --- a/hkl/diffract.py +++ b/hkl/diffract.py @@ -177,8 +177,8 @@ class (using `calc_kw`) to instantiate a new one. UB = Cpt(AttributeSignal, attr="calc.sample.UB", doc="UB matrix") # fmt: off reflections = Cpt( - ArrayAttributeSignal, - attr="calc.sample.reflections", + AttributeSignal, + attr="_reflections", doc="Reflections", ) reflections_details = Cpt( @@ -449,6 +449,11 @@ def engine(self): # -- it becomes a problem when someone uses these functions # outside of move() + @property + def _reflections(self): + """Return the list of reflections as a [[float]]""" + return [list(r) for r in self.calc.sample.reflections] + @pseudo_position_argument def forward(self, pseudo): """ From 8b60e8b8986d1ebed1c8261fc91e4c220885a2ab Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 08:59:49 -0600 Subject: [PATCH 10/38] CI #316 databroker version in test matrix --- .github/workflows/conda_unit_test.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index e914b1f0..db3d7d41 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -27,25 +27,29 @@ jobs: - "3.9" - "3.10" - "3.11" - max-parallel: 5 + databroker-version: + - "=1.2" + - ">1.3" + max-parallel: 5 steps: - uses: actions/checkout@v4 - - - name: Create Python ${{ matrix.python-version }} environment + + - name: Create Python ${{ matrix.python-version }} Databroker ${{ matrix.databroker-version }} environment uses: mamba-org/setup-micromamba@v1 with: cache-environment: true - cache-environment-key: env-key-${{ matrix.python-version }} + cache-environment-key: env-key-${{ matrix.python-version }}-${{ matrix.databroker-version }} condarc: | channel-priority: flexible environment-file: environment.yml - environment-name: hklpy-test-py-${{ matrix.python-version }} + environment-name: hklpy-test-py-${{ matrix.python-version }}-${{ matrix.databroker-version }} create-args: >- coveralls pytest pytest-cov python=${{ matrix.python-version }} + databroker ${{ matrix.databroker-version }} - name: conda environments shell: bash -l {0} From a5fa404414ef203e171795bffcca2a04f08b30a8 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:01:27 -0600 Subject: [PATCH 11/38] STY #316 trailing whitespace --- .github/workflows/conda_unit_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index db3d7d41..5bc3ca28 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -34,7 +34,7 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Create Python ${{ matrix.python-version }} Databroker ${{ matrix.databroker-version }} environment uses: mamba-org/setup-micromamba@v1 with: From ec99c7e89051395d79faeab25b49cfecd05f7b0b Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:08:40 -0600 Subject: [PATCH 12/38] CI #316 syntax --- .github/workflows/conda_unit_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index 5bc3ca28..558faf6f 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -28,9 +28,9 @@ jobs: - "3.10" - "3.11" databroker-version: - - "=1.2" - - ">1.3" - max-parallel: 5 + - "=1.2" + - ">1.3" + max-parallel: 5 steps: - uses: actions/checkout@v4 From f53235de6a4853d69d0356daa8e0542bcf362127 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:13:48 -0600 Subject: [PATCH 13/38] CI #316 explicit versions --- .github/workflows/conda_unit_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index 558faf6f..4b7785df 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -28,8 +28,8 @@ jobs: - "3.10" - "3.11" databroker-version: - - "=1.2" - - ">1.3" + - "1.2.5" + - "2.0.0b31" max-parallel: 5 steps: @@ -49,7 +49,7 @@ jobs: pytest pytest-cov python=${{ matrix.python-version }} - databroker ${{ matrix.databroker-version }} + databroker=${{ matrix.databroker-version }} - name: conda environments shell: bash -l {0} From 1d3a91a0b1ed31e9ee4085af58275eefbc40c8cd Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:18:59 -0600 Subject: [PATCH 14/38] CI #316 syntax --- .github/workflows/conda_unit_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index 4b7785df..5b4a257c 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -21,6 +21,7 @@ jobs: runs-on: ubuntu-latest # needs: lint strategy: + max-parallel: 5 matrix: python-version: - "3.8" @@ -30,7 +31,6 @@ jobs: databroker-version: - "1.2.5" - "2.0.0b31" - max-parallel: 5 steps: - uses: actions/checkout@v4 From ae2028c57bcf1872386fefc7d1c61f0bf3299572 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:25:55 -0600 Subject: [PATCH 15/38] ENV #316 require tiled --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index c6c1e425..c910e424 100644 --- a/environment.yml +++ b/environment.yml @@ -29,6 +29,7 @@ dependencies: - suitcase-mongo - suitcase-msgpack - suitcase-utils + - tiled - tqdm - pip: - coveralls From 4da2327781caca21ea7fda4dd0c1b7a080f8d816 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:36:50 -0600 Subject: [PATCH 16/38] CI #316 pick tiled version --- .github/workflows/conda_unit_test.yml | 8 ++++++++ environment.yml | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index 5b4a257c..3c66161b 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -31,6 +31,13 @@ jobs: databroker-version: - "1.2.5" - "2.0.0b31" + include: + - databroker-version: "1.2.5" + tiled-version: + - "0.1.0a96" + - databroker-version: "1.2.5" + tiled-version: + - "0.1.0a110" steps: - uses: actions/checkout@v4 @@ -50,6 +57,7 @@ jobs: pytest-cov python=${{ matrix.python-version }} databroker=${{ matrix.databroker-version }} + tiled=${{ matrix.tiled-version }} - name: conda environments shell: bash -l {0} diff --git a/environment.yml b/environment.yml index c910e424..c6c1e425 100644 --- a/environment.yml +++ b/environment.yml @@ -29,7 +29,6 @@ dependencies: - suitcase-mongo - suitcase-msgpack - suitcase-utils - - tiled - tqdm - pip: - coveralls From c4fdb7379da1d5345a6ac57c24d8dfabad536fd5 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:40:03 -0600 Subject: [PATCH 17/38] CI #316 typo --- .github/workflows/conda_unit_test.yml | 2 +- hkl/util.py | 28 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index 3c66161b..7c91d8ae 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -35,7 +35,7 @@ jobs: - databroker-version: "1.2.5" tiled-version: - "0.1.0a96" - - databroker-version: "1.2.5" + - databroker-version: "2.0.0b31" tiled-version: - "0.1.0a110" diff --git a/hkl/util.py b/hkl/util.py index 287e91b2..c6ca51ee 100644 --- a/hkl/util.py +++ b/hkl/util.py @@ -344,16 +344,28 @@ def run_orientation_info(run): devices = {} try: run_conf = run.primary.config + _aaa = type(run_conf).__name__ for device in sorted(run_conf): - conf = run_conf[device].read() - if f"{device}_orientation_attrs" in conf: - # fmt:off - devices[device] = { - item[len(device)+1:]: conf[item].to_dict()["data"][0] - for item in conf - } - # fmt:on + if type(run_conf).__name__ == "Catalog": # intake catalog + conf = run_conf[device].read() + if f"{device}_orientation_attrs" in conf: + # fmt:off + devices[device] = { + item[len(device)+1:]: conf[item].to_dict()["data"][0] + for item in conf + } + # fmt:on + elif type(run_conf).__name__ == "Container": # tiled container + import yaml + + _bbb = run_conf.read() + _bbb = run_conf.item["attributes"]["structure"] + conf = run_conf.get(device) + print(yaml.dump(conf, indent=2, sort_keys=False)) + else: + raise TypeError(f"Not prepared to handle {type(run_conf)} documents.") except Exception as exc: + print(f"{exc=}") logger.warning("Could not process run %s, due to %s", run, exc) return devices From 8f745c7d06cc895818353f529ba6cb847c822214 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:42:15 -0600 Subject: [PATCH 18/38] CI #316 simpler --- .github/workflows/conda_unit_test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index 7c91d8ae..a7bd3b99 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -30,14 +30,14 @@ jobs: - "3.11" databroker-version: - "1.2.5" - - "2.0.0b31" + # - "2.0.0b31" include: - databroker-version: "1.2.5" tiled-version: - "0.1.0a96" - - databroker-version: "2.0.0b31" - tiled-version: - - "0.1.0a110" + # - databroker-version: "2.0.0b31" + # tiled-version: + # - "0.1.0a110" steps: - uses: actions/checkout@v4 From 0a5af3c181441563c24b0cd188523b65f40eaad9 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 09:44:14 -0600 Subject: [PATCH 19/38] MNT #316 revert changes in commit c4fdb7379da --- hkl/util.py | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/hkl/util.py b/hkl/util.py index c6ca51ee..287e91b2 100644 --- a/hkl/util.py +++ b/hkl/util.py @@ -344,28 +344,16 @@ def run_orientation_info(run): devices = {} try: run_conf = run.primary.config - _aaa = type(run_conf).__name__ for device in sorted(run_conf): - if type(run_conf).__name__ == "Catalog": # intake catalog - conf = run_conf[device].read() - if f"{device}_orientation_attrs" in conf: - # fmt:off - devices[device] = { - item[len(device)+1:]: conf[item].to_dict()["data"][0] - for item in conf - } - # fmt:on - elif type(run_conf).__name__ == "Container": # tiled container - import yaml - - _bbb = run_conf.read() - _bbb = run_conf.item["attributes"]["structure"] - conf = run_conf.get(device) - print(yaml.dump(conf, indent=2, sort_keys=False)) - else: - raise TypeError(f"Not prepared to handle {type(run_conf)} documents.") + conf = run_conf[device].read() + if f"{device}_orientation_attrs" in conf: + # fmt:off + devices[device] = { + item[len(device)+1:]: conf[item].to_dict()["data"][0] + for item in conf + } + # fmt:on except Exception as exc: - print(f"{exc=}") logger.warning("Could not process run %s, due to %s", run, exc) return devices From 535c74bc96847cebe681c7beed9a4a77a5d44237 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 10:39:42 -0600 Subject: [PATCH 20/38] CI #316 --- .github/workflows/conda_unit_test.yml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index a7bd3b99..f14eb384 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -28,36 +28,26 @@ jobs: - "3.9" - "3.10" - "3.11" - databroker-version: - - "1.2.5" - # - "2.0.0b31" - include: - - databroker-version: "1.2.5" - tiled-version: - - "0.1.0a96" - # - databroker-version: "2.0.0b31" - # tiled-version: - # - "0.1.0a110" steps: - uses: actions/checkout@v4 - - name: Create Python ${{ matrix.python-version }} Databroker ${{ matrix.databroker-version }} environment + - name: Create Python ${{ matrix.python-version }} environment uses: mamba-org/setup-micromamba@v1 with: cache-environment: true - cache-environment-key: env-key-${{ matrix.python-version }}-${{ matrix.databroker-version }} + cache-environment-key: env-key-${{ matrix.python-version }} condarc: | channel-priority: flexible environment-file: environment.yml - environment-name: hklpy-test-py-${{ matrix.python-version }}-${{ matrix.databroker-version }} + environment-name: hklpy-test-py-${{ matrix.python-version }} create-args: >- coveralls pytest pytest-cov python=${{ matrix.python-version }} - databroker=${{ matrix.databroker-version }} - tiled=${{ matrix.tiled-version }} + databroker=1.2.5 + tiled=0.1.0a96 - name: conda environments shell: bash -l {0} From aa1e0c59bdda8013fc5a50a55fc2aff189686160 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 10:47:39 -0600 Subject: [PATCH 21/38] CI #316 --- .github/workflows/conda_unit_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index f14eb384..c55a8a97 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -75,4 +75,4 @@ jobs: run: | coverage run --concurrency=thread --parallel-mode -m pytest -vvv # --exitfirst . coverage combine - coverage report--precision 3 + coverage report From 6a4ceaa65bc25514a1005236a16b138aa6bc2b96 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 11:12:28 -0600 Subject: [PATCH 22/38] MNT #316 error for databroker v2 now --- hkl/util.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hkl/util.py b/hkl/util.py index 287e91b2..5825a285 100644 --- a/hkl/util.py +++ b/hkl/util.py @@ -26,8 +26,6 @@ .. [#] https://physics.nist.gov/cgi-bin/cuu/Value?asil """ -from __future__ import print_function - import logging import subprocess import sys @@ -341,6 +339,14 @@ def run_orientation_info(run): run : from Databroker A Bluesky run, from databroker v2, such as ``cat.v2[-1]``. """ + import databroker + + if databroker.__version__ >= "2.0": + raise ValueError( + f"This function does not work with databroker {databroker.__version__}." + " See https://github.com/bluesky/hklpy/pull/317 for details." + ) + devices = {} try: run_conf = run.primary.config From 861cf5ab24bb401a8ee4c1ccf6c39083def9f232 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 11:17:26 -0600 Subject: [PATCH 23/38] DOC #316 --- RELEASE_NOTES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index ad1eb990..2e989782 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -40,6 +40,7 @@ Fixes * ``diffract.forward()`` should pick solution consistent with ``diffract.forward_solution_table()``, if it can. Otherwise, fall back to previous iterative method. * Resolved under-reported problems in CI unit tests. +* Raise ValueError in ``util.run_orientation_info()`` for databroker v2+. * ``util.restore_reflections()`` use renamed motor axes if so defined. Maintenance @@ -52,6 +53,8 @@ Maintenance * Documentation ZIP file uploaded as artifact with each build. Great for review! * Expand testing to to Py3.8 - Py3.11. * Fix code in ``util.restore_reflections()`` that failed unit tests locally. +* Pin databroker 1.2 (issue #316). +* Pin tiled <=0.1.0a96 (issue #316). * Make it easier to find the SPEC command cross-reference table. * Update packaging to latest PyPA recommendations. * Validate user input to sample.add_reflection(). From 1f4b46263b528c5b88a3d3877ba6c675c1e1d353 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 11:24:52 -0600 Subject: [PATCH 24/38] PKG #316 pin databroker version --- .github/workflows/conda_unit_test.yml | 2 -- RELEASE_NOTES.rst | 1 - environment.yml | 1 + hkl/tests/test_util.py | 2 -- pyproject.toml | 3 ++- 5 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index c55a8a97..66e972b1 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -46,8 +46,6 @@ jobs: pytest pytest-cov python=${{ matrix.python-version }} - databroker=1.2.5 - tiled=0.1.0a96 - name: conda environments shell: bash -l {0} diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 2e989782..9213cf7b 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -54,7 +54,6 @@ Maintenance * Expand testing to to Py3.8 - Py3.11. * Fix code in ``util.restore_reflections()`` that failed unit tests locally. * Pin databroker 1.2 (issue #316). -* Pin tiled <=0.1.0a96 (issue #316). * Make it easier to find the SPEC command cross-reference table. * Update packaging to latest PyPA recommendations. * Validate user input to sample.add_reflection(). diff --git a/environment.yml b/environment.yml index c6c1e425..9b633d7c 100644 --- a/environment.yml +++ b/environment.yml @@ -15,6 +15,7 @@ dependencies: - python >=3.8,<3.12 - apischema - bluesky + - databroker =1.2 - hkl - numpy - ophyd diff --git a/hkl/tests/test_util.py b/hkl/tests/test_util.py index f7cc8a71..6434051e 100644 --- a/hkl/tests/test_util.py +++ b/hkl/tests/test_util.py @@ -19,8 +19,6 @@ @pytest.fixture(scope="function") def cat(): - import databroker - yield databroker.temp().v2 diff --git a/pyproject.toml b/pyproject.toml index 697f24f6..62c68939 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ classifiers = [ # pyqt ==5 dependencies = [ "apischema", + "databroker =1.2", "numpy", "ophyd", "pint", @@ -64,7 +65,7 @@ docs = [ ] tests = [ "bluesky", - "databroker", + "tiled <=0.1.0a96", "packaging", ] all = ["hklpy[docs,tests]"] From e6014fdad59052adb4e20a86180d64da4eb0fcd2 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 11:41:30 -0600 Subject: [PATCH 25/38] PKG #316 syntax --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 62c68939..e9906d6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ classifiers = [ # pyqt ==5 dependencies = [ "apischema", - "databroker =1.2", + "databroker ==1.2", "numpy", "ophyd", "pint", From 68de7488bfbc32d746ee6140fd2eedac22378edb Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 11:54:47 -0600 Subject: [PATCH 26/38] DOC #316 --- RELEASE_NOTES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 9213cf7b..91d0379c 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -53,7 +53,7 @@ Maintenance * Documentation ZIP file uploaded as artifact with each build. Great for review! * Expand testing to to Py3.8 - Py3.11. * Fix code in ``util.restore_reflections()`` that failed unit tests locally. -* Pin databroker 1.2 (issue #316). +* Pin databroker 1.2 (issues #316 & #318). * Make it easier to find the SPEC command cross-reference table. * Update packaging to latest PyPA recommendations. * Validate user input to sample.add_reflection(). From 2bd334d3c97b070b7da2b1ac8ebc20d7c68bc64d Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 14:48:40 -0600 Subject: [PATCH 27/38] MNT #318 enable use of databroker v2+ --- RELEASE_NOTES.rst | 4 +- environment.yml | 2 +- hkl/tests/test_save_restore_UB.py | 72 +++++++++++++++++++++++-------- hkl/util.py | 48 +++++++++++++-------- pyproject.toml | 4 +- 5 files changed, 87 insertions(+), 43 deletions(-) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 91d0379c..9947a126 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -39,8 +39,9 @@ Fixes ----- * ``diffract.forward()`` should pick solution consistent with ``diffract.forward_solution_table()``, if it can. Otherwise, fall back to previous iterative method. +* Make ``util.list_orientation_runs()`` work with databroker v1.2 or v2+. +* Make ``util.run_orientation_info()`` work with databroker v1.2 or v2+. * Resolved under-reported problems in CI unit tests. -* Raise ValueError in ``util.run_orientation_info()`` for databroker v2+. * ``util.restore_reflections()`` use renamed motor axes if so defined. Maintenance @@ -53,7 +54,6 @@ Maintenance * Documentation ZIP file uploaded as artifact with each build. Great for review! * Expand testing to to Py3.8 - Py3.11. * Fix code in ``util.restore_reflections()`` that failed unit tests locally. -* Pin databroker 1.2 (issues #316 & #318). * Make it easier to find the SPEC command cross-reference table. * Update packaging to latest PyPA recommendations. * Validate user input to sample.add_reflection(). diff --git a/environment.yml b/environment.yml index 9b633d7c..093a7779 100644 --- a/environment.yml +++ b/environment.yml @@ -15,7 +15,7 @@ dependencies: - python >=3.8,<3.12 - apischema - bluesky - - databroker =1.2 + - databroker - hkl - numpy - ophyd diff --git a/hkl/tests/test_save_restore_UB.py b/hkl/tests/test_save_restore_UB.py index 9f44e6d0..7ca4fddb 100644 --- a/hkl/tests/test_save_restore_UB.py +++ b/hkl/tests/test_save_restore_UB.py @@ -1,3 +1,5 @@ +import time + import bluesky.plans as bp import databroker import numpy.testing @@ -84,18 +86,16 @@ def test_fourc_orientation_save(cat, RE, fourc): # this run will not save orientation information _uids = RE(bp.count([det])) assert len(_uids) == 1 + time.sleep(1) assert len(cat) == 1 assert "fourc" not in cat[1].primary.config # this run _will_ save orientation information _uids = RE(bp.count([det, fourc])) assert len(_uids) == 1 + time.sleep(1) assert len(cat) == 2 - xarray_data = cat[2].primary.config["fourc"].read() - assert not isinstance(xarray_data, dict) - descriptors = xarray_data.to_dict() - assert isinstance(descriptors, dict) - assert list(descriptors.keys()) == "coords attrs dims data_vars".split() + key_list = """ _pseudos _reals @@ -108,20 +108,54 @@ def test_fourc_orientation_save(cat, RE, fourc): sample_name UB """.split() - for key in key_list: - key_name = f"fourc_{key}" - assert hasattr(xarray_data, key_name) - assert key_name in descriptors["data_vars"] - - assert xarray_data.fourc_class_name == "Fourc" - assert xarray_data.fourc_geometry_name == "E4CV" - assert xarray_data.fourc_diffractometer_name == "fourc" - assert xarray_data.fourc_sample_name == "Si" - - assert len(xarray_data.fourc__pseudos) == 1 - assert xarray_data.fourc__pseudos[0].values.tolist() == "h k l".split() - assert len(xarray_data.fourc__reals) == 1 - assert xarray_data.fourc__reals.values[0].tolist() == "omega chi phi tth".split() + + if databroker.__version__ < "2.0": + conf = cat[_uids[0]].primary.config["fourc"].read() + assert not isinstance(conf, dict) + descriptors = conf.to_dict() + assert isinstance(descriptors, dict) + assert list(descriptors.keys()) == "coords attrs dims data_vars".split() + for key in key_list: + key_name = f"fourc_{key}" + assert hasattr(conf, key_name) + assert key_name in descriptors["data_vars"] + + assert conf.fourc_class_name == "Fourc" + assert conf.fourc_geometry_name == "E4CV" + assert conf.fourc_diffractometer_name == "fourc" + assert conf.fourc_sample_name == "Si" + + assert len(conf.fourc__pseudos) == 1 + assert conf.fourc__pseudos[0].values.tolist() == "h k l".split() + assert len(conf.fourc__reals) == 1 + assert conf.fourc__reals.values[0].tolist() == "omega chi phi tth".split() + + else: + descriptors = cat[_uids[0]].primary.descriptors + assert isinstance(descriptors, list) + assert len(descriptors) > 0 + for descriptor in descriptors: + for device, configuration in descriptor.get("configuration", {}).items(): + assert isinstance(device, str) + assert isinstance(configuration, dict) + conf = configuration.get("data", {}) + assert isinstance(conf, dict) + + if device != "fourc": + continue + for key in key_list: + key_name = f"fourc_{key}" + assert key_name in conf + + assert conf["fourc_class_name"] == "Fourc" + assert conf["fourc_geometry_name"] == "E4CV" + assert conf["fourc_diffractometer_name"] == "fourc" + assert conf["fourc_sample_name"] == "Si" + + assert len(conf["fourc__pseudos"]) == 3 + assert conf["fourc__pseudos"] == "h k l".split() + assert len(conf["fourc__reals"]) == 4 + assert conf["fourc__reals"] == "omega chi phi tth".split() def test_fourc_run_orientation_info(cat, RE, fourc): diff --git a/hkl/util.py b/hkl/util.py index 5825a285..0704980f 100644 --- a/hkl/util.py +++ b/hkl/util.py @@ -32,6 +32,7 @@ from collections import defaultdict from collections import namedtuple +import databroker import gi import numpy as np import pandas as pd @@ -306,7 +307,10 @@ def list_orientation_runs(catalog, *args, limit=20): info = run_orientation_info(run) if len(info): scan_id = run.metadata["start"]["scan_id"] - uid = run.name[:7] + if databroker.__version__ >= "2.0": + uid = run.start["uid"][:7] + else: + uid = run.name[:7] for device in sorted(info.keys()): orientation = info[device] row = dict(scan_id=scan_id) @@ -339,26 +343,32 @@ def run_orientation_info(run): run : from Databroker A Bluesky run, from databroker v2, such as ``cat.v2[-1]``. """ - import databroker - - if databroker.__version__ >= "2.0": - raise ValueError( - f"This function does not work with databroker {databroker.__version__}." - " See https://github.com/bluesky/hklpy/pull/317 for details." - ) - devices = {} + try: - run_conf = run.primary.config - for device in sorted(run_conf): - conf = run_conf[device].read() - if f"{device}_orientation_attrs" in conf: - # fmt:off - devices[device] = { - item[len(device)+1:]: conf[item].to_dict()["data"][0] - for item in conf - } - # fmt:on + if databroker.__version__ >= "2.0": + for descriptor in run.primary.descriptors: + for device, configuration in descriptor.get("configuration", {}).items(): + conf = configuration.get("data", {}) + if f"{device}_orientation_attrs" in conf: + # fmt:off + devices[device] = { + item[len(device) + 1:]: value + for item, value in conf.items() + } + # fmt:on + + else: # older databroker v1.2 + run_conf = run.primary.config + for device in sorted(run_conf): + conf = run_conf[device].read() + if f"{device}_orientation_attrs" in conf: + # fmt:off + devices[device] = { + item[len(device)+1:]: conf[item].to_dict()["data"][0] + for item in conf + } + # fmt:on except Exception as exc: logger.warning("Could not process run %s, due to %s", run, exc) return devices diff --git a/pyproject.toml b/pyproject.toml index e9906d6a..a8197336 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ classifiers = [ # pyqt ==5 dependencies = [ "apischema", - "databroker ==1.2", + "databroker", "numpy", "ophyd", "pint", @@ -65,7 +65,7 @@ docs = [ ] tests = [ "bluesky", - "tiled <=0.1.0a96", + "tiled", "packaging", ] all = ["hklpy[docs,tests]"] From 1fc55ef19154d64208fbfb1fdf357e14442498ea Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 15:33:51 -0600 Subject: [PATCH 28/38] CI #317 require chardet package for sphinx --- env-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/env-dev.yml b/env-dev.yml index e2ebbeb6..a6bc4152 100644 --- a/env-dev.yml +++ b/env-dev.yml @@ -16,6 +16,7 @@ dependencies: - apischema - black - bluesky + - chardet - databroker - flake8 - hkl From f9b18ca64a432cf0c0308f06c1524a79adfe4905 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 15:46:47 -0600 Subject: [PATCH 29/38] CI #318 verbose logging --- docs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index d0c3cbf1..70cf0a7e 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS ?= +SPHINXOPTS ?= -vv SPHINXBUILD ?= sphinx-build SOURCEDIR = source BUILDDIR = build From 97d8a27772da2a94079a13235b699fad2284772c Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 15:54:06 -0600 Subject: [PATCH 30/38] CI #317 build docs with py311 --- .github/workflows/publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 340f4f58..6c5e48e8 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: [3.11] steps: - name: Set env vars From f6000bb5d7e14c9169787f9602be101ad28d5de5 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 16:41:35 -0600 Subject: [PATCH 31/38] DOC #317 cite each dataclass separately --- docs/source/configuration.rst | 62 ++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index d076ecc6..e328a942 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -169,7 +169,67 @@ API .. automodule:: hkl.configuration :members: DiffractometerConfiguration, - DCConstraint, DCLattice, DCReflection, DCSample, DCConfiguration, _check_key, _check_not_value, _check_range, _check_type, _check_value :private-members: :undoc-members: + +.. autoclass:: hkl.configuration.DCConfiguration + + .. autoattribute:: geometry + .. autoattribute:: engine + .. autoattribute:: library + .. autoattribute:: mode + .. autoattribute:: canonical_axes + .. autoattribute:: real_axes + .. autoattribute:: reciprocal_axes + .. autoattribute:: samples + .. autoattribute:: samples + .. autoattribute:: name + .. autoattribute:: datetime + .. autoattribute:: wavelength_angstrom + .. autoattribute:: energy_keV + .. autoattribute:: hklpy_version + .. autoattribute:: library_version + .. autoattribute:: python_class + .. autoattribute:: other + .. automethod:: validate + .. automethod:: write + +.. autoclass:: hkl.configuration.DCConstraint + + .. autoattribute:: low_limit + .. autoattribute:: high_limit + .. autoattribute:: value + .. autoattribute:: fit + .. automethod:: validate + .. autoproperty:: values + +.. autoclass:: hkl.configuration.DCLattice + + .. autoattribute:: a + .. autoattribute:: b + .. autoattribute:: c + .. autoattribute:: alpha + .. autoattribute:: beta + .. autoattribute:: gamma + .. automethod:: validate + .. autoproperty:: values + +.. autoclass:: hkl.configuration.DCReflection + + .. autoattribute:: reflection + .. autoattribute:: position + .. autoattribute:: wavelength + .. autoattribute:: orientation_reflection + .. autoattribute:: flag + .. automethod:: validate + +.. autoclass:: hkl.configuration.DCSample + + .. autoattribute:: name + .. autoattribute:: lattice + .. autoattribute:: reflections + .. autoattribute:: UB + .. autoattribute:: U + .. automethod:: validate + .. automethod:: write From 154accf1827c3cc347ee0eec02e44b24290f0167 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 16:56:50 -0600 Subject: [PATCH 32/38] CI #317 pin trio package version --- env-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/env-dev.yml b/env-dev.yml index a6bc4152..72ee9956 100644 --- a/env-dev.yml +++ b/env-dev.yml @@ -36,6 +36,7 @@ dependencies: - spec2nexus - sphinx - tqdm + - trio >=0.22 - pip: - coveralls - pytest From 496e25f357191a82d81578ccc155fe3238b95646 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 23 Dec 2023 17:06:06 -0600 Subject: [PATCH 33/38] CI #317 drop the verbosity now --- docs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index 70cf0a7e..d0c3cbf1 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS ?= -vv +SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = source BUILDDIR = build From 32e3043e6ce0b7690c09b30702bc3046d7b2a141 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sat, 6 Jan 2024 09:36:48 -0600 Subject: [PATCH 34/38] Update hkl/util.py I like this. Co-authored-by: Padraic Shafer <76011594+padraic-shafer@users.noreply.github.com> --- hkl/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hkl/util.py b/hkl/util.py index 0704980f..44e5c0b0 100644 --- a/hkl/util.py +++ b/hkl/util.py @@ -353,7 +353,7 @@ def run_orientation_info(run): if f"{device}_orientation_attrs" in conf: # fmt:off devices[device] = { - item[len(device) + 1:]: value + item[len(f"{device}_"):]: value for item, value in conf.items() } # fmt:on From 9671da72c2f689e24e293f9ced93615e5892e586 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Fri, 12 Jan 2024 09:13:07 -0600 Subject: [PATCH 35/38] Update hkl/util.py Co-authored-by: Padraic Shafer <76011594+padraic-shafer@users.noreply.github.com> --- hkl/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hkl/util.py b/hkl/util.py index 44e5c0b0..a5154b4f 100644 --- a/hkl/util.py +++ b/hkl/util.py @@ -365,7 +365,7 @@ def run_orientation_info(run): if f"{device}_orientation_attrs" in conf: # fmt:off devices[device] = { - item[len(device)+1:]: conf[item].to_dict()["data"][0] + item[len(f"{device}_"):]: conf[item].to_dict()["data"][0] for item in conf } # fmt:on From 2fb010fc042b00da2a495e054ea9904508d7f380 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Fri, 12 Jan 2024 09:16:26 -0600 Subject: [PATCH 36/38] MNT #317 as suggested (for py38) --- hkl/configuration.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hkl/configuration.py b/hkl/configuration.py index c56bb546..6e6077dc 100644 --- a/hkl/configuration.py +++ b/hkl/configuration.py @@ -245,8 +245,7 @@ class DCSample: (the reciprocal of the crystal) in an orthonormal system. """ - # TODO: Once py38 is dropped, re-enable the default value setting - U: List[List[float]] # = field(default_factory=list[list[float]]) + U:field(default_factory=lambda: [[]]) # list containing an empty list """ Orientation matrix (3 x 3) of the crystal relative to the diffractometer. (optional) From e10f49b1a1344e3f20320266fa276eadef7b1e93 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Fri, 12 Jan 2024 09:27:26 -0600 Subject: [PATCH 37/38] MNT #317 revert --- hkl/configuration.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hkl/configuration.py b/hkl/configuration.py index 6e6077dc..c56bb546 100644 --- a/hkl/configuration.py +++ b/hkl/configuration.py @@ -245,7 +245,8 @@ class DCSample: (the reciprocal of the crystal) in an orthonormal system. """ - U:field(default_factory=lambda: [[]]) # list containing an empty list + # TODO: Once py38 is dropped, re-enable the default value setting + U: List[List[float]] # = field(default_factory=list[list[float]]) """ Orientation matrix (3 x 3) of the crystal relative to the diffractometer. (optional) From ae13efe44f507cfef56359f72497f692417add41 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Fri, 12 Jan 2024 09:31:20 -0600 Subject: [PATCH 38/38] Update .github/workflows/conda_unit_test.yml Co-authored-by: Padraic Shafer <76011594+padraic-shafer@users.noreply.github.com> --- .github/workflows/conda_unit_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/conda_unit_test.yml b/.github/workflows/conda_unit_test.yml index 66e972b1..5eb78131 100644 --- a/.github/workflows/conda_unit_test.yml +++ b/.github/workflows/conda_unit_test.yml @@ -71,6 +71,7 @@ jobs: - name: Test with coverage and pytest shell: bash -l {0} run: | - coverage run --concurrency=thread --parallel-mode -m pytest -vvv # --exitfirst . + set -vxeuo pipefail + coverage run --concurrency=thread --parallel-mode -m pytest -vvv coverage combine coverage report