chore:fixing cli build due to missing variable in build phase 5 and the headless_runner not doing setup/tagging automatically

This commit is contained in:
matt 2025-09-05 12:46:49 -07:00
parent 9eafe49393
commit 668f1a7185
2 changed files with 41 additions and 3 deletions

View file

@ -45,12 +45,13 @@ class ColorBalanceMixin:
Uses the color source matrix to aggregate counts for each color.
"""
matrix = self._compute_color_source_matrix()
counts = {c:0 for c in ['W','U','B','R','G']}
# Track only WUBRG here; ignore colorless 'C' and any other markers for this computation.
counts = {c: 0 for c in ['W', 'U', 'B', 'R', 'G']}
for name, colors in matrix.items():
entry = self.card_library.get(name, {})
copies = entry.get('Count',1)
copies = entry.get('Count', 1)
for c, v in colors.items():
if v:
if v and c in counts:
counts[c] += copies
return counts

View file

@ -4,9 +4,45 @@ import argparse
import json
import os
from typing import Any, Dict, List, Optional
import time
import sys
import os
from deck_builder.builder import DeckBuilder
from deck_builder import builder_constants as bc
from file_setup.setup import initial_setup
from tagging import tagger
def _is_stale(file1: str, file2: str) -> bool:
"""Return True if file2 is missing or older than file1."""
if not os.path.isfile(file2):
return True
if not os.path.isfile(file1):
return True
return os.path.getmtime(file2) < os.path.getmtime(file1)
def _ensure_data_ready():
cards_csv = os.path.join("csv_files", "cards.csv")
tagging_json = os.path.join("csv_files", ".tagging_complete.json")
# If cards.csv is missing, run full setup+tagging
if not os.path.isfile(cards_csv):
print("cards.csv not found, running full setup and tagging...")
initial_setup()
tagger.run_tagging()
_write_tagging_flag(tagging_json)
# If tagging_complete is missing or stale, run tagging
elif not os.path.isfile(tagging_json) or _is_stale(cards_csv, tagging_json):
print(".tagging_complete.json missing or stale, running tagging...")
tagger.run_tagging()
_write_tagging_flag(tagging_json)
def _write_tagging_flag(tagging_json):
import json
from datetime import datetime
os.makedirs(os.path.dirname(tagging_json), exist_ok=True)
with open(tagging_json, 'w', encoding='utf-8') as f:
json.dump({'tagged_at': datetime.now().isoformat(timespec='seconds')}, f)
def run(
command_name: str = "",
@ -273,6 +309,7 @@ def _resolve_value(
def _main() -> int:
_ensure_data_ready()
parser = _build_arg_parser()
args = parser.parse_args()
# Optional config discovery (no prompts)