some webUI fixes

This commit is contained in:
Ayzen
2026-06-10 14:39:25 +03:00
parent c12ae05148
commit 21f76d7cd2
14 changed files with 767 additions and 32 deletions
+14 -4
View File
@@ -27,6 +27,15 @@ from python_app.storage.store_api import StoreApi
logger = logging.getLogger(__name__)
def _compose_snapshot_stem(name: str, name_prefix: str) -> str:
"""Compose a sanitized snapshot stem from an optional prefix and the operator's name.
The name falls back to a UTC timestamp when blank, so a save is always uniquely named.
"""
base = name.strip() or datetime.now(timezone.utc).strftime("snapshot_%Y%m%d_%H%M%S")
return sanitize_path_component(f"{name_prefix}_{base}" if name_prefix else base)
class NpzStore(StoreApi):
"""Persist preprocess sets and runtime snapshots using NumPy files."""
@@ -193,13 +202,14 @@ class NpzStore(StoreApi):
preprocessed_history: list[SweepCollection],
result_history: list[ResultCollection],
last_n: int,
*,
name_prefix: str = "",
) -> tuple[Path, dict[str, Any]]:
"""Save historical runtime collections in NumPy tree format."""
if last_n <= 0:
raise ValueError("last_n must be > 0")
snapshot_stem = snapshot_name.strip() or datetime.now(timezone.utc).strftime("snapshot_%Y%m%d_%H%M%S")
snapshot_stem = sanitize_path_component(snapshot_stem)
snapshot_stem = _compose_snapshot_stem(snapshot_name, name_prefix)
output_root_dir.mkdir(parents=True, exist_ok=True)
snapshot_dir = output_root_dir / snapshot_stem
@@ -324,13 +334,13 @@ class NpzStore(StoreApi):
*,
channel: str = "s21",
primary_stage: str = "preprocessed",
name_prefix: str = "",
) -> tuple[list[Path], dict[str, Any]]:
"""Save one runtime VNA-history JSON per available combo."""
if last_n <= 0:
raise ValueError("last_n must be > 0")
output_stem = output_name.strip() or datetime.now(timezone.utc).strftime("snapshot_%Y%m%d_%H%M%S")
output_stem = sanitize_path_component(output_stem)
output_stem = _compose_snapshot_stem(output_name, name_prefix)
output_root_dir.mkdir(parents=True, exist_ok=True)
output_dir = self._vna_json_output_dir(output_root_dir, output_stem)
output_dir.mkdir(parents=True, exist_ok=True)