(task_file: Path, max_data_rows: int)
| 786 | |
| 787 | |
| 788 | def prepare_task_info(task_file: Path, max_data_rows: int) -> Optional[Dict]: |
| 789 | |
| 790 | try: |
| 791 | |
| 792 | category, instruction, data_filenames = parse_task_file(task_file) |
| 793 | |
| 794 | if not instruction: |
| 795 | print(f"⚠️ Skip task {task_file}: missing instruction content") |
| 796 | return None |
| 797 | |
| 798 | if not data_filenames: |
| 799 | print(f"⚠️ Skip task {task_file}: missing data file list") |
| 800 | return None |
| 801 | |
| 802 | data_directory = task_file.parent |
| 803 | data_files = find_data_files(data_directory, data_filenames) |
| 804 | |
| 805 | if not data_files: |
| 806 | print(f"⚠️ Skip task {task_file}: data files not found {data_filenames} in directory {data_directory}") |
| 807 | return None |
| 808 | |
| 809 | |
| 810 | missing_files = set(data_filenames) - set(data_files.keys()) |
| 811 | if missing_files: |
| 812 | print(f"⚠️ Skip task {task_file}: missing data files {missing_files}") |
| 813 | return None |
| 814 | |
| 815 | |
| 816 | data_info = {} |
| 817 | for filename, filepath in data_files.items(): |
| 818 | try: |
| 819 | data_info[filename] = read_data_file(filepath, max_data_rows) |
| 820 | except Exception as e: |
| 821 | print(f"⚠️ Skip task {task_file}: read data file {filename} Failed: {e}") |
| 822 | return None |
| 823 | |
| 824 | difficulty = task_file.stem.split('_')[-1] if not task_file.stem.endswith('_mul') else task_file.stem.split('_')[-2] |
| 825 | is_multi = task_file.stem.endswith('_mul') |
| 826 | |
| 827 | image_path=None |
| 828 | refine_folders = [f for f in data_directory.glob("refine*") if f.is_dir()] |
| 829 | if refine_folders: |
| 830 | for refine_folder in refine_folders: |
| 831 | if refine_folder.is_dir(): |
| 832 | if not is_multi: |
| 833 | png_files = list(refine_folder.glob(f"*{difficulty}.png")) |
| 834 | if png_files: |
| 835 | image_path = png_files[0] |
| 836 | else: |
| 837 | png_files = list(refine_folder.glob(f"*{difficulty}_mul.png")) |
| 838 | if png_files: |
| 839 | image_path = png_files[0] |
| 840 | if not image_path: |
| 841 | if not is_multi: |
| 842 | png_files = list(data_directory.glob(f"*{difficulty}.png")) |
| 843 | if png_files: |
| 844 | image_path = png_files[0] |
| 845 | else: |
nothing calls this directly
no test coverage detected