(task_name)
| 329 | |
| 330 | @staticmethod |
| 331 | def find_field_by_task(task_name): |
| 332 | if len(Tasks.reverse_field_index) == 0: |
| 333 | # Lazy init, not thread safe |
| 334 | field_dict = { |
| 335 | Fields.cv: [ |
| 336 | getattr(Tasks, attr) for attr in dir(CVTasks) |
| 337 | if not attr.startswith('__') |
| 338 | ], |
| 339 | Fields.nlp: [ |
| 340 | getattr(Tasks, attr) for attr in dir(NLPTasks) |
| 341 | if not attr.startswith('__') |
| 342 | ], |
| 343 | Fields.audio: [ |
| 344 | getattr(Tasks, attr) for attr in dir(AudioTasks) |
| 345 | if not attr.startswith('__') |
| 346 | ], |
| 347 | Fields.multi_modal: [ |
| 348 | getattr(Tasks, attr) for attr in dir(MultiModalTasks) |
| 349 | if not attr.startswith('__') |
| 350 | ], |
| 351 | Fields.science: [ |
| 352 | getattr(Tasks, attr) for attr in dir(ScienceTasks) |
| 353 | if not attr.startswith('__') |
| 354 | ], |
| 355 | } |
| 356 | |
| 357 | for field, tasks in field_dict.items(): |
| 358 | for task in tasks: |
| 359 | if task in Tasks.reverse_field_index: |
| 360 | raise ValueError(f'Duplicate task: {task}') |
| 361 | Tasks.reverse_field_index[task] = field |
| 362 | |
| 363 | return Tasks.reverse_field_index.get(task_name) |
| 364 | |
| 365 | |
| 366 | class InputFields(object): |
no test coverage detected