From 73ab622fb006ff0d8aea79182a56769daf8788cf Mon Sep 17 00:00:00 2001 From: David Perl Date: Mon, 26 Oct 2026 14:53:29 +0100 Subject: [PATCH] feat: use aare config for jfjoch images per file --- pyproject.toml | 15 ++++++--------- src/aare/devices/jfjoch.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ee9c1fbe..f2c78069 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ dependencies = [ "aarelcinfer-client==0.1.1a8", "matplotlib>=3.10.3", "httpx>=0.28.1", + "aare-config>=0.1.7", ] [project.optional-dependencies] @@ -46,12 +47,10 @@ test = [ "pytest-timeout", "fakeredis[lua]", "diff-cover", - "ruff>=0.15" + "ruff>=0.15", ] -docs = [ - "zensical" -] +docs = ["zensical"] [lint] ignore = ["F401", "F541", "W503", "W504"] @@ -70,7 +69,7 @@ ignore = ["F401", "F541", "W503", "W504"] override-dependencies = ["opencv-python; sys_platform == 'nonexistent'"] [tool.uv.sources] -aaredb = { index = "psi"} +aaredb = { index = "psi" } [[tool.uv.index]] name = "psi" @@ -82,9 +81,7 @@ python_files = ["test_*.py"] norecursedirs = ["scripts", ".venv", "logs", "docs"] asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function" -markers = [ - "integration: tests that require external systems or secrets", -] +markers = ["integration: tests that require external systems or secrets"] [build-system] requires = ["setuptools>=75.6.0"] @@ -113,7 +110,7 @@ ignore = [ "DTZ005", "DTZ006", ] -isort.split-on-trailing-comma=false +isort.split-on-trailing-comma = false [tool.ruff.format] skip-magic-trailing-comma = true diff --git a/src/aare/devices/jfjoch.py b/src/aare/devices/jfjoch.py index 063198eb..f731b6ab 100644 --- a/src/aare/devices/jfjoch.py +++ b/src/aare/devices/jfjoch.py @@ -6,6 +6,7 @@ from enum import Enum from typing import Concatenate, ParamSpec, TypeVar, final import jfjoch_client +from aare_config import AareConfigClient from aarecommon.config.beamline import get_jfjoch_url from aarecommon.config.logger import setup_logger from aarecommon.errors.exception_handler import AareUserError, JFJochCommunicationError @@ -55,6 +56,13 @@ class JFJochWrapper: self._connected: bool = False _client: ApiClient _api: DefaultApi + try: + self._config_client = AareConfigClient( + redis_url=f"redis://mx-{bl.value.lower()}-queue-01", key_prefix="config" + ) + except Exception: + logger.exception("Failed to create aare config client") + self._config_client = None def connect(self) -> None: """Connect to JFJoch on first use; a no-op once the client exists.""" @@ -178,6 +186,11 @@ class JFJochWrapper: ) else: smargon_phi_chi = None + images_per_file = ( + self._config_client.jfjoch.n_images_per_file + if self._config_client is not None + else None + ) or None dataset_settings = jfjoch_client.DatasetSettings( beam_x_pxl=s.diffraction.beam_center_pxl[0], beam_y_pxl=s.diffraction.beam_center_pxl[1], @@ -202,6 +215,7 @@ class JFJochWrapper: beam_size_x_um=s.geom.beam_size_mm.x * 1000.0, beam_size_y_um=s.geom.beam_size_mm.y * 1000.0, polarization_factor=1.0, + images_per_file=images_per_file, ) # settup grid or goniometer settings adn add to dataset settings -- 2.54.0