added data saving feature

This commit is contained in:
Ayzen
2026-06-23 12:19:31 +03:00
parent 716fd0b07a
commit 8db14b9482
20 changed files with 1192 additions and 63 deletions
@@ -39,23 +39,55 @@ class AppWindowSnapshotMixin:
return output_dir / "config_profile.json"
def _save_snapshot(self) -> None:
"""Save runtime snapshot in numpy-directory format."""
"""Save the last-N runtime measurements as a numpy snapshot (the "Save Dataset" button)."""
self._drain_runtime_rings_for_snapshot()
if not self._raw_history and not self._pre_history and not self._result_history:
self._show_error("No runtime data is available for save", details=self._runtime_history_details())
return
self._write_snapshot_dataset(
list(self._raw_history),
list(self._pre_history),
list(self._result_history),
int(self._save_count.value()),
)
def _snapshot_destination_dir(self) -> Path:
"""The directory a save/record would create now, from the current path/name fields.
Used to surface a name clash *before* doing work (manual save and the disk
recorder both create this directory and fail if it already exists).
"""
output_root = Path(self._save_path_input.text().strip()).expanduser()
return self._store.snapshot_directory(
output_root,
self._save_name_input.text().strip(),
name_prefix=self._radar_config_name_prefix(),
)
def _write_snapshot_dataset(
self,
raw_history: list,
preprocessed_history: list,
result_history: list,
last_n: int,
) -> None:
"""Save the given aligned histories as a numpy snapshot + adjacent config profile.
Shared by the manual "Save Dataset" button (which passes the runtime history)
and the on-the-fly disk recorder (which passes the freshly recorded buffers),
so both produce byte-identical dataset layouts and identical error reporting.
"""
try:
last_n = int(self._save_count.value())
output_root = Path(self._save_path_input.text().strip()).expanduser()
snapshot_name = self._save_name_input.text().strip()
snapshot_dir, summary = self._store.save_runtime_snapshot_numpy(
output_root,
snapshot_name,
list(self._raw_history),
list(self._pre_history),
list(self._result_history),
raw_history,
preprocessed_history,
result_history,
last_n,
name_prefix=self._radar_config_name_prefix(),
)