text stringlengths 0 1.47k |
|---|
logger.warning("[{}] missing from raw/clean; skipping".format(rig_id)) |
continue |
# The failed list may be stale: only touch entries still empty now. |
was_empty = is_empty_entry(face_data.get(rig_id)) |
if only_if_currently_empty and not was_empty: |
skipped_not_empty += 1 |
continue |
try: |
entry, used_fallback = resolve_rig( |
rig_id, raw_data[rig_id], clean_data[rig_id], client, |
system_prompt=system_prompt, max_tokens=max_tokens, |
max_retries=max_retries, timeout_seconds=timeout_seconds, |
fallback_on_error=False, include_hint=False, |
) |
except Exception as err: # noqa: BLE001 — exhausted retries: keep the entry |
logger.warning("[{}] LLM resolve failed: {}".format(rig_id, err)) |
entry, used_fallback = None, True |
# Accept only clean non-empty LLM wins. used_fallback=True means the |
# rule-based hint came back on timeout — the same answer that already |
# failed the first pass. |
if entry is not None and not used_fallback and is_non_empty_entry(entry): |
face_data[rig_id] = entry |
updated += 1 |
# Save on update only: an unchanged entry doesn't warrant |
# rewriting the whole (MB-sized) JSON on shared storage. |
save_json(face_data, face_path) |
elif was_empty: |
still_empty.append(rig_id) |
else: |
# --force_reattempt on a non-empty (rule-fallback) entry that the |
# LLM couldn't beat: keep it, but don't log it as "still empty". |
kept_existing += 1 |
# Append (like every other id log in this stage) rather than truncate: a |
# --failed_list run only sees a subset, and a truncating write would |
# replace the global record with just that subset. |
known_empty = (set(read_id_list(still_empty_path)) |
if os.path.exists(still_empty_path) else set()) |
if still_empty: |
new_ids = [rig_id for rig_id in still_empty if rig_id not in known_empty] |
if new_ids: |
append_id_list(still_empty_path, new_ids) |
logger.info("{} rigs still empty ({} newly recorded) -> {}".format( |
len(still_empty), len(new_ids), still_empty_path)) |
elif known_empty: |
logger.warning( |
"No rig came back empty in this run, but {} still lists {} id(s) " |
"from earlier runs — it may be stale.".format( |
still_empty_path, len(known_empty))) |
if (failed_list_path and only_if_currently_empty and target_ids |
and skipped_not_empty >= len(target_ids) / 2): |
logger.warning( |
"{}/{} listed rigs were skipped because their current entry is " |
"not 'empty'. failed_face_joints.txt records rule-based " |
"FALLBACKS, whose entries are usually non-empty — pass " |
"--force_reattempt to re-attempt them.".format( |
skipped_not_empty, len(target_ids))) |
logger.info( |
"Done. updated={} | still_empty={} | kept_existing={} | " |
"skipped_not_empty={} | missing_raw_or_clean={} | total={}".format( |
updated, len(still_empty), kept_existing, skipped_not_empty, |
missing, len(target_ids))) |
return face_data |
# ───────────────────────────────────────────────────────────────────────────── |
# CLI |
# ───────────────────────────────────────────────────────────────────────────── |
def main(): |
parser = argparse.ArgumentParser( |
description="Re-run LLM face-joint selection on rigs whose source is 'empty'; " |
"updates face_joint_names.json in place when a pair is found.") |
parser.add_argument("--raw", required=True, help="Raw joint_names.json.") |
parser.add_argument("--cleaned", required=True, help="clean_joint_names.json.") |
parser.add_argument("--face", required=True, |
help="face_joint_names.json — updated IN PLACE; a '.bak' sibling " |
"is made on first run.") |
parser.add_argument("--failed_list", default=None, |
help="Optional txt file with one rig id per line. Default: every " |
"rig whose entry in --face has source=='empty'. NOTE: " |
"failed_face_joints.txt lists rule-based FALLBACKS, whose " |
"entries are usually non-empty — combine with " |
"--force_reattempt or they will all be skipped.") |
parser.add_argument("--still_empty_log", default=None, |
help="Path to write rig ids the LLM still couldn't fill (default: " |
"sibling 'still_empty_face_joints.txt').") |
parser.add_argument("--force_reattempt", action="store_true", |
help="Re-run even if the current entry isn't source=='empty' anymore. " |
"Existing non-empty entries are only replaced by a clean " |
"non-empty LLM win, never by 'empty'.") |
parser.add_argument("--rig_timeout", type=int, default=60, |
help="Per-rig wall-time budget in seconds (SIGALRM). 0 disables.") |
add_llm_args(parser, default_max_tokens=2048) |
args = parser.parse_args() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.