(task_file: Path, max_data_rows: int)
| 747 | |
| 748 | |
| 749 | def prepare_task_info(task_file: Path, max_data_rows: int) -> Optional[Dict]: |
| 750 | |
| 751 | try: |
| 752 | |
| 753 | category, instruction, data_filenames = parse_task_file(task_file) |
| 754 | |
| 755 | if not instruction: |
| 756 | print(f"⚠️ Skip task {task_file}: missing instruction content") |
| 757 | return None |
| 758 | |
| 759 | if not data_filenames: |
| 760 | print(f"⚠️ Skip task {task_file}: missing data file list") |
| 761 | return None |
| 762 | |
| 763 | data_directory = task_file.parent |
| 764 | data_files = find_data_files(data_directory, data_filenames) |
| 765 | |
| 766 | if not data_files: |
| 767 | print(f"⚠️ Skip task {task_file}: data files not found {data_filenames} in directory {data_directory}") |
| 768 | return None |
| 769 | |
| 770 | |
| 771 | missing_files = set(data_filenames) - set(data_files.keys()) |
| 772 | if missing_files: |
| 773 | print(f"⚠️ Skip task {task_file}: missing data files {missing_files}") |
| 774 | return None |
| 775 | |
| 776 | |
| 777 | data_info = {} |
| 778 | for filename, filepath in data_files.items(): |
| 779 | try: |
| 780 | data_info[filename] = read_data_file(filepath, max_data_rows) |
| 781 | except Exception as e: |
| 782 | print(f"⚠️ Skip task {task_file}: read data file {filename} Failed: {e}") |
| 783 | return None |
| 784 | |
| 785 | difficulty = task_file.stem.split('_')[-1] if not task_file.stem.endswith('_mul') else task_file.stem.split('_')[-2] |
| 786 | print(difficulty) |
| 787 | print(data_directory) |
| 788 | is_multi = task_file.stem.endswith('_mul') |
| 789 | |
| 790 | image_path=None |
| 791 | refine_folders = [f for f in data_directory.glob("refine*") if f.is_dir()] |
| 792 | if refine_folders: |
| 793 | for refine_folder in refine_folders: |
| 794 | if refine_folder.is_dir(): |
| 795 | if not is_multi: |
| 796 | png_files = list(refine_folder.glob(f"*{difficulty}.png")) |
| 797 | if png_files: |
| 798 | image_path = png_files[0] |
| 799 | else: |
| 800 | png_files = list(refine_folder.glob(f"*{difficulty}_mul.png")) |
| 801 | if png_files: |
| 802 | image_path = png_files[0] |
| 803 | if not image_path: |
| 804 | if not is_multi: |
| 805 | png_files = list(data_directory.glob(f"*{difficulty}.png")) |
| 806 | if png_files: |
nothing calls this directly
no test coverage detected