fix: generation_N.jsonl candidate_id format mismatch vs filenames (#669)

This commit is contained in:
openhands 2026-03-14 04:27:59 +00:00
parent 0aa819f168
commit b6c07b1d93

View file

@ -762,7 +762,7 @@ for fname in sorted(os.listdir(output_dir)):
if not (fname.startswith('generation_') and fname.endswith('.jsonl')):
continue
try:
int(fname[len('generation_'):-len('.jsonl')]) # validate integer suffix
gen_idx = int(fname[len('generation_'):-len('.jsonl')]) # validate integer suffix
except ValueError:
continue
with open(os.path.join(output_dir, fname)) as f:
@ -773,13 +773,11 @@ for fname in sorted(os.listdir(output_dir)):
fitness = int(d.get('fitness', 0))
if fitness < threshold:
continue
# cid format: "gen{N}_c{MMM}"
if not cid.startswith('gen') or '_c' not in cid:
# cid format: "candidate_XXX" (gen_idx derived from enclosing filename)
if not cid.startswith('candidate_'):
continue
after_gen = cid[3:] # strip "gen"
gen_str, cand_str = after_gen.split('_c', 1)
gen_idx = int(gen_str)
push3_path = os.path.join(
cand_str = cid[len('candidate_'):] # numeric suffix, e.g. "001"
push3_path = os.path.join(
work_dir, f'gen_{gen_idx}',
f'candidate_{int(cand_str):03d}.push3'
)