Answer principles round 2: 0 🔴, 0 🟡; decide ships-alone in one predicate both modules call
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""The lines the preflight prints, stated from what it gathered."""
|
||||
from todo_table import BUNDLE_MAX_R, bundle_candidates, Item, version
|
||||
from todo_table import BUNDLE_MAX_R, bundle_candidates, Item, ships_alone, version
|
||||
from failure import Failure
|
||||
from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, Ran
|
||||
from chunk_pick import LastCut, unreleased_entries
|
||||
@@ -66,7 +66,7 @@ def open_pulls(stdout: str, forge: Forge, branch: str) -> list[str]:
|
||||
|
||||
def bundled(plan: Plan) -> list[str]:
|
||||
first, candidates = plan.first, bundle_candidates(plan.items, plan.first)
|
||||
if first.scores.get("R", 0) > BUNDLE_MAX_R:
|
||||
if ships_alone(first):
|
||||
return [f"- Item {first.id} has R above {BUNDLE_MAX_R}, so it ships alone."]
|
||||
if not candidates:
|
||||
return [f"- No other item of release {version(first.release)} may join item {first.id}'s chunk."]
|
||||
|
||||
+8
-3
@@ -202,11 +202,16 @@ def renames(todo: str) -> set[tuple[int, int, int]] | Failure:
|
||||
return marked
|
||||
|
||||
|
||||
def ships_alone(item: Item) -> bool:
|
||||
"""An item above BUNDLE_MAX_R joins no chunk, and none joins it."""
|
||||
return item.scores.get("R", 0) > BUNDLE_MAX_R
|
||||
|
||||
|
||||
def bundle_candidates(found: list[Item], first: Item) -> list[Item]:
|
||||
"""The items of first's release, in the table's order, that a chunk taking first may take too: those that do not wait once the chunk's own items count as done. An item above BUNDLE_MAX_R ships alone."""
|
||||
chunk = {item.id for item in found if item.release == first.release and item.scores.get("R", 0) <= BUNDLE_MAX_R}
|
||||
if first.id not in chunk:
|
||||
"""The items of first's release, in the table's order, that a chunk taking first may take too: those that do not ship alone, and do not wait once the chunk's own items count as done."""
|
||||
if ships_alone(first):
|
||||
return []
|
||||
chunk = {item.id for item in found if item.release == first.release and not ships_alone(item)}
|
||||
# Dropping an item that waits may make another wait on it, so drop until none waits.
|
||||
while waits := waiting(found, chunk) & chunk:
|
||||
chunk -= waits
|
||||
|
||||
Reference in New Issue
Block a user