"""Why did a chain run end in generation_failed? Prints, per recovery attempt, the room whose layout search found no pose, the entities in conflict and the native failure status, plus the first lines of the execute log's last error. why_failed.py [...]""" import json import sys from pathlib import Path for exp in map(Path, sys.argv[1:]): meta = json.load(open(exp / 'experiment.json')) case = Path(meta['runs'][0]['case']) print('==', exp.name, '| case', case.name) path = case / 'layout_recovery_execution.json' if not path.is_file(): print(' no layout_recovery_execution.json (the failure is elsewhere):') log = (exp / 'run_01' / 'execute.log').read_text(errors='replace').splitlines() for line in log[-6:]: print(' ', line[:300]) continue data = json.load(open(path)) for i, attempt in enumerate(data['attempts']): plan = attempt.get('recovery_plan', {}) print(' attempt %d: failed room %-10s status %-34s changed %-18s conflicts %s' % ( i, plan.get('failed_room_id'), plan.get('native_failure_status'), plan.get('changed_entity_id'), plan.get('conflict_counts')))