MCPcopy Create free account
hub / github.com/catid/supercharger / write_code

Method write_code

codegen/codegen.py:277–308  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

275 self.handle_judge_pair(task_id=task_id, score=score)
276
277 def write_code(self):
278 # Delete any existing code from a previous run
279 delete_old_scripts(args.sources_dirname, args.function_name)
280
281 try:
282 while True:
283 self.handle_results()
284
285 active_workers = self.manager.active_workers()
286 approx_queue_depth = self.manager.approx_queue_depth()
287 if approx_queue_depth == 0 and active_workers < args.workers:
288 logging.info(f"Work queue empty and detected only {active_workers}/{args.workers} workers active. Adding job...")
289 self.add_code_or_test_job()
290 else:
291 logging.info(f"Work queue depth = {approx_queue_depth} active workers = {active_workers}/{args.workers}")
292
293 for pair_score in self.pair_scores.values():
294 (code_id, test_id, score) = pair_score
295 if score is None:
296 continue
297
298 if score >= args.threshold:
299 logging.info(f"Found a good code/test pair: code={code_id} test={test_id} score={score}")
300 copy_candidate_scripts(args.sources_dirname, args.function_name, code_id, test_id)
301 logging.info("Wrote final code and test to disk. Exiting...")
302 return
303 except KeyboardInterrupt:
304 logging.info("Terminating early on user request...")
305 except Exception as e:
306 logging.error(f"Exception in run_queue: {e}")
307 finally:
308 self.manager.terminate()
309
310def main(args):
311 logging.info(f"Input comments: {args.comments}")

Callers 1

mainFunction · 0.95

Calls 7

handle_resultsMethod · 0.95
add_code_or_test_jobMethod · 0.95
delete_old_scriptsFunction · 0.85
copy_candidate_scriptsFunction · 0.85
active_workersMethod · 0.80
approx_queue_depthMethod · 0.80
terminateMethod · 0.45

Tested by

no test coverage detected