(input_path, output_path)
| 125 | |
| 126 | # # Single-threaded version |
| 127 | def convert2aitz_single_thread(input_path, output_path): |
| 128 | data = load_json_data(input_path) |
| 129 | base_path = os.path.join(output_path) |
| 130 | |
| 131 | for item in data: |
| 132 | task = item.get("category", "unknown") |
| 133 | episode_id = item.get("episode_id", "unknown") |
| 134 | steps = item.get("steps", [item]) |
| 135 | |
| 136 | for index, each_step in enumerate(steps): |
| 137 | step_id = index if "steps" in item else each_step.get("step_id", index) |
| 138 | |
| 139 | actions, parameters, status = parse_action(each_step["pred"]) |
| 140 | |
| 141 | transformed_entry = { |
| 142 | "action_predict": { |
| 143 | "COA": { |
| 144 | "txt": { |
| 145 | "ACTION": actions, |
| 146 | "ARGS": parameters, |
| 147 | "STATUS": status |
| 148 | }, |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | folder = f"{task}-{episode_id}" |
| 153 | file_name = f"{folder}_{step_id}.json" |
| 154 | folder_path = os.path.join(base_path, folder) |
| 155 | output_path = os.path.join(folder_path, file_name) |
| 156 | |
| 157 | os.makedirs(folder_path, exist_ok=True) |
| 158 | |
| 159 | with open(output_path, 'w', encoding='utf-8') as output_file: |
| 160 | json.dump(transformed_entry, output_file, indent=4, ensure_ascii=False) |
| 161 | |
| 162 | print(f"Saved transformed entry to: {output_path}") |
nothing calls this directly
no test coverage detected