From df433c88c4fc56b7ddcf5a921f1cbf2363a8f560 Mon Sep 17 00:00:00 2001 From: x12sa Date: Wed, 16 Sep 2026 13:09:45 +0200 Subject: [PATCH] fix(omny): accept p-accounts as valid in TomoIDManager bec.active_account is normally a p##### proposal account in production, but _is_valid_eaccount() only matched e#####, causing every real beamtime session to be silently rejected and fall back to tomo ID 0 (skipping OMNY registration and PDF upload). Widen the regex to accept both e- and p-accounts while still rejecting test/gac-* accounts. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01CpPtD7tCRwRZZnREhWcJi8 --- .../plugins/OMNY_shared/omny_general_tools.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/OMNY_shared/omny_general_tools.py b/csaxs_bec/bec_ipython_client/plugins/OMNY_shared/omny_general_tools.py index 3959efb5..0a75cb8f 100644 --- a/csaxs_bec/bec_ipython_client/plugins/OMNY_shared/omny_general_tools.py +++ b/csaxs_bec/bec_ipython_client/plugins/OMNY_shared/omny_general_tools.py @@ -327,6 +327,8 @@ class TomoIDManager: """Registers a tomography measurement in the OMNY sample database and returns its assigned tomo ID. + Real e-accounts (personal, e.g. "e12345") and p-accounts (proposal + accounts, e.g. "p23092") are both registered against OMNY_URL. Non-production accounts (e.g. test accounts like "gac-x01dc") are not registered against OMNY_URL at all -- there is no longer a separate test server to redirect them to, and registering test runs against @@ -351,8 +353,8 @@ class TomoIDManager: @staticmethod def _is_valid_eaccount(eaccount: str) -> bool: - """True for real e-accounts (e.g. "e12345"), False for test accounts.""" - return bool(re.fullmatch(r"e\d{5}", eaccount.strip())) + """True for real e- or p-accounts (e.g. "e12345", "p23092"), False for test accounts.""" + return bool(re.fullmatch(r"[ep]\d{5}", eaccount.strip())) def register( self, @@ -366,7 +368,7 @@ class TomoIDManager: ) -> int: """Register a new measurement and return the assigned tomo ID. - Registers against OMNY_URL for a real e-account. For any other + Registers against OMNY_URL for a real e- or p-account. For any other account (e.g. a test/"gac-*" account), skips registration entirely and returns FALLBACK_TOMO_ID (0) -- there is no separate test server to register against, and registering test runs against @@ -376,7 +378,7 @@ class TomoIDManager: """ if not self._is_valid_eaccount(eaccount): logger.warning( - f"Account '{eaccount}' is not a valid e-account; skipping OMNY " + f"Account '{eaccount}' is not a valid e- or p-account; skipping OMNY " f"registration (no separate test server to register against) " f"and falling back to tomo ID {self.FALLBACK_TOMO_ID}." )