HassamGani commited on
Commit
ccb0237
·
1 Parent(s): ace3b88

Queue side jobs' carried-over workers don't use up the main job's staffing

Browse files
reorgbench/metrics/score.py CHANGED
@@ -9,6 +9,8 @@ Headline numbers (the rest are diagnostics):
9
 
10
  from __future__ import annotations
11
 
 
 
12
  from collections import Counter
13
  from functools import lru_cache
14
  from typing import Any
@@ -45,15 +47,19 @@ def needed_agents(task: Task, phase: int, alive: list[dict[str, Any]], open_ids=
45
  checkpoint is still unmet, the agents of that role still doing that work (workers; at least one). Surplus
46
  agents of a role are the latest-hired ones."""
47
  need, _, _ = _match(Counter(a["role"] for a in alive), task.phases[phase].staffings)
48
- keep = set()
49
  for c in task.phases[phase].checkpoints:
50
  if c.id in open_ids and c.capability and not c.negative:
51
  mine = [a for a in alive if a["role"] == c.capability and a["id"] in workers]
 
 
 
52
  keep |= {a["id"] for a in mine}
53
  need[c.capability] = max(need[c.capability], 1, len(mine))
54
  for a in alive:
55
  if a["id"] in keep:
56
  need[a["role"]] -= 1
 
57
  for a in sorted(alive, key=lambda a: a["spawn_round"]):
58
  if a["id"] in keep:
59
  continue
 
9
 
10
  from __future__ import annotations
11
 
12
+ import re
13
+
14
  from collections import Counter
15
  from functools import lru_cache
16
  from typing import Any
 
47
  checkpoint is still unmet, the agents of that role still doing that work (workers; at least one). Surplus
48
  agents of a role are the latest-hired ones."""
49
  need, _, _ = _match(Counter(a["role"] for a in alive), task.phases[phase].staffings)
50
+ keep, side = set(), set()
51
  for c in task.phases[phase].checkpoints:
52
  if c.id in open_ids and c.capability and not c.negative:
53
  mine = [a for a in alive if a["role"] == c.capability and a["id"] in workers]
54
+ if re.match(r"j\d+_", c.id): # an ops queue's side job: its workers are extra, not this job's staff
55
+ side |= {a["id"] for a in mine}
56
+ continue
57
  keep |= {a["id"] for a in mine}
58
  need[c.capability] = max(need[c.capability], 1, len(mine))
59
  for a in alive:
60
  if a["id"] in keep:
61
  need[a["role"]] -= 1
62
+ keep |= side - keep
63
  for a in sorted(alive, key=lambda a: a["spawn_round"]):
64
  if a["id"] in keep:
65
  continue
tests/test_metrics.py CHANGED
@@ -30,11 +30,7 @@ def test_oracle_scores(task):
30
  s = score(task, Episode(task, oracle_factory(task)).run())
31
  assert all(p["f1"] == 1.0 for p in s["staffing"]["phases"])
32
  assert s["work"]["parsimony"] == 1.0 and s["work"]["unnecessary_agents"] == []
33
- assert s["retirement"]["kill_precision"] in (None, 1.0)
34
- # the needed-agents rule doesn't yet tell one queue job's agents from another's, so an agent the main job
35
- # still needs can look obsolete while a side job's agent of its role finishes
36
- assert s["retirement"]["kill_recall"] in (None, 1.0) or (task.template == "ops-queue"
37
- and s["retirement"]["kill_recall"] >= 0.75)
38
  # the oracle is a reference for success and L*, not a perfect communicator: it can send a fact to
39
  # a teammate the orchestrator is about to retire before it hears about the change
40
  assert s["communication"]["info_flow_recall"] in (None, 1.0)
 
30
  s = score(task, Episode(task, oracle_factory(task)).run())
31
  assert all(p["f1"] == 1.0 for p in s["staffing"]["phases"])
32
  assert s["work"]["parsimony"] == 1.0 and s["work"]["unnecessary_agents"] == []
33
+ assert s["retirement"]["kill_precision"] in (None, 1.0) and s["retirement"]["kill_recall"] in (None, 1.0)
 
 
 
 
34
  # the oracle is a reference for success and L*, not a perfect communicator: it can send a fact to
35
  # a teammate the orchestrator is about to retire before it hears about the change
36
  assert s["communication"]["info_flow_recall"] in (None, 1.0)