Active user attribute set, latest activities, guarded changes to used values, artefact links, durations and averages; irreversible showcase step
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: sonnet Assistant-Process: 295952@bnt-lap001 Assistant-Session: e93f64ad-516c-46eb-9666-aad8d300c477
This commit is contained in:
parent
6716cee921
commit
8d62c1fbe8
22 changed files with 1025 additions and 35 deletions
|
|
@ -115,3 +115,39 @@ def test_runs_of_different_packs_in_one_repository_are_not_mixed(tmp_path):
|
|||
assert R.scorecard(pa)["tried"] == 2 and R.scorecard(pb)["tried"] == 1
|
||||
assert R.list_runs(pb) != R.list_runs(pa) and len(R.list_runs(pb)) == 1
|
||||
assert R.scorecard(pb)["feedback"]["good"] == 0 and R.all_feedback(pb) == []
|
||||
|
||||
|
||||
# ---- durations -----------------------------------------------------------------------------------------------
|
||||
|
||||
def test_fmt_duration():
|
||||
assert [R.fmt_duration(x) for x in (None, 0, 45, 60, 200, 3600, 3900, 90000)] == ["-", "0 s", "45 s", "1 min", "3 min 20 s", "1 h", "1 h 5 min", "1 d 1 h"]
|
||||
|
||||
|
||||
def test_run_times_and_average_of_succeeded_runs_only(pk):
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import json
|
||||
def timed(operator, seconds, outcome):
|
||||
r = R.create(pk, operator)
|
||||
start = datetime(2026, 9, 29, 10, 0, tzinfo=timezone.utc)
|
||||
r.data["created"] = start.isoformat()
|
||||
r.data["outcome"] = outcome
|
||||
r.data["finished"] = (start + timedelta(seconds=seconds)).isoformat()
|
||||
first = next(iter(r.data["steps"]))
|
||||
r.data["steps"][first].update(state="done", started=(start + timedelta(seconds=10)).isoformat(),
|
||||
finished=(start + timedelta(seconds=40)).isoformat())
|
||||
r.path.write_text(json.dumps(r.data))
|
||||
return r
|
||||
a = timed("a", 600, "succeeded"); timed("b", 1200, "succeeded"); timed("c", 9000, "failed"); timed("d", 300, "abandoned")
|
||||
t = R.run_times(R.load(pk, a.data["run_id"]))
|
||||
assert t["elapsed"] == 600 and t["finished_run"] and t["step_seconds"] == {next(iter(a.data["steps"])): 30.0} and t["working"] == 30.0
|
||||
c = R.scorecard(pk)
|
||||
assert c["avg_seconds"] == 900 and c["median_seconds"] == 900 and c["fastest_seconds"] == 600 and c["timed_runs"] == 2 # the failed 9000 s run is not counted
|
||||
assert R.scorecard(pk)["succeeded"] == 2
|
||||
|
||||
|
||||
def test_unfinished_run_elapsed_runs_to_now_and_no_average_without_succeeded_runs(pk):
|
||||
from datetime import datetime, timedelta, timezone
|
||||
r = R.create(pk, "x")
|
||||
t = R.run_times(r, now=datetime.now(timezone.utc) + timedelta(seconds=90))
|
||||
assert not t["finished_run"] and 89 <= t["elapsed"] <= 91
|
||||
assert R.scorecard(pk)["avg_seconds"] is None and R.scorecard(pk)["timed_runs"] == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue