fix: fall back to jfjoch default when n_images_per_file is not configured
CI / coverage-analysis (push) Canceled after 0s
CI / test (3.14) (pull_request) Successful in 4m16s
CI / lint (pull_request) Successful in 1m5s
CI / test (3.13) (pull_request) Successful in 4m10s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Successful in 4m4s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Successful in 3m44s
CI / test (3.12) (pull_request) Successful in 4m13s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Successful in 4m9s
CI / test-with-coverage (pull_request) Successful in 4m23s
CI / coverage-analysis (pull_request) Successful in 2s
Docs build and publish / docker (push) Successful in 3s
CI / lint (push) Canceled after 1m7s
CI / test-with-beamline-plugins (pxiii_bec) (push) Canceled after 1m4s
CI / test (3.14) (push) Canceled after 1m7s
Build and Publish / release (push) Successful in 59s
CI / test (3.12) (push) Canceled after 1m7s
CI / test-with-beamline-plugins (pxi_bec) (push) Canceled after 1m6s
CI / test-with-coverage (push) Canceled after 1m3s
CI / test (3.13) (push) Canceled after 1m6s
CI / test-with-beamline-plugins (pxii_bec) (push) Canceled after 1m4s
CI / coverage-analysis (push) Canceled after 0s
CI / test (3.14) (pull_request) Successful in 4m16s
CI / lint (pull_request) Successful in 1m5s
CI / test (3.13) (pull_request) Successful in 4m10s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Successful in 4m4s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Successful in 3m44s
CI / test (3.12) (pull_request) Successful in 4m13s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Successful in 4m9s
CI / test-with-coverage (pull_request) Successful in 4m23s
CI / coverage-analysis (pull_request) Successful in 2s
Docs build and publish / docker (push) Successful in 3s
CI / lint (push) Canceled after 1m7s
CI / test-with-beamline-plugins (pxiii_bec) (push) Canceled after 1m4s
CI / test (3.14) (push) Canceled after 1m7s
Build and Publish / release (push) Successful in 59s
CI / test (3.12) (push) Canceled after 1m7s
CI / test-with-beamline-plugins (pxi_bec) (push) Canceled after 1m6s
CI / test-with-coverage (push) Canceled after 1m3s
CI / test (3.13) (push) Canceled after 1m6s
CI / test-with-beamline-plugins (pxii_bec) (push) Canceled after 1m4s
Reading jfjoch/n_images_per_file from aare config raises when the key is not set and has no default (e.g. on x06da), which aborted data collection setup. Treat a failed lookup like a missing config client: log a warning and let JFJoch use its own images-per-file default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #256.
This commit is contained in:
1 parent
b1fecd8714
commit
d0cef9385b
2 files changed
+35
-6
No files matched your search
@@ -64,6 +64,19 @@ class JFJochWrapper:
|
||||
logger.exception("Failed to create aare config client")
|
||||
self._config_client = None
|
||||
|
||||
def _get_images_per_file(self) -> int | None:
|
||||
"""Images per file from aare config; None (JFJoch default) if unavailable."""
|
||||
if self._config_client is None:
|
||||
return None
|
||||
try:
|
||||
return self._config_client.jfjoch.n_images_per_file or None
|
||||
except Exception:
|
||||
logger.warning(
|
||||
"jfjoch/n_images_per_file not available from aare config; using JFJoch default",
|
||||
exc_info=True,
|
||||
)
|
||||
return None
|
||||
|
||||
def connect(self) -> None:
|
||||
"""Connect to JFJoch on first use; a no-op once the client exists."""
|
||||
if self._connected:
|
||||
@@ -186,11 +199,7 @@ 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
|
||||
images_per_file = self._get_images_per_file()
|
||||
dataset_settings = jfjoch_client.DatasetSettings(
|
||||
beam_x_pxl=s.diffraction.beam_center_pxl[0],
|
||||
beam_y_pxl=s.diffraction.beam_center_pxl[1],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock, PropertyMock, patch
|
||||
|
||||
import pytest
|
||||
from aarecommon.errors.exception_handler import JFJochCommunicationError
|
||||
@@ -123,6 +123,26 @@ def test_client_is_created_lazily(mock_jfjoch_client):
|
||||
assert wrapper._api is api
|
||||
|
||||
|
||||
def test_images_per_file_from_config(jfjoch_wrapper):
|
||||
jfjoch_wrapper._config_client = MagicMock()
|
||||
jfjoch_wrapper._config_client.jfjoch.n_images_per_file = 500
|
||||
assert jfjoch_wrapper._get_images_per_file() == 500
|
||||
|
||||
|
||||
def test_images_per_file_without_config_client(jfjoch_wrapper):
|
||||
jfjoch_wrapper._config_client = None
|
||||
assert jfjoch_wrapper._get_images_per_file() is None
|
||||
|
||||
|
||||
def test_images_per_file_falls_back_when_key_not_set(jfjoch_wrapper):
|
||||
# e.g. x06da, where jfjoch/n_images_per_file is not set and has no default
|
||||
jfjoch_wrapper._config_client = MagicMock()
|
||||
type(jfjoch_wrapper._config_client.jfjoch).n_images_per_file = PropertyMock(
|
||||
side_effect=KeyError("jfjoch/n_images_per_file is not set and has no default")
|
||||
)
|
||||
assert jfjoch_wrapper._get_images_per_file() is None
|
||||
|
||||
|
||||
def test_initialize(jfjoch_wrapper, mock_jfjoch_client):
|
||||
mock_jfjoch_client.initialize_post.reset_mock()
|
||||
jfjoch_wrapper.initialize()
|
||||
|
||||
Reference in new issue
Block a user