backend_interface
anomaly_match_ui.utils.backend_interface
¶
BackendInterface: Single interface for UI-backend communication.
This module provides a static interface for the UI components to interact with the backend Session without direct imports, enabling clean separation between the UI and backend packages.
BackendInterface
¶
Single interface for UI-backend communication.
This static class wraps all Session methods needed by the UI components, providing a clean interface that decouples the UI from the backend implementation.
set_session(session)
staticmethod
¶
Set the session instance to use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The Session instance to interact with. |
required |
get_session()
staticmethod
¶
Get the current session instance.
Returns:
| Type | Description |
|---|---|
Session | None
|
The current Session instance, or None if not set. |
get_config()
staticmethod
¶
Get the session configuration.
Returns:
| Type | Description |
|---|---|
Any
|
The session configuration object (DotMap). |
get_num_channels()
staticmethod
¶
Get the number of channels in the images.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of image channels. |
Source code in anomaly_match_ui/utils/backend_interface.py
get_prediction_db_path(output_dir=None)
staticmethod
¶
Return the live predictions.db path for the active session.
Resolves any local-disk relocation (NFS sessions) centrally, so the UI poller reads the same file the prediction subprocess writes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str | None
|
Optional session-dir override (e.g. a chooser selection);
defaults to the session's |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the live |
Source code in anomaly_match_ui/utils/backend_interface.py
get_session_db_path(output_dir=None)
staticmethod
¶
Return the durable session-dir predictions.db path.
This is the snapshot copy that survives a relocated run; it equals
:meth:get_prediction_db_path when the DB is not relocated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str | None
|
Optional session-dir override; defaults to the session's
|
None
|
Returns:
| Type | Description |
|---|---|
str
|
Path to |
Source code in anomaly_match_ui/utils/backend_interface.py
launch_training_subprocess(num_train_iter=None, normalisation_overrides=None, gallery_labels=None)
staticmethod
¶
Serialize config and labels, then launch the training subprocess.
Prepares a temporary directory with the pickled config and merged
labels CSV, then spawns subprocess_scripts/training_process.py as a
process. The caller monitors progress via the returned
progress-file path and :class:~subprocess.Popen handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_train_iter
|
int | None
|
Override for |
None
|
normalisation_overrides
|
dict[str, Any] | None
|
Dict of normalisation config overrides
(keys matching |
None
|
gallery_labels
|
dict[str, str] | None
|
Dict mapping |
None
|
Returns:
| Type | Description |
|---|---|
Popen
|
|
str
|
path to the temporary directory, and the path to the JSON-lines |
str
|
progress file the subprocess writes to. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the training script cannot be found. |
Source code in anomaly_match_ui/utils/backend_interface.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
merge_gallery_labels(new_labels, output_path=None)
staticmethod
¶
Merge new gallery labels with the existing label CSV and save.
Delegates I/O to :meth:SessionIOHandler.merge_gallery_labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_labels
|
dict[str, str]
|
Dict mapping |
required |
output_path
|
str | None
|
Where to write the merged CSV. Defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
str
|
Absolute path to the written CSV file. |
Source code in anomaly_match_ui/utils/backend_interface.py
validate_labels_against_source(source_dir, source_type, label_path, *, stale_check=None)
staticmethod
¶
Validate labeled IDs against the data source.
Delegates to :func:~anomaly_match.data_io.source_validation.validate_labeled_files
and formats the result as a human-readable message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_dir
|
str
|
Path to the data directory. |
required |
source_type
|
str
|
A :class: |
required |
label_path
|
str
|
Path to the label CSV. |
required |
stale_check
|
Optional zero-arg callable returning |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Tuple of |
dict[str, tuple]
|
|
bool
|
other two fields reflect only the catalogues processed so far — |
tuple[str, dict[str, tuple], bool]
|
callers must not cache them or build a labeled cache from them. |
Source code in anomaly_match_ui/utils/backend_interface.py
build_labeled_cache(found_locations, label_path, source_type, stale_check=None)
staticmethod
¶
Build a labeled data cache for container sources (Zarr/Cutana).
Delegates to :meth:LabeledDataCache.build.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
found_locations
|
dict[str, tuple]
|
Validated locations from
:meth: |
required |
label_path
|
str
|
Path to the label CSV. |
required |
source_type
|
str
|
A :class: |
required |
stale_check
|
Callable[[], bool] | None
|
Optional zero-arg callable returning |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
Path to the cache directory, |
str | None
|
a container type, or |
str | None
|
the job was superseded. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If another process holds the cache lock past
:data: |
Source code in anomaly_match_ui/utils/backend_interface.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | |
update_labeled_cache(new_labels)
staticmethod
¶
Update the labeled data cache after gallery labeling.
Delegates to :meth:LabeledDataCache.update.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_labels
|
dict[str, str]
|
Dict mapping |
required |
Source code in anomaly_match_ui/utils/backend_interface.py
evaluate_all_images(top_n, progress_callback=None)
staticmethod
¶
Evaluate all images in the prediction search directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
top_n
|
int
|
Number of top images to keep. |
required |
progress_callback
|
Callable | None
|
Optional callback for progress updates. |
None
|
Source code in anomaly_match_ui/utils/backend_interface.py
get_last_run_skip_stats()
staticmethod
¶
Return how many chunks/sources were skipped on the last evaluate_all_images.
Used by scoring screens to display a partial-completion warning when
some chunks failed (typically: data volume detached mid-run so Cutana
couldn't reach the FITS tiles). Stats are reset at the start of each
evaluate_all_images call.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with |
dict
|
|
Source code in anomaly_match_ui/utils/backend_interface.py
request_prediction_stop(timeout=15.0)
staticmethod
¶
Request a graceful cancel of the currently running prediction.
SIGTERMs the prediction subprocess (if any) and sets the flag that
tells the chunk loop not to spawn the next one. Idempotent — safe
to call when no prediction is running. Callers that care about
the GPU being free (e.g. retrain) should also join the thread
running evaluate_all_images after calling this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Seconds to wait for SIGTERM to take effect before escalating to SIGKILL. |
15.0
|
Source code in anomaly_match_ui/utils/backend_interface.py
set_log_level(log_level)
staticmethod
¶
Set the log level via the backend utility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_level
|
str
|
The log level to set (e.g. 'DEBUG', 'INFO'). |
required |
Source code in anomaly_match_ui/utils/backend_interface.py
set_terminal_output(output_widget)
staticmethod
¶
Set the terminal output widget for logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_widget
|
Any
|
The output widget for terminal logging. |
required |
Source code in anomaly_match_ui/utils/backend_interface.py
remember_current_file(filename)
staticmethod
¶
Remember the current file by appending it to a CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The filename to remember. |
required |
Source code in anomaly_match_ui/utils/backend_interface.py
remember_file(filename)
staticmethod
¶
Remember a file by name, without requiring a catalog index.
Delegates to remember_current_file on the session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The filename to remember. |
required |
Source code in anomaly_match_ui/utils/backend_interface.py
open_prediction_monitor(db_path, search_dir)
staticmethod
¶
Open an AnomalyScoreDB and ImageCache for live polling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_path
|
str
|
Path to the SQLite prediction database. |
required |
search_dir
|
str
|
Root directory for loading source images. |
required |
Source code in anomaly_match_ui/utils/backend_interface.py
close_prediction_monitor()
staticmethod
¶
Close the score DB and cache.
Sets the reference to None before closing so that daemon threads (poll/prefetch) see None and bail out instead of querying a connection that is being closed — avoids a C-level segfault.
Source code in anomaly_match_ui/utils/backend_interface.py
get_prediction_count()
staticmethod
¶
Return total number of stored prediction results.
Returns:
| Type | Description |
|---|---|
int
|
Row count, or 0 if no DB is open. |
Source code in anomaly_match_ui/utils/backend_interface.py
get_prediction_results(sort_by='score_desc', limit=100, offset=0)
staticmethod
¶
Query prediction results with sorting and pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sort_by
|
str
|
Sort key (e.g. |
'score_desc'
|
limit
|
int
|
Maximum rows. |
100
|
offset
|
int
|
Rows to skip. |
0
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of result dicts. |
Source code in anomaly_match_ui/utils/backend_interface.py
get_prediction_score_range()
staticmethod
¶
Return (min_score, max_score) across all results.
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Tuple of min and max score. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no results exist. |
Source code in anomaly_match_ui/utils/backend_interface.py
get_prediction_histogram(bins=50)
staticmethod
¶
Compute a score histogram from stored results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bins
|
int
|
Number of histogram bins. |
50
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
|
Source code in anomaly_match_ui/utils/backend_interface.py
get_prediction_result(filename)
staticmethod
¶
Look up a single prediction result by filename.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Source filename. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
Result dict or |
Source code in anomaly_match_ui/utils/backend_interface.py
load_prediction_image(filename)
staticmethod
¶
Load a source image via the prediction image cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Source filename. |
required |
Returns:
| Type | Description |
|---|---|
ndarray | None
|
HWC uint8 numpy array, or |
Source code in anomaly_match_ui/utils/backend_interface.py
cache_prediction_image(filename, image)
staticmethod
¶
Manually insert an image into the prediction cache.
Useful for caching images loaded via alternative paths (e.g. Cutana cutouts) so subsequent lookups hit the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Cache key. |
required |
image
|
ndarray
|
HWC uint8 numpy array. |
required |
Source code in anomaly_match_ui/utils/backend_interface.py
clear_image_cache()
staticmethod
¶
Drop all cached images so they are re-loaded with current settings.
scan_and_count_sources(folder)
staticmethod
¶
Detect source type and count sources in a folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Path to the search directory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
SourceScanResult
|
class: |
Source code in anomaly_match_ui/utils/backend_interface.py
detect_and_count_sources(folder)
staticmethod
¶
Detect source type and count sources in a folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Path to the search directory. |
required |
Returns:
| Type | Description |
|---|---|
tuple[DataSourceType, int]
|
Tuple of |
Source code in anomaly_match_ui/utils/backend_interface.py
detect_source_channel_count(folder, source_type, image_files=None)
staticmethod
¶
Return the per-image channel count of a Zarr store or image folder.
Delegates to :func:anomaly_match.data_io.source_scanning.detect_source_channel_count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Source directory or single Zarr store. |
required |
source_type
|
DataSourceType
|
The detected source type. |
required |
image_files
|
list[str] | None
|
Image filenames for image-folder sources. |
None
|
Returns:
| Type | Description |
|---|---|
int | None
|
The channel count, or |
Source code in anomaly_match_ui/utils/backend_interface.py
detect_and_count_prediction_sources(folder)
staticmethod
¶
Detect prediction source type and count items in a folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Directory to scan, or a direct path to a single store. |
required |
Returns:
| Type | Description |
|---|---|
tuple[DataSourceType, int]
|
Tuple of |
Source code in anomaly_match_ui/utils/backend_interface.py
is_shipped_default_path(key, value)
staticmethod
¶
Return whether value is the bundled default path for config key.
Delegates to :func:anomaly_match.utils.get_default_cfg.is_shipped_default_path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Top-level config key, e.g. |
required |
value
|
str | None
|
The configured path, or |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in anomaly_match_ui/utils/backend_interface.py
read_label_map(label_path)
staticmethod
¶
Read a label CSV and return an {id: label} mapping.
Delegates to :func:anomaly_match.data_io.source_scanning.read_label_map,
which raises FileNotFoundError for missing paths and ValueError
for malformed content — callers must guard against the "no label
selected" UI state before invoking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label_path
|
str
|
Path to an existing label CSV file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Mapping from sample id to label string. |
Source code in anomaly_match_ui/utils/backend_interface.py
load_preview_samples(folder, source_type, *, image_files=None, source_ids=None, max_items=9, offset=0, stale_check=None)
staticmethod
¶
Load sample images for preview display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Path to the data directory. |
required |
source_type
|
str
|
Detected source type value string. |
required |
image_files
|
list[str] | None
|
Files to load for image_folder sources. |
None
|
source_ids
|
list[str] | None
|
Source IDs to load for Cutana sources. |
None
|
max_items
|
int
|
Maximum number of preview samples to return. |
9
|
offset
|
int
|
Skip this many items before loading |
0
|
stale_check
|
Optional zero-arg callable returning |
None
|
Returns:
| Type | Description |
|---|---|
list[tuple[str, ndarray]]
|
List of |
Source code in anomaly_match_ui/utils/backend_interface.py
load_cutana_preview(folder, source_ids, *, max_items, stale_check=None)
staticmethod
¶
Load Cutana preview cutouts plus the raws worth holding (issue #501).
Reads the labeled cache once and returns both the decoded preview images and — when the cache fully covered the request — the raw arrays the setup screen holds to re-decode on a normalisation change without re-reading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Source catalogue directory (fallback search root). |
required |
source_ids
|
list[str]
|
Candidate ids, already stratified by label. |
required |
max_items
|
int
|
Cap on preview grid size. |
required |
stale_check
|
Optional zero-arg callable returning |
None
|
Returns:
| Type | Description |
|---|---|
list[tuple[str, ndarray]]
|
|
list[tuple[str, ndarray]] | None
|
cache fully backed the request. |
Source code in anomaly_match_ui/utils/backend_interface.py
decode_raw_cutouts(raw_items)
staticmethod
¶
Apply the current normalisation to held raw cutouts (issue #501).
Rebuilds fitsbolt_cfg from the session's current normalisation
settings and decodes the raw arrays to display-ready HWC uint8. The
UI calls this on a normalisation change to refresh the preview from the
in-memory raws without any cache read.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_items
|
list[tuple[str, ndarray]]
|
|
required |
Returns:
| Type | Description |
|---|---|
list[tuple[str, ndarray]]
|
List of |
Source code in anomaly_match_ui/utils/backend_interface.py
load_prediction_db_state(db_path)
staticmethod
¶
Return the row count and stored metadata for an existing DB.
The caller uses this to decide whether to present a resume and, if so, which stored normalisation settings to apply to the setup widgets. Compatibility comparison lives on the caller side — we hand back the raw stored metadata here, not a compatible/incompatible verdict.
AnomalyScoreDB propagates SchemaVersionError when the
file's schema doesn't match; callers handle it by surfacing a
"delete and re-run" message to the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_path
|
str
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
int
|
Tuple of |
dict
|
file does not exist. |
Source code in anomaly_match_ui/utils/backend_interface.py
read_model_normalisation(model_path)
staticmethod
¶
Read the normalisation settings embedded in a model checkpoint.
Thin wrapper over
:func:anomaly_match.data_io.checkpoint_io.read_model_normalisation.
Prediction overrides its decode pipeline from the checkpoint, so these
settings — not a user choice — are what inference runs; the prediction
setup screen reads them to show a read-only overview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
str
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Summary dict (see the backend function); normalisation fields are |
dict
|
|
Source code in anomaly_match_ui/utils/backend_interface.py
sync_normalisation_from_model(model_path)
staticmethod
¶
Mirror a checkpoint's full normalisation onto the session config.
The prediction setup screen previews Cutana cutouts before the
prediction subprocess runs, and the Cutana orchestrator validates that
cfg.fitsbolt_cfg and cfg.normalisation agree. Mirroring only the
display-shaped cfg.normalisation fields (as
:meth:read_model_normalisation feeds) leaves cfg.fitsbolt_cfg stale
at the pickled default (CONVERSION_ONLY), so the preview crashes on the
disagreement guard. This writes all three normalisation surfaces —
fitsbolt_cfg, the cfg.normalisation fields and
channel_combination — exactly as the prediction subprocess does via
:func:~anomaly_match.data_io.checkpoint_io.sync_normalisation_from_checkpoint,
keeping the preview decode in lock-step with inference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
str
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
it was applied; |
bool
|
caller keeps showing the read-only overview and lets the prediction |
bool
|
subprocess raise the definitive "retrain to embed normalisation" |
bool
|
error). |
Source code in anomaly_match_ui/utils/backend_interface.py
load_cutana_cutout(source_id)
staticmethod
¶
Create a single cutout for a streaming source via Cutana.
Uses the session config to locate the catalogue and create a cutout on demand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
str
|
The source identifier from the prediction DB. |
required |
Returns:
| Type | Description |
|---|---|
ndarray | None
|
HWC uint8 numpy array, or |
Source code in anomaly_match_ui/utils/backend_interface.py
load_cutana_batch(source_ids)
staticmethod
¶
Create cutouts for multiple sources in a single batch.
Much more efficient than calling load_cutana_cutout per source
since only one Cutana orchestrator is created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_ids
|
list[str]
|
List of source identifiers from the prediction DB. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
Dict mapping source_id to HWC uint8 numpy array. Gallery |
dict[str, ndarray]
|
callers don't pass |
dict[str, ndarray]
|
class: |
dict[str, ndarray]
|
unwrap straight to the cutouts dict. |
Source code in anomaly_match_ui/utils/backend_interface.py
load_container_images(filenames)
staticmethod
¶
Load and decode images from Zarr containers by filename.
Handles synthetic filenames from the prediction DB:
Zarr: parses prefix__image_NNNNNN to extract array indices.
Pixels are decoded with the session's normalisation and
channel_combination via :func:decode_zarr_gallery_images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filenames
|
list[str]
|
List of filenames from the prediction DB. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
Dict mapping filename to decoded HWC image. |
Source code in anomaly_match_ui/utils/backend_interface.py
decode_single_with_normalisation(filename, source_type, norm_overrides, *, search_dir)
staticmethod
¶
Re-decode a single source under one-shot normalisation overrides.
Used by :class:ImageDetailScreen to redraw the displayed image
after the user tweaks normalisation knobs without leaving the
screen. The session config is never mutated — overrides go
into a deep-copy so subsequent training/prediction runs keep the
committed cfg (#443). cfg.fitsbolt_cfg is cleared before
the call so the loader rebuilds it from the override values
rather than re-using the stale build.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Source identifier (filename for image-folder / Zarr, source-id for Cutana) as stored in the prediction DB. |
required |
source_type
|
DataSourceType
|
Which loader path to use for the re-decode. |
required |
norm_overrides
|
dict
|
A mapping of |
required |
search_dir
|
str
|
Folder holding the catalogues / image files for
this source. Passed through |
required |
Returns:
| Type | Description |
|---|---|
ndarray | None
|
HWC uint8 array under the override settings. For Cutana |
ndarray | None
|
sources, |
ndarray | None
|
catalogue (propagated from |
ndarray | None
|
func: |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
|
Source code in anomaly_match_ui/utils/backend_interface.py
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 | |
load_single_native_cutout(source_id, *, search_dir, cutout_padding_factor)
staticmethod
¶
Read one native-resolution raw cutout for the detail view.
The detail screen holds this normalisation-independent per-band float
array and re-normalises it in-process on every widget change via
:meth:decode_raw_with_normalisation, so the catalogue/tile is read
once per (source, zoom) (issue #501). The cutout comes back at its true
native pixel size (Cutana do_only_cutout_extraction), so the user
inspects real pixels rather than a fixed-resolution resample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
str
|
The Cutana source id stored in the prediction DB. |
required |
search_dir
|
str
|
Catalogue directory passed through the detail context —
the cfg's |
required |
cutout_padding_factor
|
float
|
The "Cutout Zoom-out" the widget currently shows. Unlike the normalisation knobs this changes the extracted sky window (and hence the native pixel size), so it must be applied at extraction time — re-normalising a held raw can't widen it. |
required |
Returns:
| Type | Description |
|---|---|
ndarray | None
|
HWC float32 array (one channel per FITS band) at native resolution, |
ndarray | None
|
or |
ndarray | None
|
cutout. |
Source code in anomaly_match_ui/utils/backend_interface.py
decode_raw_with_normalisation(raw_image, norm_overrides)
staticmethod
¶
Apply one-shot normalisation overrides to a held raw cutout.
In-memory counterpart to :meth:decode_single_with_normalisation for
Cutana: instead of re-reading the catalogue and re-extracting, it
re-normalises the raw float32 array the detail screen already holds.
The session config is never mutated — overrides go into a deep-copy
(the hasattr guard mirrors :meth:decode_single_with_normalisation)
and the actual decode is delegated to the same backend re-decode the
501 preview path uses, so the result is identical to a fresh¶
:func:load_single_cutout at the same settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_image
|
ndarray
|
HWC float32 cutout from :meth: |
required |
norm_overrides
|
dict
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray | None
|
HWC uint8 array under the override settings, or |
ndarray | None
|
decode produced nothing. |
Source code in anomaly_match_ui/utils/backend_interface.py
get_version()
staticmethod
¶
Get the anomaly_match version.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The version string. |
get_git_commit()
staticmethod
¶
Get the git commit the UI is running from.
Returns:
| Type | Description |
|---|---|
str | None
|
The abbreviated commit hash, or |
str | None
|
(e.g. an installed wheel with no |