def check_inputs(mic_config_arg): _inputs = get_inputs(Path(mic_config_arg)) assert _inputs == { 'txtinout_zip': { 'format': 'zip', 'path': 'TxtInOut.zip' } }
def wrapper(mic_file): """ Generates the MIC Wrapper:a directory structure and commands required to run your model component using the information gathered from previous steps - You must pass the MIC_FILE (mic.yaml) as an argument using the (-f) option or run the command from the same directory as mic.yaml mic pkg wrapper -f <mic_file> Example: mic pkg wrapper -f mic/mic.yaml """ # Searches for mic file if user does not provide one mic_file = check_mic_path(mic_file) log_command(logging, "wrapper", mic_file=mic_file) try: info_start_wrapper() mic_config_file = Path(mic_file) user_execution_directory = mic_config_file.parent.parent repro_zip_trace_dir = find_dir(REPRO_ZIP_TRACE_DIR, user_execution_directory) repro_zip_trace_dir = Path(repro_zip_trace_dir) repro_zip_config_file = repro_zip_trace_dir / REPRO_ZIP_CONFIG_FILE mic_directory_path = mic_config_file.parent mic_inputs = get_inputs(mic_config_file) mic_parameters = get_parameters(mic_config_file) mic_outputs = get_outputs_mic(mic_config_file) mic_configs = get_configs(mic_config_file) mic_code = get_code(mic_config_file) spec = get_spec(mic_config_file) reprozip_spec = get_spec(repro_zip_config_file) logging.info("Generating wrapper code") code = f"""{generate_pre_runner(spec, user_execution_directory)} {generate_runner(reprozip_spec, user_execution_directory, mic_inputs, mic_outputs, mic_parameters)}""" render_bash_color(mic_directory_path) render_run_sh(mic_directory_path, mic_inputs, mic_parameters, mic_outputs, code) render_io_sh(mic_directory_path, mic_inputs, mic_parameters, mic_configs) render_output(mic_directory_path, mic_outputs, False) copy_code_to_src(mic_code, user_execution_directory, mic_directory_path / SRC_DIR) copy_config_to_src(mic_configs, user_execution_directory, mic_directory_path / SRC_DIR) info_end_wrapper(mic_directory_path / SRC_DIR / RUN_FILE) logging.info("wrapper done") except Exception as e: logging.exception(f"Wrapper failed: {e}") click.secho("Failed", fg="red") click.secho(e)
def test_wrapper_code(): mic_yaml = Path("254/mic/mic3.yaml") repro_yaml = Path("254/.reprozip-trace2/config.yml") repro_spec = get_spec(Path(__file__).parent / RESOURCES / repro_yaml) inp = get_inputs(Path(__file__).parent / RESOURCES / mic_yaml) outp = get_outputs_mic(Path(__file__).parent / RESOURCES / mic_yaml) params = get_parameters(Path(__file__).parent / RESOURCES / mic_yaml) code = generate_runner(repro_spec, DEFAULT_PATH, inp, outp, params) assert code == "\npushd .\n/bin/sh ./addtoarray.sh ${a_txt} ${in_txt} ${param_1} \"${param_2}\" ${param_3} " \ "${param_4} \"${param_5}\" \"${param_6}\"\npopd"
def create_execution_directory(mic_config_file: Path, execution_name): model_path = mic_config_file.parent execution_dir = model_path / EXECUTIONS_DIR / execution_name execution_dir.mkdir(parents=True) click.secho("Create a execution directory {}".format(execution_dir)) src_executions_dir = execution_dir / SRC_DIR _copy_directory(model_path / SRC_DIR, src_executions_dir) click.secho(f"""Copying the inputs Source: {model_path / DATA_DIR} Destination: {src_executions_dir}""") spec = get_inputs(mic_config_file) for key, value in spec.items(): file = model_path / DATA_DIR / str(Path(value[PATH_KEY]).name) copy_file(file, src_executions_dir) return src_executions_dir
def check_inputs(mic_config_arg): _inputs = get_inputs(Path(mic_config_arg)) assert _inputs == {'c_txt': {'format': 'txt', 'path': 'c.txt'}}
def check_inputs(mic_config_arg): _inputs = get_inputs(Path(mic_config_arg)) print("INPUTS: --->",_inputs) assert _inputs == {'sample_input_txt': {'path': 'sample_input.txt', 'format': 'txt'}}