()
| 92 | |
| 93 | |
| 94 | async def main(): |
| 95 | args = parse_args() |
| 96 | output_dir = Path(args.output_dir).expanduser() |
| 97 | output_dir.mkdir(parents=True, exist_ok=True) |
| 98 | configure_logging(log_path=output_dir / "logs/log.txt") |
| 99 | dataset = JSONLReader.parse_file(args.dataset_json) |
| 100 | |
| 101 | current_time = Time.instance().value or time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) |
| 102 | Time.instance().value = current_time |
| 103 | result_file = output_dir / f"{args.domain}_{args.llm_name}_{current_time}.json" |
| 104 | latency_target = str(output_dir) |
| 105 | |
| 106 | agent_names = [name for name, num in zip(args.agent_names, args.agent_nums) for _ in range(num)] |
| 107 | kwargs = get_kwargs(args.mode, len(agent_names)) |
| 108 | |
| 109 | kv_config: Optional[KVCommConfig] = None |
| 110 | if args.execution_mode == "allow_kv_reuse": |
| 111 | kv_config = KVCommConfig.from_env().apply_overrides( |
| 112 | threshold=args.kv_threshold, |
| 113 | max_anchor_num=args.kv_max_anchor_num, |
| 114 | window_size=args.kv_window_size, |
| 115 | thread_pool_workers=args.kv_thread_workers, |
| 116 | worker_timeout=args.kv_worker_timeout, |
| 117 | ) |
| 118 | else: |
| 119 | kv_config = KVCommConfig.from_env() |
| 120 | |
| 121 | graph = Graph( |
| 122 | domain=args.domain, |
| 123 | llm_name=args.llm_name, |
| 124 | agent_names=agent_names, |
| 125 | decision_method=args.decision_method, |
| 126 | kv_config=kv_config, |
| 127 | **kwargs, |
| 128 | ) |
| 129 | |
| 130 | num_batches = int(len(dataset) / args.batch_size) |
| 131 | total_solved, total_executed = 0, 0 |
| 132 | |
| 133 | for i_batch in range(num_batches): |
| 134 | logger.opt(colors=True).info(f"<blue>[BATCH]</blue> {i_batch} {'-' * 40}") |
| 135 | start_ts = time.time() |
| 136 | current_batch = dataloader(dataset, args.batch_size, i_batch) |
| 137 | if not current_batch: |
| 138 | logger.warning("No more data available.") |
| 139 | break |
| 140 | |
| 141 | tasks = [] |
| 142 | meta_info = [] |
| 143 | for record in current_batch: |
| 144 | realized_graph = copy.deepcopy(graph) |
| 145 | realized_graph.spatial_logits = graph.spatial_logits |
| 146 | realized_graph.temporal_logits = graph.temporal_logits |
| 147 | task = record["prompt"] |
| 148 | tests = record["test"] |
| 149 | input_dict = {"task": task, "_batch_index": i_batch} |
| 150 | |
| 151 | mode_kwargs = {} |
no test coverage detected