#!/usr/bin/env python3 import sys,re # args: base_config out_config stage1_cache out_root ds_name exp views schedules_csv base,out,stage1_cache,out_root,ds_name,exp,views,sched = sys.argv[1:9] txt=open(base).read() # cut everything from 'val_appforce:' to EOF, replace with our block idx=txt.index('\nval_appforce:') head=txt[:idx] sched_list='['+', '.join(sched.split(','))+']' block=f""" val_appforce: enabled: true every: 5000 at_step0: false views: {views} schedules: {sched_list} seed: 42 limit: 0 batch_size: 6 single: true decode_procs: 1 ref_threads: 8 stage1_cache: {stage1_cache} out_root: {out_root} ref_python: /lp-dev/jonghoon/mv-mesh/envs/mv-sam3d/bin/python eval_dataset_flag: toys4k datasets: - name: {ds_name} exp: {exp} """ open(out,'w').write(head+block) print("wrote",out)