Fix exploration slot and same-maker review explanation
This commit is contained in:
1 parent
e8d29e80e0
commit
190d036901
2 files changed
+40
-5
No files matched your search
+12
-5
@@ -244,12 +244,14 @@ def choose(candidates, records, availability, kind, difficulty, review_of=None,
|
||||
pool.sort(key=key)
|
||||
choice = pool[0] if pool else None
|
||||
explored = None
|
||||
if choice is not None and difficulty == 1 and not _pattern_match(choice, prefer):
|
||||
if (choice is not None and difficulty == 1 and not _pattern_match(choice, prefer)
|
||||
and _cell(stats, choice["worker"], kind, difficulty)["n"] >= MIN_ATTEMPTS):
|
||||
total = sum(_cell(stats, c["worker"], kind, difficulty)["n"] for c in candidates)
|
||||
if total >= EXPLORE_EVERY and total % EXPLORE_EVERY == EXPLORE_EVERY - 1:
|
||||
if total >= EXPLORE_EVERY - 1 and total % EXPLORE_EVERY == EXPLORE_EVERY - 1:
|
||||
thinner = [c for c in pool
|
||||
if _cell(stats, c["worker"], kind, difficulty)["n"] < MIN_ATTEMPTS
|
||||
and price_of(c) < price_of(choice)]
|
||||
if c is not choice
|
||||
and _cell(stats, c["worker"], kind, difficulty)["n"] < MIN_ATTEMPTS
|
||||
and price_of(c) <= price_of(choice)]
|
||||
if thinner:
|
||||
thinner.sort(key=key)
|
||||
explored, choice = choice, thinner[0]
|
||||
@@ -311,7 +313,12 @@ def explain_choice(result, kind, difficulty):
|
||||
lines.append("this is an exploration pick: %s was the usual choice, passed over once so a cheaper "
|
||||
"thin-record worker gathers evidence" % result["explored"])
|
||||
if result.get("author_maker"):
|
||||
lines.append("it is from a different maker than the author (%s)" % result["author_maker"])
|
||||
choice_maker = choice.get("maker") or maker_of(choice.get("model") or choice["worker"])
|
||||
if choice_maker != result["author_maker"]:
|
||||
lines.append("it is from a different maker than the author (%s)" % result["author_maker"])
|
||||
else:
|
||||
lines.append("no worker from a different maker than the author (%s) is available, "
|
||||
"so the review stays with the same maker" % result["author_maker"])
|
||||
groups, order = {}, []
|
||||
for worker, reason in result["passed_over"]:
|
||||
if reason not in groups:
|
||||
|
||||
@@ -252,6 +252,34 @@ class DigestTests(OrchCase):
|
||||
self.assertEqual(got2["count"], 0)
|
||||
|
||||
|
||||
class ExplorationTests(unittest.TestCase):
|
||||
def test_one_low_stakes_task_in_ten_tries_the_cheaper_thin_worker(self):
|
||||
"""About one difficulty-1 task in ten explores a cheaper thin-record worker."""
|
||||
from sisi import routing
|
||||
cands = [
|
||||
{"worker": "tool/alpha-1", "tool": "tool", "model": "alpha-1", "maker": "alpha",
|
||||
"plan": "per-use", "cost": 5.0, "allowance_pct_left": None, "usable": True,
|
||||
"aliases": ["tool/alpha-1", "alpha-1"]},
|
||||
{"worker": "tool/beta-1", "tool": "tool", "model": "beta-1", "maker": "beta",
|
||||
"plan": "per-use", "cost": 5.0, "allowance_pct_left": None, "usable": True,
|
||||
"aliases": ["tool/beta-1", "beta-1"]},
|
||||
]
|
||||
# Same price: alpha (proven, stronger prior) is the usual pick. Every tenth judged
|
||||
# attempt for the kind and difficulty, the thin-record beta gets the task instead.
|
||||
cands[0]["prior_score"] = 90.0
|
||||
cands[1]["prior_score"] = 10.0
|
||||
records = [{"kind": "attempt", "id": "e%d" % i, "type": "read", "difficulty": 1,
|
||||
"worker": "tool/alpha-1", "outcome": "accepted", "check": "tests"}
|
||||
for i in range(9)]
|
||||
before = routing.choose(cands, records[:-1], {}, "read", 1, now=1000.0)
|
||||
self.assertEqual(before["choice"]["worker"], "tool/alpha-1")
|
||||
tenth = routing.choose(cands, records, {}, "read", 1, now=1000.0)
|
||||
self.assertEqual(tenth["choice"]["worker"], "tool/beta-1")
|
||||
self.assertEqual(tenth["explored"], "tool/alpha-1")
|
||||
again = routing.choose(cands, records, {}, "read", 1, now=1000.0)
|
||||
self.assertEqual(again["choice"]["worker"], "tool/beta-1", "deterministic for one record")
|
||||
|
||||
|
||||
class GenericTests(unittest.TestCase):
|
||||
def test_no_model_names_or_prices_in_product_files(self):
|
||||
"""The product ships no model id, model-family name or price."""
|
||||
|
||||
Reference in new issue
Block a user