def _eval_strategy_for_task(model_type: str, task_type_for_data: TaskTypesEnum): models_repo = ModelTypesRepository() model_info = models_repo.model_info_by_id(model_type) task_type_for_model = task_type_for_data task_types_acceptable_for_model = model_info.task_type # if the model can't be used directly for the task type from data if task_type_for_model not in task_types_acceptable_for_model: # search the supplementary task types, that can be included in chain which solves original task globally_compatible_task_types = compatible_task_types( task_type_for_model) compatible_task_types_acceptable_for_model = list( set(task_types_acceptable_for_model).intersection( set(globally_compatible_task_types))) if len(compatible_task_types_acceptable_for_model) == 0: raise ValueError( f'Model {model_type} can not be used as a part of {task_type_for_model}.' ) task_type_for_model = compatible_task_types_acceptable_for_model[0] strategy = models_repo.model_info_by_id(model_type).current_strategy( task_type_for_model) return strategy
def test_search_in_repository_by_id_correct(): repo = ModelTypesRepository(mocked_path()) model = repo.model_info_by_id(id='tpot') assert model.id == 'tpot' assert 'automl' in model.tags