(args)
| 66 | |
| 67 | # Use multiprocessing to speed up processing |
| 68 | def process_step(args): |
| 69 | task, episode_id, step_id, pred, base_path = args |
| 70 | try: |
| 71 | actions, parameters, status = parse_action(pred) |
| 72 | |
| 73 | transformed_entry = { |
| 74 | "action_predict": { |
| 75 | "COA": { |
| 76 | "txt": { |
| 77 | "ACTION": actions, |
| 78 | "ARGS": parameters, |
| 79 | "STATUS": status |
| 80 | }, |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | folder = f"{task}-{episode_id}" |
| 86 | file_name = f"{folder}_{step_id}.json" |
| 87 | output_file_path = os.path.join(base_path, folder, file_name) |
| 88 | |
| 89 | with open(output_file_path, 'w', encoding='utf-8') as output_file: |
| 90 | json.dump(transformed_entry, output_file, indent=4, ensure_ascii=False) |
| 91 | |
| 92 | return f"Saved transformed entry to: {output_file_path}" |
| 93 | except Exception as e: |
| 94 | return f"Error processing step {step_id} in episode {episode_id}: {e}" |
| 95 | |
| 96 | |
| 97 | # # Multi-threaded version |
nothing calls this directly
no test coverage detected