tnk2908 commited on
Commit
8afcedd
1 Parent(s): 4dd6602

Add results save frequency

Browse files
Files changed (1) hide show
  1. analyse.py +10 -0
analyse.py CHANGED
@@ -161,6 +161,9 @@ def create_args():
161
  default=None,
162
  help="Where to save results",
163
  )
 
 
 
164
  parser.add_argument(
165
  "--figs-dir",
166
  type=str,
@@ -226,6 +229,13 @@ def get_results(args, prompts, msgs):
226
  "msg_len": len(msg_bytes),
227
  }
228
  )
 
 
 
 
 
 
 
229
  pbar.update()
230
  return results
231
 
 
161
  default=None,
162
  help="Where to save results",
163
  )
164
+ parser.add_argument(
165
+ "--results-save-freq", type=int, default=100, help="Save frequency"
166
+ )
167
  parser.add_argument(
168
  "--figs-dir",
169
  type=str,
 
229
  "msg_len": len(msg_bytes),
230
  }
231
  )
232
+ if (len(results) + 1) % args.results_save_freq == 0:
233
+ if args.results_save_file:
234
+ os.makedirs(os.path.dirname(args.results_save_file), exist_ok=True)
235
+ with open(args.results_save_file, "w") as f:
236
+ json.dump(results, f)
237
+ print(f"Saved results to {args.results_save_file}")
238
+
239
  pbar.update()
240
  return results
241