fix(flomni,lamni): stop registering test/gac accounts against production omny.psi.ch

TomoIDManager.OMNY_URL and TEST_OMNY_URL both point at omny.psi.ch since
the dedicated omny-test.psi.ch host was retired, so the eaccount check no
longer redirects test/gac-* accounts anywhere different -- it just logs a
warning and still registers them in the production sample database. Skip
registration entirely for non-e-accounts and return FALLBACK_TOMO_ID
instead, to avoid polluting production with test entries.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013gGu5ANBo88Fh7eqmRdFbU
This commit is contained in:
x12saandClaude Sonnet 5 committed 2026-09-11 16:18:51 +02:00
1 parent 42739fcc7a
commit da4007d7e7
2 files changed
+20 -22

No files matched your search

@@ -327,12 +327,11 @@ class TomoIDManager:
"""Registers a tomography measurement in the OMNY sample database
and returns its assigned tomo ID.
Non-production accounts (e.g. test accounts like "gac-x01dc") register
against the test server (TEST_OMNY_URL) instead of production, so
testing still gets a real, incrementing tomo ID -- matching the
counter the samples-folder PDF upload reads from on that same test
host -- accepting that the eaccount recorded in that test database
won't be a real e-account.
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
the production sample database would pollute it. They get
FALLBACK_TOMO_ID instead.
Usage:
id_manager = TomoIDManager()
@@ -348,7 +347,6 @@ class TomoIDManager:
"""
OMNY_URL = "https://omny.psi.ch/samples/newmeasurement.php"
TEST_OMNY_URL = "https://omny.psi.ch/samples/newmeasurement.php"
FALLBACK_TOMO_ID = 0
@staticmethod
@@ -368,20 +366,21 @@ class TomoIDManager:
) -> int:
"""Register a new measurement and return the assigned tomo ID.
Registers against OMNY_URL (production) for a real e-account, or
TEST_OMNY_URL (test server) otherwise. Returns FALLBACK_TOMO_ID (0)
only if the server actually can't be reached / returns an unusable
response.
Registers against OMNY_URL for a real e-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
production would pollute the real sample database. FALLBACK_TOMO_ID
is also returned if the server actually can't be reached / returns
an unusable response.
"""
if self._is_valid_eaccount(eaccount):
omny_url = self.OMNY_URL
else:
omny_url = self.TEST_OMNY_URL
if not self._is_valid_eaccount(eaccount):
logger.warning(
f"Account '{eaccount}' is not a valid e-account; registering "
f"against the test server ({self.TEST_OMNY_URL}) instead of "
"production -- the eaccount recorded there won't be real."
f"Account '{eaccount}' is not a valid e-account; skipping OMNY "
f"registration (no separate test server to register against) "
f"and falling back to tomo ID {self.FALLBACK_TOMO_ID}."
)
return self.FALLBACK_TOMO_ID
params = {
"sample": sample_name,
@@ -407,7 +406,7 @@ class TomoIDManager:
try:
response = requests.get(
omny_url,
self.OMNY_URL,
params=params,
timeout=30,
verify=False, # accept self-signed certs
@@ -392,9 +392,8 @@ class TomoQueueMixin:
user=user,
)
# Must match whatever host TomoIDManager.OMNY_URL/TEST_OMNY_URL
# registered against, since that host's sample counter is what
# self.tomo_id came from.
# Must match whatever host TomoIDManager.OMNY_URL registered against,
# since that host's sample counter is what self.tomo_id came from.
_SAMPLES_UPLOAD_HOSTS = ("https://omny.psi.ch",)
def _upload_pdf_report_to_samples(self, pdf_path: str) -> None: