(task_file: Path, max_data_rows: int)
| 715 | |
| 716 | |
| 717 | def prepare_task_info(task_file: Path, max_data_rows: int) -> Optional[Dict]: |
| 718 | |
| 719 | try: |
| 720 | |
| 721 | category, instruction, data_filenames = parse_task_file(task_file) |
| 722 | |
| 723 | if not instruction: |
| 724 | print(f"⚠️ Skip task {task_file}: missing instruction content") |
| 725 | return None |
| 726 | |
| 727 | if not data_filenames: |
| 728 | print(f"⚠️ Skip task {task_file}: missing data file list") |
| 729 | return None |
| 730 | |
| 731 | data_directory = task_file.parent |
| 732 | data_files = find_data_files(data_directory, data_filenames) |
| 733 | |
| 734 | if not data_files: |
| 735 | print(f"⚠️ Skip task {task_file}: data files not found {data_filenames} in directory {data_directory}") |
| 736 | return None |
| 737 | |
| 738 | |
| 739 | missing_files = set(data_filenames) - set(data_files.keys()) |
| 740 | if missing_files: |
| 741 | print(f"⚠️ Skip task {task_file}: missing data files {missing_files}") |
| 742 | return None |
| 743 | |
| 744 | |
| 745 | data_info = {} |
| 746 | for filename, filepath in data_files.items(): |
| 747 | try: |
| 748 | data_info[filename] = read_data_file(filepath, max_data_rows) |
| 749 | except Exception as e: |
| 750 | print(f"⚠️ Skip task {task_file}: read data file {filename} Failed: {e}") |
| 751 | return None |
| 752 | |
| 753 | difficulty = task_file.stem.split('_')[-1] if not task_file.stem.endswith('_mul') else task_file.stem.split('_')[-2] |
| 754 | print(difficulty) |
| 755 | print(data_directory) |
| 756 | is_multi = task_file.stem.endswith('_mul') |
| 757 | |
| 758 | image_path=None |
| 759 | refine_folders = [f for f in data_directory.glob("refine*") if f.is_dir()] |
| 760 | if refine_folders: |
| 761 | for refine_folder in refine_folders: |
| 762 | if refine_folder.is_dir(): |
| 763 | if not is_multi: |
| 764 | png_files = list(refine_folder.glob(f"*{difficulty}.png")) |
| 765 | if png_files: |
| 766 | image_path = png_files[0] |
| 767 | else: |
| 768 | png_files = list(refine_folder.glob(f"*{difficulty}_mul.png")) |
| 769 | if png_files: |
| 770 | image_path = png_files[0] |
| 771 | if not image_path: |
| 772 | if not is_multi: |
| 773 | png_files = list(data_directory.glob(f"*{difficulty}.png")) |
| 774 | if png_files: |
nothing calls this directly
no test coverage detected