def tool_contract_to_meta_task(tc, max_nchunks): """Shim layer to load tool contracts and convert them to MetaTask type """ # there needs to be special attention here. This is side stepping all the # validation layers used in the rest of the code. def _get_ft(x_): return REGISTERED_FILE_TYPES[x_] schema_option_d = {opt['required'][0]: opt for opt in tc.task.options} # resolve strings to FileType instances input_types = validate_provided_file_types([_get_ft(x.file_type_id) for x in tc.task.input_file_types]) output_types = validate_provided_file_types([_get_ft(x.file_type_id) for x in tc.task.output_file_types]) _spe = os.path.splitext output_file_names = [ (_spe(x.default_name)[0], ft.ext) for x,ft in zip(tc.task.output_file_types, output_types) ] # task_type = validate_task_type(tc.task.is_distributed) if isinstance(tc.task, ScatterToolContractTask): meta_task = _to_meta_scatter_task(tc, task_type, input_types, output_types, schema_option_d, max_nchunks, 'chunk-key') elif isinstance(tc.task, GatherToolContractTask): meta_task = _to_meta_gather_task(tc, task_type, input_types, output_types, schema_option_d) elif isinstance(tc.task, ToolContractTask): meta_task = _to_meta_task(tc, task_type, input_types, output_types, schema_option_d, output_file_names) else: raise TypeError("Unsupported Type {t} {x}".format(x=tc.task, t=type(tc.task))) return meta_task
def tool_contract_to_meta_task(tc, max_nchunks): """Shim layer to load tool contracts and convert them to MetaTask type """ # there needs to be special attention here. This is side stepping all the # validation layers used in the rest of the code. def _get_ft(x_): return REGISTERED_FILE_TYPES[x_] schema_option_d = {opt["required"][0]: opt for opt in tc.task.options} # resolve strings to FileType instances input_types = validate_provided_file_types([_get_ft(x.file_type_id) for x in tc.task.input_file_types]) output_types = validate_provided_file_types([_get_ft(x.file_type_id) for x in tc.task.output_file_types]) _spe = os.path.splitext output_file_names = [(_spe(x.default_name)[0], ft.ext) for x, ft in zip(tc.task.output_file_types, output_types)] # task_type = validate_task_type(tc.task.is_distributed) if isinstance(tc.task, ScatterToolContractTask): meta_task = _to_meta_scatter_task( tc, task_type, input_types, output_types, schema_option_d, max_nchunks, "chunk-key" ) elif isinstance(tc.task, GatherToolContractTask): meta_task = _to_meta_gather_task(tc, task_type, input_types, output_types, schema_option_d) elif isinstance(tc.task, ToolContractTask): meta_task = _to_meta_task(tc, task_type, input_types, output_types, schema_option_d, output_file_names) else: raise TypeError("Unsupported Type {t} {x}".format(x=tc.task, t=type(tc.task))) return meta_task