From aa8281f9638c7aedea542d8a48a2c7b570b35e37 Mon Sep 17 00:00:00 2001 From: yoshifuminakamura Date: Mon, 10 Aug 2026 16:25:42 +0900 Subject: [PATCH] Show latest snapshot in profile usage overview Signed-off-by: yoshifuminakamura --- ...usage_report_profile_overview_section.html | 7 ++++++ .../tests/test_profile_usage_overview.py | 11 +++++++++ result_server/utils/profile_usage_overview.py | 23 +++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/result_server/templates/_usage_report_profile_overview_section.html b/result_server/templates/_usage_report_profile_overview_section.html index 1c54891..79fca12 100644 --- a/result_server/templates/_usage_report_profile_overview_section.html +++ b/result_server/templates/_usage_report_profile_overview_section.html @@ -69,6 +69,13 @@

Results

{{ row.latest_result.timestamp }} {{ row.latest_result.code }} / {{ row.latest_result.system }} / {{ row.latest_result.exp }} {{ row.latest_result.trigger_headline }} / pipeline {{ row.latest_result.pipeline_id }} + {% if row.latest_result.environment_snapshot %} + + snapshot {{ row.latest_result.environment_snapshot.short_hash }} + / {{ row.latest_result.environment_snapshot.allocation_project_id }} + / {{ row.latest_result.environment_snapshot.scheduler }} + + {% endif %} {% else %} - {% endif %} diff --git a/result_server/tests/test_profile_usage_overview.py b/result_server/tests/test_profile_usage_overview.py index 3cc6bad..040a680 100644 --- a/result_server/tests/test_profile_usage_overview.py +++ b/result_server/tests/test_profile_usage_overview.py @@ -79,6 +79,15 @@ def test_profile_usage_overview_links_profile_triggers_results_and_node_hours(tm "type": "scheduled", "reason": "cron:0 14 * * *@2026-08-10T14:00+09:00", }, + "environment_snapshot": { + "hash": "sha256:54d4b0024f2e58b62b80cc5ca2b86f522fa69fee381c5a15e4cf37168debe7fb", + "summary": { + "system": "Fugaku", + "allocation_project_id": "rkp00010", + "scheduler": "pbs", + "runner": "fugaku-runner", + }, + }, } ), encoding="utf-8", @@ -101,6 +110,8 @@ def test_profile_usage_overview_links_profile_triggers_results_and_node_hours(tm assert row["latest_trigger_run"]["status"] == "submitted" assert row["latest_result"]["filename"] == result_file assert row["latest_result"]["trigger_headline"] == "Scheduled / qws-fugaku-time" + assert row["latest_result"]["environment_snapshot"]["short_hash"] == "sha256:54d4b0024f..." + assert row["latest_result"]["environment_snapshot"]["allocation_project_id"] == "rkp00010" def test_profile_usage_overview_handles_missing_db(tmp_path): diff --git a/result_server/utils/profile_usage_overview.py b/result_server/utils/profile_usage_overview.py index 6d8d972..c1bceab 100644 --- a/result_server/utils/profile_usage_overview.py +++ b/result_server/utils/profile_usage_overview.py @@ -184,6 +184,7 @@ def _latest_result_context(record: dict[str, Any] | None) -> dict[str, Any] | No if not record: return None trigger_summary = summarize_execution_trigger(record["data"]) + snapshot = _environment_snapshot_context(record["data"].get("environment_snapshot")) return { "filename": record["filename"], "timestamp": record["timestamp_label"], @@ -192,6 +193,7 @@ def _latest_result_context(record: dict[str, Any] | None) -> dict[str, Any] | No "exp": record["data"].get("Exp") or "-", "pipeline_id": record["data"].get("pipeline_id") or "-", "trigger_headline": trigger_summary.get("headline") or "-", + "environment_snapshot": snapshot, } @@ -203,3 +205,24 @@ def _latest_run_context(run: dict[str, Any] | None) -> dict[str, str] | None: "created_at": str(run.get("created_at") or "-"), "reason": str(run.get("reason") or "-"), } + + +def _environment_snapshot_context(snapshot: Any) -> dict[str, str] | None: + if not isinstance(snapshot, dict): + return None + snapshot_hash = str(snapshot.get("hash") or "").strip() + if not snapshot_hash: + return None + summary = snapshot.get("summary") + summary = summary if isinstance(summary, dict) else {} + short_hash = snapshot_hash + if snapshot_hash.startswith("sha256:") and len(snapshot_hash) > 18: + short_hash = f"{snapshot_hash[:17]}..." + return { + "hash": snapshot_hash, + "short_hash": short_hash, + "system": str(summary.get("system") or "-"), + "allocation_project_id": str(summary.get("allocation_project_id") or "-"), + "scheduler": str(summary.get("scheduler") or "-"), + "runner": str(summary.get("runner") or "-"), + }