From 603acdf4cc6edaa83678c2625829c87a64fd7878 Mon Sep 17 00:00:00 2001 From: anandhu-eng Date: Thu, 24 Apr 2025 17:47:27 +0530 Subject: [PATCH 1/4] replace print with logger --- .../customize.py | 2 +- .../app-image-corner-detection/customize.py | 3 +- .../app-loadgen-generic-python/customize.py | 8 ++- .../app-mlperf-inference-dummy/customize.py | 6 +- .../app-mlperf-inference-intel/customize.py | 6 +- .../customize.py | 8 ++- .../customize.py | 12 ++-- .../customize.py | 6 +- .../app-mlperf-inference-redhat/customize.py | 6 +- script/app-mlperf-inference/customize.py | 28 ++++---- .../customize.py | 4 +- script/benchmark-program/customize.py | 16 ++--- script/build-docker-image/customize.py | 11 ++-- script/build-dockerfile/customize.py | 5 +- script/calibrate-model-for.qaic/customize.py | 9 +-- .../customize.py | 2 +- script/compile-model-for.qaic/customize.py | 6 +- script/compile-program/customize.py | 4 +- script/create-custom-cache-entry/customize.py | 4 +- script/create-patch/customize.py | 12 ++-- script/detect-cpu/customize.py | 10 +-- script/detect-sudo/customize.py | 38 +++++------ script/download-file/customize.py | 14 ++-- script/extract-file/customize.py | 10 +-- .../customize.py | 31 ++++----- .../customize.py | 23 +++---- .../generate-mlperf-tiny-report/customize.py | 6 +- .../customize.py | 17 ++--- script/get-android-sdk/customize.py | 12 ++-- script/get-aocc/customize.py | 4 +- script/get-aria2/customize.py | 7 +- script/get-aws-cli/customize.py | 3 +- script/get-bazel/customize.py | 4 +- script/get-cl/customize.py | 4 +- script/get-cmake/customize.py | 4 +- script/get-conda/customize.py | 8 ++- script/get-cuda/customize.py | 14 ++-- script/get-cudnn/customize.py | 6 +- script/get-dataset-coco/customize.py | 21 +++--- script/get-dataset-coco2014/customize.py | 1 + .../customize.py | 54 ++++++++-------- script/get-dataset-openimages/customize.py | 6 +- .../customize.py | 20 +++--- script/get-docker/customize.py | 4 +- script/get-gcc/customize.py | 3 +- script/get-generic-python-lib/customize.py | 1 + script/get-generic-sys-util/customize.py | 21 +++--- script/get-gh-actions-runner/customize.py | 4 +- script/get-github-cli/customize.py | 7 +- script/get-go/customize.py | 3 +- script/get-huggingface-cli/customize.py | 4 +- script/get-ipol-src/customize.py | 10 +-- script/get-java/customize.py | 9 +-- script/get-javac/customize.py | 9 +-- script/get-llvm/customize.py | 5 +- .../customize.py | 4 +- script/get-ml-model-gptj/customize.py | 3 +- script/get-ml-model-mobilenet/customize.py | 3 +- .../customize.py | 7 -- script/get-ml-model-rnnt/customize.py | 4 +- .../customize.py | 6 +- .../customize.py | 14 ++-- script/get-onnxruntime-prebuilt/customize.py | 8 ++- script/get-openssl/customize.py | 3 +- script/get-python3/customize.py | 3 +- script/get-qaic-apps-sdk/customize.py | 5 +- script/get-qaic-platform-sdk/customize.py | 4 +- script/get-rclone/customize.py | 8 ++- script/get-rocm/customize.py | 3 +- script/get-sys-utils-cm/customize.py | 18 +++--- script/get-sys-utils-min/customize.py | 18 +++--- script/get-tensorrt/customize.py | 4 +- script/get-terraform/customize.py | 4 +- script/get-tvm-model/customize.py | 4 +- script/install-bazel/customize.py | 4 +- script/install-cmake-prebuilt/customize.py | 14 ++-- .../install-diffusers-from-src/customize.py | 2 - script/install-gcc-src/customize.py | 4 +- .../customize.py | 4 +- script/install-gflags/customize.py | 8 +-- script/install-llvm-prebuilt/customize.py | 22 ++++--- script/install-openssl/customize.py | 24 +------ script/install-python-src/customize.py | 4 +- script/install-python-venv/customize.py | 4 +- .../install-rapidjson-from-src/customize.py | 2 - .../install-torchvision-from-src/customize.py | 2 - .../plug-prebuilt-cudnn-to-cuda/customize.py | 6 +- .../customize.py | 6 +- .../customize.py | 8 ++- script/process-mlperf-accuracy/customize.py | 16 +++-- script/prune-bert-models/customize.py | 14 ++-- script/push-csv-to-spreadsheet/customize.py | 2 - .../customize.py | 2 - script/run-all-mlperf-models/customize.py | 6 +- script/run-docker-container/customize.py | 64 ++++++++++--------- script/run-mlperf-automotive-app/customize.py | 19 +++--- script/run-mlperf-inference-app/customize.py | 20 +++--- .../customize.py | 7 +- .../customize.py | 3 +- script/run-mlperf-power-client/customize.py | 2 - script/run-mlperf-power-server/customize.py | 6 +- script/run-terraform/customize.py | 7 +- script/run-vllm-server/customize.py | 9 ++- script/runtime-system-infos/customize.py | 7 +- script/set-venv/customize.py | 16 +++-- script/submit-mlperf-results/customize.py | 28 ++++---- script/tar-my-folder/customize.py | 5 +- .../customize.py | 3 +- .../customize.py | 2 - 109 files changed, 564 insertions(+), 466 deletions(-) diff --git a/script/app-image-classification-onnx-py/customize.py b/script/app-image-classification-onnx-py/customize.py index c3c31b17a..39ae86bba 100644 --- a/script/app-image-classification-onnx-py/customize.py +++ b/script/app-image-classification-onnx-py/customize.py @@ -19,7 +19,6 @@ def postprocess(i): os_info = i['os_info'] env = i['env'] state = i['state'] - automation = i['automation'] logger = automation.action_object.logger @@ -48,6 +47,7 @@ def postprocess(i): json.dump(data, f, ensure_ascii=False, indent=4) except Exception as e: logger.warning('CM warning: {}'.format(e)) + logger.warning('CM warning: {}'.format(e)) try: import yaml diff --git a/script/app-image-corner-detection/customize.py b/script/app-image-corner-detection/customize.py index 7b37eb663..8efad95b8 100644 --- a/script/app-image-corner-detection/customize.py +++ b/script/app-image-corner-detection/customize.py @@ -38,6 +38,7 @@ def preprocess(i): def postprocess(i): env = i['env'] - print(env['MLC_OUTPUT'] + " generated in " + env['MLC_RUN_DIR']) + logger = i['automation'].logger + logger.info(env['MLC_OUTPUT'] + " generated in " + env['MLC_RUN_DIR']) return {'return': 0} diff --git a/script/app-loadgen-generic-python/customize.py b/script/app-loadgen-generic-python/customize.py index 9a4a6104e..639ed9c5c 100644 --- a/script/app-loadgen-generic-python/customize.py +++ b/script/app-loadgen-generic-python/customize.py @@ -11,6 +11,8 @@ def preprocess(i): env = i['env'] + logger = i['automation'].logger + if 'MLC_ML_MODEL_FILE_WITH_PATH' not in env: return { 'return': 1, 'error': 'Please select a variation specifying the model to run'} @@ -87,9 +89,9 @@ def preprocess(i): env['MLC_RUN_OPTS'] = run_opts - print('') - print('Assembled flags: {}'.format(run_opts)) - print('') + logger.info('') + logger.info('Assembled flags: {}'.format(run_opts)) + logger.info('') return {'return': 0} diff --git a/script/app-mlperf-inference-dummy/customize.py b/script/app-mlperf-inference-dummy/customize.py index f200e915b..93d24a7b1 100644 --- a/script/app-mlperf-inference-dummy/customize.py +++ b/script/app-mlperf-inference-dummy/customize.py @@ -11,6 +11,8 @@ def preprocess(i): return {'return': 1, 'error': 'Windows is not supported in this script yet'} env = i['env'] + logger = i['automation'].logger + if env.get('MLC_MLPERF_SKIP_RUN', '') == "yes": return {'return': 0} @@ -29,8 +31,8 @@ def preprocess(i): return r run_cmd = r['run_cmd'] run_dir = r['run_dir'] - print(run_cmd) - print(run_dir) + logger.info(run_cmd) + logger.info(run_dir) return {'return': 1, 'error': 'Run command needs to be tested!'} diff --git a/script/app-mlperf-inference-intel/customize.py b/script/app-mlperf-inference-intel/customize.py index 932817163..d6276e5ab 100644 --- a/script/app-mlperf-inference-intel/customize.py +++ b/script/app-mlperf-inference-intel/customize.py @@ -11,6 +11,8 @@ def preprocess(i): return {'return': 1, 'error': 'Windows is not supported in this script yet'} env = i['env'] + logger = i['automation'].logger + if env.get('MLC_MLPERF_SKIP_RUN', '') == "yes": return {'return': 0} @@ -104,7 +106,7 @@ def preprocess(i): os.path.dirname(env['MLC_ML_MODEL_FILE_WITH_PATH']), 'retinanet-int8-model.pth') elif env['MLC_LOCAL_MLPERF_INFERENCE_INTEL_RUN_MODE'] == "build_harness": - print(f"Harness Root: {harness_root}") + logger.info(f"Harness Root: {harness_root}") if "bert" in env['MLC_MODEL']: i['run_script_input']['script_name'] = "build_bert_harness" env['MLC_MLPERF_INFERENCE_INTEL_HARNESS_PATH'] = os.path.join( @@ -162,7 +164,7 @@ def preprocess(i): env[model_dir_name]) elif env['MLC_LOCAL_MLPERF_INFERENCE_INTEL_RUN_MODE'] == "run_harness": - print(f"Harness Root: {harness_root}") + logger.info(f"Harness Root: {harness_root}") if env.get('MLC_MLPERF_LOADGEN_MODE', '') == "compliance": audit_path = env['MLC_MLPERF_INFERENCE_AUDIT_PATH'] shutil.copy(audit_path, env['MLC_RUN_DIR']) diff --git a/script/app-mlperf-inference-mlcommons-cpp/customize.py b/script/app-mlperf-inference-mlcommons-cpp/customize.py index fa9db9d76..6ca58e3bc 100644 --- a/script/app-mlperf-inference-mlcommons-cpp/customize.py +++ b/script/app-mlperf-inference-mlcommons-cpp/customize.py @@ -11,10 +11,12 @@ def preprocess(i): meta = i['meta'] + logger = i['automation'].logger + if os_info['platform'] == 'windows': - print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') - print('WARNING: this script was not thoroughly tested on Windows and compilation may fail - please help us test and improve it!') - print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') + logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') + logger.warning('This script was not thoroughly tested on Windows and compilation may fail - please help us test and improve it!') + logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') # # Currently support only LLVM on Windows # print ('# Forcing LLVM on Windows') # r = automation.update_deps({'deps':meta['post_deps'], 'update_deps':{'compile-program': {'adr':{'compiler':{'tags':'llvm'}}}}}) diff --git a/script/app-mlperf-inference-mlcommons-python/customize.py b/script/app-mlperf-inference-mlcommons-python/customize.py index d0eef3b51..8d732b413 100644 --- a/script/app-mlperf-inference-mlcommons-python/customize.py +++ b/script/app-mlperf-inference-mlcommons-python/customize.py @@ -13,6 +13,8 @@ def preprocess(i): state = i['state'] script_path = i['run_script_input']['path'] + logger = i['automation'].logger + if env.get('MLC_MLPERF_SKIP_RUN', '') == "yes": return {'return': 0} @@ -179,7 +181,7 @@ def preprocess(i): mlperf_implementation = env.get('MLC_MLPERF_IMPLEMENTATION', 'reference') cmd, run_dir = get_run_cmd(os_info, env, scenario_extra_options, - mode_extra_options, dataset_options, mlperf_implementation) + mode_extra_options, dataset_options, logger, mlperf_implementation) if env.get('MLC_NETWORK_LOADGEN', '') == "lon": @@ -202,10 +204,10 @@ def preprocess(i): def get_run_cmd(os_info, env, scenario_extra_options, - mode_extra_options, dataset_options, implementation="reference"): + mode_extra_options, dataset_options, logger, implementation="reference"): if implementation == "reference": return get_run_cmd_reference( - os_info, env, scenario_extra_options, mode_extra_options, dataset_options) + os_info, env, scenario_extra_options, mode_extra_options, dataset_options, logger) if implementation == "nvidia": return get_run_cmd_nvidia( os_info, env, scenario_extra_options, mode_extra_options, dataset_options) @@ -213,7 +215,7 @@ def get_run_cmd(os_info, env, scenario_extra_options, def get_run_cmd_reference( - os_info, env, scenario_extra_options, mode_extra_options, dataset_options): + os_info, env, scenario_extra_options, mode_extra_options, dataset_options, logger): device = env['MLC_MLPERF_DEVICE'] if env['MLC_MLPERF_DEVICE'] not in [ "gpu", "rocm"] else "cuda" @@ -533,7 +535,7 @@ def get_run_cmd_reference( if env.get('MLC_MLPERF_POINTPAINTING_TIME', '') != '': cmd += f" --time {env['MLC_MLPERF_POINTPAINTING_TIME']}" - print(cmd) + logger.info(fcmd) if env.get('MLC_NETWORK_LOADGEN', '') in ["lon", "sut"]: cmd = cmd + " " + "--network " + env['MLC_NETWORK_LOADGEN'] diff --git a/script/app-mlperf-inference-qualcomm/customize.py b/script/app-mlperf-inference-qualcomm/customize.py index 2ba7db912..095bfe2dd 100644 --- a/script/app-mlperf-inference-qualcomm/customize.py +++ b/script/app-mlperf-inference-qualcomm/customize.py @@ -8,6 +8,8 @@ def preprocess(i): os_info = i['os_info'] + logger = i['automation'].logger + if os_info['platform'] == 'windows': return {'return': 1, 'error': 'Windows is not supported in this script yet'} env = i['env'] @@ -27,7 +29,7 @@ def preprocess(i): kilt_root = env['MLC_KILT_CHECKOUT_PATH'] - print(f"Harness Root: {kilt_root}") + logger.info(f"Harness Root: {kilt_root}") source_files = [] env['MLC_SOURCE_FOLDER_PATH'] = env['MLC_KILT_CHECKOUT_PATH'] @@ -161,7 +163,7 @@ def preprocess(i): "master", "QAicInfApi.cpp")) - print(f"Compiling the source files: {source_files}") + logger.info(f"Compiling the source files: {source_files}") env['MLC_CXX_SOURCE_FILES'] = ";".join(source_files) env['+ CXXFLAGS'].append("-std=c++17") diff --git a/script/app-mlperf-inference-redhat/customize.py b/script/app-mlperf-inference-redhat/customize.py index 25ff631d1..67b7b04e4 100644 --- a/script/app-mlperf-inference-redhat/customize.py +++ b/script/app-mlperf-inference-redhat/customize.py @@ -12,6 +12,8 @@ def preprocess(i): return {'return': 1, 'error': 'Windows is not supported in this script yet'} env = i['env'] + logger = i['automation'].logger + if is_true(env.get('MLC_MLPERF_SKIP_RUN', '')): return {'return': 0} @@ -30,8 +32,8 @@ def preprocess(i): return r run_cmd = r['run_cmd'] run_dir = r['run_dir'] - print(run_cmd) - print(run_dir) + logger.info(run_cmd) + logger.info(run_dir) env['MLC_MLPERF_RUN_CMD'] = run_cmd env['MLC_RUN_DIR'] = run_dir env['MLC_RUN_CMD'] = run_cmd diff --git a/script/app-mlperf-inference/customize.py b/script/app-mlperf-inference/customize.py index e67e35cf1..3a2c0cf57 100644 --- a/script/app-mlperf-inference/customize.py +++ b/script/app-mlperf-inference/customize.py @@ -63,6 +63,8 @@ def postprocess(i): state = i['state'] mlc = i['automation'].action_object + logger = i['automation'].logger + # if env.get('MLC_MLPERF_USER_CONF', '') == '': # return {'return': 0} @@ -218,7 +220,7 @@ def postprocess(i): pattern["Offline"] = "Samples per second: (.*)\n" pattern["SingleStream"] = "Mean latency \\(ns\\)\\s*:(.*)" pattern["MultiStream"] = "Mean latency \\(ns\\)\\s*:(.*)" - print("\n") + logger.info("\n") with open("mlperf_log_summary.txt", "r") as fp: summary = fp.read() @@ -241,7 +243,7 @@ def postprocess(i): print( f"SUT: {sut_name}, model: {model_full_name}, scenario: {scenario}, {metric} (mean value) updated as {value}") - print(f"New config stored in {sut_config_path}") + logger.info(f"New config stored in {sut_config_path}") with open(sut_config_path, "w") as f: yaml.dump(sut_config, f) @@ -288,8 +290,8 @@ def postprocess(i): ] = y[1].strip() if not is_false(env.get("MLC_MLPERF_PRINT_SUMMARY", "")): - print("\n") - print(mlperf_log_summary) + logger.info("\n") + logger.info(mlperf_log_summary) with open("measurements.json", "w") as fp: json.dump(measurements, fp, indent=2) @@ -503,7 +505,7 @@ def postprocess(i): else: cmd = f"""{env['MLC_PYTHON_BIN_WITH_PATH']} {q}{SCRIPT_PATH}{q} -r {q}{RESULT_DIR}{q} -c {q}{COMPLIANCE_DIR}{q} -o {q}{OUTPUT_DIR}{q}""" - print(cmd) + logger.info(cmd) os.system(cmd) if test == "TEST01": @@ -520,13 +522,13 @@ def postprocess(i): ACCURACY_DIR = os.path.join(RESULT_DIR, "accuracy") if not os.path.exists(ACCURACY_DIR): - print("Accuracy run not yet completed") + logger.warning("Accuracy run not yet completed") return { 'return': 1, 'error': 'TEST01 needs accuracy run to be completed first'} cmd = f"""cd {q}{TEST01_DIR}{q} && bash {q}{SCRIPT_PATH}{q} {q}{os.path.join(ACCURACY_DIR, "mlperf_log_accuracy.json")}{q} {q}{os.path.join(COMPLIANCE_DIR, "mlperf_log_accuracy.json")}{q} """ env['CMD'] = cmd - print(cmd) + logger.info(cmd) r = automation.run_native_script( {'run_script_input': run_script_input, 'env': env, 'script_name': 'verify_accuracy'}) if r['return'] > 0: @@ -538,7 +540,7 @@ def postprocess(i): data = file.read().replace('\n', '\t') if 'TEST PASS' not in data: - print("\nDeterministic TEST01 failed... Trying with non-determinism.\n") + logger.warning("\nDeterministic TEST01 failed... Trying with non-determinism.\n") # #Normal test failed, trying the check with non-determinism baseline_accuracy_file = os.path.join( @@ -603,8 +605,8 @@ def postprocess(i): sys_utilisation_log['timestamp']) ''' for i in range(len(sys_utilisation_log['timestamp'])): - print(f"{sys_utilisation_log['timestamp'][i]} {power_begin_time}") - print(sys_utilisation_log['timestamp'][i]>=power_begin_time) + logger.info(f"{sys_utilisation_log['timestamp'][i]} {power_begin_time}") + logger.info(sys_utilisation_log['timestamp'][i]>=power_begin_time) ''' # print(f"{sys_utilisation_log['timestamp'][0]} {power_begin_time}") # print(sys_utilisation_log['timestamp'][0]>=power_begin_time) @@ -616,9 +618,9 @@ def postprocess(i): ) system_utilisation_info_dump["avg_used_memory_gb"] = filtered_log['used_memory_gb'].mean( ) - print("\nSystem utilisation info for the current run:") - print(system_utilisation_info_dump) - print("\n") + logger.info("\nSystem utilisation info for the current run:") + logger.info(system_utilisation_info_dump) + logger.info("\n") if state.get( 'mlperf-inference-implementation') and state['mlperf-inference-implementation'].get('version_info'): diff --git a/script/benchmark-any-mlperf-inference-implementation/customize.py b/script/benchmark-any-mlperf-inference-implementation/customize.py index 00ce47ea5..7f8bb1564 100644 --- a/script/benchmark-any-mlperf-inference-implementation/customize.py +++ b/script/benchmark-any-mlperf-inference-implementation/customize.py @@ -14,6 +14,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) models = env['MODELS'].split(",") @@ -165,7 +167,7 @@ def preprocess(i): with open(os.path.join(script_path, run_file_name + ".sh"), 'w') as f: f.write(run_script_content) - print(run_script_content) + logger.info(run_script_content) run_script_input = i['run_script_input'] r = automation.run_native_script( diff --git a/script/benchmark-program/customize.py b/script/benchmark-program/customize.py index de0fac475..d0ce03b1d 100644 --- a/script/benchmark-program/customize.py +++ b/script/benchmark-program/customize.py @@ -6,7 +6,7 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] - + logger = i['automation'].logger q = '"' if os_info['platform'] == 'windows' else "'" if env.get('MLC_RUN_CMD', '') == '': @@ -104,15 +104,15 @@ def preprocess(i): env['MLC_POST_RUN_CMD'] = post_run_cmd # Print info - print('***************************************************************************') - print('CM script::benchmark-program/run.sh') - print('') - print('Run Directory: {}'.format(env.get('MLC_RUN_DIR', ''))) + logger.info('***************************************************************************') + logger.info('CM script::benchmark-program/run.sh') + logger.info('') + logger.info('Run Directory: {}'.format(env.get('MLC_RUN_DIR', ''))) - print('') - print('CMD: {}'.format(env.get('MLC_RUN_CMD', ''))) + logger.info('') + logger.info('CMD: {}'.format(env.get('MLC_RUN_CMD', ''))) - print('') + logger.info('') return {'return': 0} diff --git a/script/build-docker-image/customize.py b/script/build-docker-image/customize.py index acf660261..4b2f35022 100644 --- a/script/build-docker-image/customize.py +++ b/script/build-docker-image/customize.py @@ -8,7 +8,7 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] - + logger = i['automation'].logger dockerfile_path = env.get('MLC_DOCKERFILE_WITH_PATH', '') if dockerfile_path != '' and os.path.exists(dockerfile_path): build_dockerfile = False @@ -83,7 +83,7 @@ def preprocess(i): CMD = ''.join(XCMD) - print(CMD) + logger.info(CMD) env['MLC_DOCKER_BUILD_CMD'] = CMD @@ -102,6 +102,7 @@ def get_image_name(env): def postprocess(i): env = i['env'] + logger = i['automation'].logger # Check if need to push docker image to the Docker Hub if is_true(env.get('MLC_DOCKER_PUSH_IMAGE', '')): @@ -118,12 +119,12 @@ def postprocess(i): with open(dockerfile_path + '.build.bat', 'w') as f: f.write(PCMD + '\n') - print(PCMD) + logger.info(PCMD) - print('') + logger.info('') r = os.system(PCMD) - print('') + logger.info('') if r > 0: return {'return': 1, 'error': 'pushing to Docker Hub failed'} diff --git a/script/build-dockerfile/customize.py b/script/build-dockerfile/customize.py index 8a01ef753..a3d32b247 100644 --- a/script/build-dockerfile/customize.py +++ b/script/build-dockerfile/customize.py @@ -11,6 +11,7 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger if env["MLC_DOCKER_OS"] not in ["ubuntu", "rhel", "arch"]: return { @@ -379,7 +380,7 @@ def preprocess(i): env['MLC_DOCKER_RUN_CMD'] = "mlc pull repo && " + \ env['MLC_DOCKER_RUN_CMD'] - print(env['MLC_DOCKER_RUN_CMD']) + logger.info(env['MLC_DOCKER_RUN_CMD']) fake_run = env.get("MLC_DOCKER_FAKE_RUN_OPTION", " --fake_run") + dockerfile_env_input_string fake_run = fake_run + \ @@ -441,7 +442,7 @@ def preprocess(i): s = r['string'] f.write(s + EOL) - print(f"""Dockerfile written at {dockerfile_with_path}""") + logger.info(f"""Dockerfile written at {dockerfile_with_path}""") f.close() diff --git a/script/calibrate-model-for.qaic/customize.py b/script/calibrate-model-for.qaic/customize.py index 706ad1767..42f1c64ca 100644 --- a/script/calibrate-model-for.qaic/customize.py +++ b/script/calibrate-model-for.qaic/customize.py @@ -15,6 +15,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) if is_true(env.get('MLC_CREATE_INPUT_BATCH', '')): @@ -27,7 +29,7 @@ def preprocess(i): return r cmd = r['cmd'] - print("Profiling from " + os.getcwd()) + logger.info("Profiling from " + os.getcwd()) env['MLC_RUN_CMD'] = cmd @@ -214,8 +216,3 @@ def postprocess(i): return {'return': 0} -def get_scale_offset(min_val, max_val): - total_range = max_val - min_val - scale = total_range /256.0 - offset = round(-min_val / scale) - return scale, offset diff --git a/script/clean-nvidia-mlperf-inference-scratch-space/customize.py b/script/clean-nvidia-mlperf-inference-scratch-space/customize.py index d1ea84490..948171d40 100644 --- a/script/clean-nvidia-mlperf-inference-scratch-space/customize.py +++ b/script/clean-nvidia-mlperf-inference-scratch-space/customize.py @@ -37,7 +37,7 @@ def preprocess(i): if cache_rm_tags: r = mlc_cache.access({'action': 'rm', 'target': 'cache', 'tags': cache_rm_tags, 'f': True}) - print(r) + logger.info(r) # Check if return code is 0 (success) # currently, the warning code is not being checked as the possibility # arises only for missing cache entry diff --git a/script/compile-model-for.qaic/customize.py b/script/compile-model-for.qaic/customize.py index ca2c48d75..ccbe4143b 100644 --- a/script/compile-model-for.qaic/customize.py +++ b/script/compile-model-for.qaic/customize.py @@ -13,6 +13,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) if env.get('MLC_REGISTER_CACHE', '') == '': @@ -22,7 +24,7 @@ def preprocess(i): return r cmd = r['cmd'] - print("Compiling from " + os.getcwd()) + logger.info("Compiling from " + os.getcwd()) env['MLC_QAIC_MODEL_FINAL_COMPILATION_CMD'] = cmd @@ -39,7 +41,7 @@ def preprocess(i): os.path.join( os.getcwd(), "elfs")) - print(r) + logger.info(r) return {'return': 0} diff --git a/script/compile-program/customize.py b/script/compile-program/customize.py index 8a4a7a669..b0cad6347 100644 --- a/script/compile-program/customize.py +++ b/script/compile-program/customize.py @@ -6,7 +6,7 @@ def preprocess(i): os_info = i['os_info'] q = '"' if os_info['platform'] == 'windows' else "'" - + logger = i['automation'].logger env = i['env'] CPPFLAGS = env.get('+ CPPFLAGS', []) env['MLC_C_COMPILER_FLAGS'] = " ".join(env.get('+ CFLAGS', []) + CPPFLAGS) @@ -30,7 +30,7 @@ def preprocess(i): # If windows, need to extend it more ... if os_info['platform'] == 'windows' and env.get( 'MLC_COMPILER_FAMILY', '') != 'LLVM': - print("WARNING: compile-program script should be extended to support flags for non-LLVM compilers on Windows") + logger.warning("Compile-program script should be extended to support flags for non-LLVM compilers on Windows") return {'return': 0} LDFLAGS = env.get('+ LDFLAGS', []) diff --git a/script/create-custom-cache-entry/customize.py b/script/create-custom-cache-entry/customize.py index a0299f50d..795235bfd 100644 --- a/script/create-custom-cache-entry/customize.py +++ b/script/create-custom-cache-entry/customize.py @@ -7,10 +7,10 @@ def preprocess(i): # CM script internal variables env = i['env'] - + logger = i['automation'].logger extra_cache_tags = [] if env.get('MLC_EXTRA_CACHE_TAGS', '').strip() == '': - print('') + logger.info('') extra_cache_tags_str = input( 'Enter extra tags for the custom CACHE entry separated by comma: ') diff --git a/script/create-patch/customize.py b/script/create-patch/customize.py index a14969634..5b6e83180 100644 --- a/script/create-patch/customize.py +++ b/script/create-patch/customize.py @@ -13,6 +13,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) new_dir = env.get('MLC_CREATE_PATCH_NEW', '') @@ -40,11 +42,11 @@ def preprocess(i): x_exclude, old_dir, new_dir) if not quiet: - print('') - print('Running command:') - print('') - print(cmd) - print('') + logger.info('') + logger.info('Running command:') + logger.info('') + logger.info(cmd) + logger.info('') os.system(cmd) diff --git a/script/detect-cpu/customize.py b/script/detect-cpu/customize.py index bac6e3dc1..b6d1d73fc 100644 --- a/script/detect-cpu/customize.py +++ b/script/detect-cpu/customize.py @@ -35,7 +35,7 @@ def postprocess(i): f = 'tmp-systeminfo.csv' if not os.path.isfile(f): - print('WARNING: {} file was not generated!'.format(f)) + logger.warning('{} file was not generated!'.format(f)) else: keys = {} j = 0 @@ -57,14 +57,14 @@ def postprocess(i): except Exception as e: logger.warning( - 'WARNING: problem processing file {} ({})!'.format( + 'Problem processing file {} ({})!'.format( f, format(e))) pass try: f = 'tmp-wmic-cpu.csv' if not os.path.isfile(f): - logger.warning('WARNING: {} file was not generated!'.format(f)) + logger.warning('{} file was not generated!'.format(f)) else: keys = {} @@ -88,7 +88,7 @@ def postprocess(i): except Exception as e: logger.warning( - 'WARNING: problem processing file {} ({})!'.format( + 'Problem processing file {} ({})!'.format( f, format(e))) pass @@ -103,7 +103,7 @@ def postprocess(i): ########################################################################## # Linux if not os.path.isfile(lscpu_out): - print('WARNING: lscpu.out file was not generated!') + logger.warning('lscpu.out file was not generated!') # Currently ignore this error though probably should fail? # But need to check that is supported on all platforms. diff --git a/script/detect-sudo/customize.py b/script/detect-sudo/customize.py index 47812286f..e2eae7a12 100644 --- a/script/detect-sudo/customize.py +++ b/script/detect-sudo/customize.py @@ -19,13 +19,15 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) if os.geteuid() == 0: env['MLC_SUDO'] = '' # root user does not need sudo env['MLC_SUDO_USER'] = "yes" else: - if can_execute_sudo_without_password() or prompt_sudo() == 0: + if can_execute_sudo_without_password(logger) or prompt_sudo(logger) == 0: env['MLC_SUDO_USER'] = "yes" env['MLC_SUDO'] = 'sudo' @@ -36,7 +38,7 @@ def preprocess(i): return {'return': 0} -def can_execute_sudo_without_password(): +def can_execute_sudo_without_password(logger): try: # Run a harmless command using sudo result = subprocess.run( @@ -53,7 +55,7 @@ def can_execute_sudo_without_password(): else: return False except Exception as e: - print(f"An error occurred: {e}") + logger.error(f"An error occurred: {e}") return False @@ -62,15 +64,15 @@ def reset_terminal(): subprocess.run(['stty', 'sane']) -def prompt_retry(timeout=10, default_retry=False): +def prompt_retry(logger, timeout=10, default_retry=False): """Prompt the user with a yes/no question to retry the command, with a 10-second timeout.""" # Check if we're in an interactive terminal if not sys.stdin.isatty(): if default_retry: - print(f"Non-interactive environment detected. Automatically retrying.") + logger.info(f"Non-interactive environment detected. Automatically retrying.") else: - print(f"Non-interactive environment detected. Skipping retry.") + logger.warning(f"Non-interactive environment detected. Skipping retry.") return default_retry # Automatically use the default in non-interactive terminals print( @@ -85,14 +87,14 @@ def prompt_retry(timeout=10, default_retry=False): answer = sys.stdin.readline().strip().lower() if answer in ['y', 'n']: return answer == 'y' # Return True if 'y', False if 'n' - print("\nInvalid input. Please enter 'y' or 'n'.") - return prompt_retry(timeout) # Re-prompt on invalid input + logger.error("\nInvalid input. Please enter 'y' or 'n'.") + return prompt_retry(logger, timeout) # Re-prompt on invalid input else: - print("\nNo input received in 10 seconds. Exiting.") + logger.info("\nNo input received in 10 seconds. Exiting.") return False # No input within the timeout, so don't retry -def is_user_in_sudo_group(): +def is_user_in_sudo_group(logger): """Check if the current user is in the 'sudo' group.""" try: sudo_group = grp.getgrnam('sudo').gr_mem @@ -101,7 +103,7 @@ def is_user_in_sudo_group(): # 'sudo' group doesn't exist (might be different on some systems) return False except Exception as e: - print(f"Error checking sudo group: {str(e)}") + logger.error(f"Error checking sudo group: {str(e)}") return False @@ -123,13 +125,13 @@ def get_input(): return result[0] # Return user input or default -def prompt_sudo(): - if os.geteuid() != 0 and not is_user_in_sudo_group(): # No sudo required for root user +def prompt_sudo(logger): + if os.geteuid() != 0 and not is_user_in_sudo_group(logger): # No sudo required for root user # Prompt for the password if not os.isatty(sys.stdin.fileno()): - print("Skipping password prompt - non-interactive terminal detected!") + logger.warning("Skipping password prompt - non-interactive terminal detected!") password = None else: # password = getpass.getpass("Enter password (-1 to skip): ") @@ -140,7 +142,7 @@ def prompt_sudo(): # Check if the input is -1 if password == "-1": - print("Skipping sudo command.") + logger.warning("Skipping sudo command.") return -1 # Run the command with sudo, passing the password @@ -162,16 +164,16 @@ def prompt_sudo(): ) return 0 except subprocess.TimeoutExpired: - print("Timedout") + logger.info("Timedout") reset_terminal() # Reset terminal to sane state if not prompt_retry(): # If the user chooses not to retry or times out return -1 except subprocess.CalledProcessError as e: - print(f"Command failed: {e.output.decode('utf-8')}") + logger.error(f"Command failed: {e.output.decode('utf-8')}") reset_terminal() # Reset terminal in case of failure return -1 except Exception as e: - print(f"An error occurred: {str(e)}") + logger.error(f"An error occurred: {str(e)}") reset_terminal() # Always reset terminal after error return -1 diff --git a/script/download-file/customize.py b/script/download-file/customize.py index 40fc3c276..95eab3b09 100644 --- a/script/download-file/customize.py +++ b/script/download-file/customize.py @@ -33,6 +33,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) tool = env.get('MLC_DOWNLOAD_TOOL', '') @@ -64,8 +66,8 @@ def preprocess(i): env['MLC_DOWNLOAD_FILENAME'] = filepath if not quiet: - print('') - print('Using local file: {}'.format(filepath)) + logger.info('') + logger.info('Using local file: {}'.format(filepath)) else: url = env.get('MLC_DOWNLOAD_URL', '') @@ -73,8 +75,8 @@ def preprocess(i): return { 'return': 1, 'error': 'please specify URL using --url={URL} or --env.MLC_DOWNLOAD_URL={URL}'} - print('') - print('Downloading from {}'.format(url)) + logger.info('') + logger.info('Downloading from {}'.format(url)) if '&' in url and tool != "mlcutil": if os_info['platform'] == 'windows': @@ -179,7 +181,7 @@ def preprocess(i): url = env.get('MLC_DOWNLOAD_URL' + str(i), '') if url == '': break - print(f"Download from {oldurl} failed, trying from {url}") + logger.error(f"Download from {oldurl} failed, trying from {url}") if r['return'] > 0: return r @@ -198,7 +200,7 @@ def preprocess(i): if url == '': break env['MLC_DOWNLOAD_CMD'] += f" || (({del_cmd} {env['MLC_DOWNLOAD_FILENAME']} || true) && wget -nc {extra_download_options} {url})" - print(env['MLC_DOWNLOAD_CMD']) + logger.info(fenv['MLC_DOWNLOAD_CMD']) elif tool == "curl": if env.get('MLC_DOWNLOAD_FILENAME', '') != '': diff --git a/script/extract-file/customize.py b/script/extract-file/customize.py index f6f041dbc..c0e0957f3 100644 --- a/script/extract-file/customize.py +++ b/script/extract-file/customize.py @@ -22,6 +22,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) filename = env.get('MLC_EXTRACT_FILEPATH', '') @@ -133,10 +135,10 @@ def preprocess(i): env.get('MLC_EXTRACT_TOOL_EXTRA_OPTIONS', '') + \ ' ' + env.get('MLC_EXTRACT_TOOL_OPTIONS', '') + ' ' + x + filename + x - print('') - print('Current directory: {}'.format(os.getcwd())) - print('Command line: "{}"'.format(env['MLC_EXTRACT_CMD'])) - print('') + logger.info('') + logger.info('Current directory: {}'.format(os.getcwd())) + logger.info('Command line: "{}"'.format(env['MLC_EXTRACT_CMD'])) + logger.info('') final_file = env.get('MLC_EXTRACT_EXTRACTED_FILENAME', '') diff --git a/script/generate-mlperf-inference-submission/customize.py b/script/generate-mlperf-inference-submission/customize.py index 2803fd187..4cb8e03e3 100644 --- a/script/generate-mlperf-inference-submission/customize.py +++ b/script/generate-mlperf-inference-submission/customize.py @@ -56,7 +56,7 @@ def model_in_valid_models(model, mlperf_version): return (True, model) -def generate_submission(env, state, inp, submission_division): +def generate_submission(env, state, inp, submission_division, logger): # Save current user directory cur_dir = os.getcwd() @@ -84,13 +84,13 @@ def generate_submission(env, state, inp, submission_division): submission_dir = env.get('MLC_MLPERF_INFERENCE_SUBMISSION_DIR', '') if env.get('MLC_MLPERF_CLEAN_SUBMISSION_DIR', '') != '': - print('=================================================') + logger.info('=================================================') print( 'Cleaning {} ...'.format( env['MLC_MLPERF_INFERENCE_SUBMISSION_DIR'])) if os.path.exists(submission_dir): shutil.rmtree(submission_dir) - print('=================================================') + logger.info('=================================================') if not os.path.isdir(submission_dir): os.makedirs(submission_dir) @@ -98,8 +98,8 @@ def generate_submission(env, state, inp, submission_division): if is_true(str(env.get('MLC_MLPERF_SUBMISSION_DIR_SHARED', ''))): os.chmod(submission_dir, 0o2775) - print('* MLPerf inference submission dir: {}'.format(submission_dir)) - print('* MLPerf inference results dir: {}'.format(results_dir)) + logger.info('* MLPerf inference submission dir: {}'.format(submission_dir)) + logger.info('* MLPerf inference results dir: {}'.format(results_dir)) results = [ f for f in os.listdir(results_dir) if not os.path.isfile( os.path.join( @@ -137,7 +137,7 @@ def generate_submission(env, state, inp, submission_division): if division not in ['open', 'closed']: return {'return': 1, 'error': '"division" must be "open" or "closed"'} - print('* MLPerf inference division: {}'.format(division)) + logger.info('* MLPerf inference division: {}'.format(division)) path_submission_root = submission_dir path_submission_division = os.path.join(path_submission_root, division) @@ -152,7 +152,7 @@ def generate_submission(env, state, inp, submission_division): submitter = system_meta_default['submitter'] env['MLC_MLPERF_SUBMITTER'] = submitter - print('* MLPerf inference submitter: {}'.format(submitter)) + logger.info('* MLPerf inference submitter: {}'.format(submitter)) if env.get('MLC_MLPERF_SUT_SW_NOTES_EXTRA', '') != '': sw_notes = f"""{system_meta_tmp.get('sw_notes','')} {env['MLC_MLPERF_SUT_SW_NOTES_EXTRA']}""" @@ -281,7 +281,7 @@ def generate_submission(env, state, inp, submission_division): else: new_res = res.replace(" ", "_") - print(f"The SUT folder name for submission generation is: {new_res}") + logger.info(f"The SUT folder name for submission generation is: {new_res}") platform_prefix = inp.get('platform_prefix', '') if platform_prefix: @@ -338,7 +338,7 @@ def generate_submission(env, state, inp, submission_division): with open(os.path.join(submission_code_path, "README.md"), mode='w') as f: f.write("TBD") # create an empty README - print('* MLPerf inference model: {}'.format(model)) + logger.info('* MLPerf inference model: {}'.format(model)) for scenario in scenarios: # the system_info.txt is copied from the mode directory if # found, else it would be looked under scenario directory @@ -468,7 +468,7 @@ def generate_submission(env, state, inp, submission_division): saved_system_meta_file_path = os.path.join( result_mode_path, "system_meta.json") else: - print("WARNING: system_meta.json was not found in the SUT root or mode directory inside the results folder. CM is automatically creating one using the system defaults. Please modify them as required.") + logger.error("WARNING: system_meta.json was not found in the SUT root or mode directory inside the results folder. CM is automatically creating one using the system defaults. Please modify them as required.") if os.path.exists(saved_system_meta_file_path): with open(saved_system_meta_file_path, "r") as f: saved_system_meta = json.load(f) @@ -485,7 +485,7 @@ def generate_submission(env, state, inp, submission_division): # system_meta.json is not detected, default one will be # written system_meta = {**system_meta_default, **system_meta} - print(system_meta) + logger.info(system_meta) # check if framework version is there in system_meta, # if not try to fill it from sut_info if system_meta['framework'] == "": @@ -636,7 +636,7 @@ def generate_submission(env, state, inp, submission_division): submission_results_path, "images")) for f in files: - print(' * ' + f) + logger.info(' * ' + f) p_target = os.path.join(submission_results_path, f) shutil.copy( os.path.join( @@ -720,7 +720,7 @@ def generate_submission(env, state, inp, submission_division): result_table, headers = mlperf_utils.get_result_table(results) - print(tabulate(result_table, headers=headers, tablefmt="pretty")) + logger.info(tabulate(result_table, headers=headers, tablefmt="pretty")) sut_readme_file = os.path.join(measurement_path, "README.md") with open(sut_readme_file, mode='w') as f: @@ -733,6 +733,7 @@ def postprocess(i): env = i['env'] state = i['state'] inp = i['input'] + logger = i['automation'].logger submission_divisions = [] @@ -745,12 +746,12 @@ def postprocess(i): # if submission division is not assigned, default value would be taken in # submission_generation function if env.get('MLC_MLPERF_SUBMISSION_DIVISION', '') == '': - r = generate_submission(env, state, inp, submission_division="") + r = generate_submission(env, state, inp, submission_division="", logger=logger) if r['return'] > 0: return r else: for submission_division in submission_divisions: - r = generate_submission(env, state, inp, submission_division) + r = generate_submission(env, state, inp, submission_division, logger=logger) if r['return'] > 0: return r diff --git a/script/generate-mlperf-inference-user-conf/customize.py b/script/generate-mlperf-inference-user-conf/customize.py index bda488003..a4114ddb8 100644 --- a/script/generate-mlperf-inference-user-conf/customize.py +++ b/script/generate-mlperf-inference-user-conf/customize.py @@ -13,6 +13,7 @@ def preprocess(i): env = i['env'] state = i['state'] script_path = i['run_script_input']['path'] + logger = i['automation'].logger rerun = True if env.get("MLC_RERUN", "") != '' else False @@ -31,7 +32,7 @@ def preprocess(i): env['MLC_MLPERF_LOADGEN_SCENARIO'] = "Offline" if 'MLC_MLPERF_LOADGEN_MODE' not in env: - print("\nNo mode given. Using accuracy as default\n") + logger.info("\nNo mode given. Using accuracy as default\n") env['MLC_MLPERF_LOADGEN_MODE'] = "accuracy" if env.get('OUTPUT_BASE_DIR', '') == '': @@ -140,15 +141,15 @@ def preprocess(i): # if env.get("MLC_MLPERF_FIND_PERFORMANCE_MODE", '') == "yes": if metric == "target_qps": if is_true(env.get("MLC_MLPERF_FIND_PERFORMANCE_MODE", '')): - print("In find performance mode: using 1 as target_qps") + logger.info("In find performance mode: using 1 as target_qps") else: - print("No target_qps specified. Using 1 as target_qps") + logger.info("No target_qps specified. Using 1 as target_qps") conf[metric] = 1 if metric == "target_latency": if is_true(env.get("MLC_MLPERF_FIND_PERFORMANCE_MODE", '')): - print("In find performance mode: using 0.5ms as target_latency") + logger.info("In find performance mode: using 0.5ms as target_latency") else: - print("No target_latency specified. Using default") + logger.info("No target_latency specified. Using default") if is_false(env.get('MLC_MLPERF_USE_MAX_DURATION', 'yes')) or is_true(env.get( 'MLC_MLPERF_MODEL_EQUAL_ISSUE_MODE', 'no')): # Total number of queries needed is a multiple of dataset @@ -288,7 +289,7 @@ def preprocess(i): else: env['MLC_MLPERF_ACCURACY_RESULTS_DIR'] = '' - run_exists = run_files_exist(log_mode, OUTPUT_DIR, required_files, env) + run_exists = run_files_exist(log_mode, OUTPUT_DIR, required_files, env, logger) if 'MLC_MLPERF_POWER' in env and env.get( 'MLC_MLPERF_SHORT_RANGING_RUN', '') != 'no' and env['MLC_MLPERF_RUN_STYLE'] == "valid" and mode == "performance": @@ -405,14 +406,14 @@ def preprocess(i): if not run_exists or rerun: - print("Output Dir: '" + OUTPUT_DIR + "'") - print(user_conf) + logger.info("Output Dir: '" + OUTPUT_DIR + "'") + logger.info(user_conf) if env.get('MLC_MLPERF_POWER', '') == "yes" and os.path.exists( env.get('MLC_MLPERF_POWER_LOG_DIR', '')): shutil.rmtree(env['MLC_MLPERF_POWER_LOG_DIR']) else: if not env.get('MLC_MLPERF_COMPLIANCE_RUN_POSTPONED', False): - print("Run files exist, skipping run...\n") + logger.warning("Run files exist, skipping run...\n") env['MLC_MLPERF_SKIP_RUN'] = "yes" if not run_exists or rerun or not measure_files_exist(OUTPUT_DIR, @@ -442,7 +443,7 @@ def preprocess(i): return {'return': 0} -def run_files_exist(mode, OUTPUT_DIR, run_files, env): +def run_files_exist(mode, OUTPUT_DIR, run_files, env, logger): import submission_checker as checker from log_parser import MLPerfLog @@ -516,7 +517,7 @@ def run_files_exist(mode, OUTPUT_DIR, run_files, env): else: cmd = f"{env['MLC_PYTHON_BIN_WITH_PATH']} {SCRIPT_PATH} -r {RESULT_DIR} -c {COMPLIANCE_DIR} -o {OUTPUT_DIR}" - print(cmd) + logger.info(cmd) os.system(cmd) is_valid = checker.check_compliance_perf_dir(COMPLIANCE_DIR) diff --git a/script/generate-mlperf-tiny-report/customize.py b/script/generate-mlperf-tiny-report/customize.py index 32bc3701d..009d33ac3 100644 --- a/script/generate-mlperf-tiny-report/customize.py +++ b/script/generate-mlperf-tiny-report/customize.py @@ -12,6 +12,8 @@ def preprocess(i): cur_dir = os.getcwd() + logger = i['automation'].logger + # Query cache for results dirs env_repo_tags = env.get('MLC_IMPORT_TINYMLPERF_REPO_TAGS', '').strip() xtags = '' if env_repo_tags == '' else ',version-' + env_repo_tags @@ -49,8 +51,8 @@ def preprocess(i): env['MLC_TINYMLPERF_CURRENT_DIR'] = cur_dir env['MLC_TINYMLPERF_REPO_VERSION'] = version - print('') - print('Repo path: {}'.format(path)) + logger.info('') + logger.info('Repo path: {}'.format(path)) r = automation.run_native_script({'run_script_input': run_script_input, 'env': env, diff --git a/script/generate-mlperf-tiny-submission/customize.py b/script/generate-mlperf-tiny-submission/customize.py index 32a97ef28..ed764a1b2 100644 --- a/script/generate-mlperf-tiny-submission/customize.py +++ b/script/generate-mlperf-tiny-submission/customize.py @@ -17,6 +17,7 @@ def generate_submission(i): env = i['env'] state = i['state'] inp = i['input'] + logger = i['automation'].logger results_dir = env['MLC_MLPERF_RESULTS_DIR'] if 'MLC_MLPERF_SUBMISSION_DIR' not in env: @@ -25,8 +26,8 @@ def generate_submission(i): if not os.path.isdir(submission_dir): os.makedirs(submission_dir) - print('* MLPerf tiny submission dir: {}'.format(submission_dir)) - print('* MLPerf tiny results dir: {}'.format(results_dir)) + logger.info('* MLPerf tiny submission dir: {}'.format(submission_dir)) + logger.info('* MLPerf tiny results dir: {}'.format(results_dir)) results = [ f for f in os.listdir(results_dir) if not os.path.isfile( os.path.join( @@ -40,7 +41,7 @@ def generate_submission(i): system_meta = state['MLC_SUT_META'] division = system_meta['division'] - print('* MLPerf tiny division: {}'.format(division)) + logger.info('* MLPerf tiny division: {}'.format(division)) path_submission_root = submission_dir path_submission_division = os.path.join(path_submission_root, division) @@ -51,7 +52,7 @@ def generate_submission(i): submitter = system_meta['submitter'] env['MLC_MLPERF_SUBMITTER'] = submitter - print('* MLPerf tiny submitter: {}'.format(submitter)) + logger.info('* MLPerf tiny submitter: {}'.format(submitter)) path_submission = os.path.join(path_submission_division, submitter) if not os.path.isdir(path_submission): @@ -67,8 +68,8 @@ def generate_submission(i): target = parts[1] framework = backend - print('* Target: {}'.format(target)) - print('* Framework: {}'.format(framework)) + logger.info('* Target: {}'.format(target)) + logger.info('* Framework: {}'.format(framework)) result_path = os.path.join(results_dir, res) platform_prefix = inp.get('platform_prefix', '') if platform_prefix: @@ -109,7 +110,7 @@ def generate_submission(i): with open(os.path.join(submission_code_path, "README.md"), mode='w'): pass # create an empty README - print('* MLPerf inference model: {}'.format(model)) + logger.info('* MLPerf inference model: {}'.format(model)) for scenario in scenarios: result_scenario_path = os.path.join( result_model_path, scenario) @@ -181,7 +182,7 @@ def generate_submission(i): files.append("accuracy.txt") for f in files: - print(' * ' + f) + logger.info(' * ' + f) p_target = os.path.join(submission_results_path, f) shutil.copy( os.path.join( diff --git a/script/get-android-sdk/customize.py b/script/get-android-sdk/customize.py index 505838b62..eedcb31e6 100644 --- a/script/get-android-sdk/customize.py +++ b/script/get-android-sdk/customize.py @@ -11,6 +11,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + recursion_spaces = i['recursion_spaces'] run_script_input = i['run_script_input'] @@ -42,7 +44,7 @@ def preprocess(i): sdk_manager_file = 'sdkmanager' + ext - print('') + logger.info('') found = False @@ -76,8 +78,8 @@ def preprocess(i): env['MLC_ANDROID_CMDLINE_TOOLS_URL'] = package_url - print('') - print('Downloading from {} ...'.format(package_url)) + logger.info('') + logger.info('Downloading from {} ...'.format(package_url)) cm = automation.action_object @@ -89,7 +91,7 @@ def preprocess(i): filename = r['filename'] - print('Unzipping file {}'.format(filename)) + logger.info('Unzipping file {}'.format(filename)) r = cm.access({'action': 'unzip_file', 'automation': 'utils,dc2743f8450541e3', @@ -123,7 +125,7 @@ def preprocess(i): paths.append(sdk_manager_dir) # Prepare SDK - print('Preparing Android SDK manager ...') + logger.info('Preparing Android SDK manager ...') r = automation.run_native_script( {'run_script_input': run_script_input, 'env': env, 'script_name': 'prepare-sdk-manager'}) diff --git a/script/get-aocc/customize.py b/script/get-aocc/customize.py index 513539438..03bae6c3b 100644 --- a/script/get-aocc/customize.py +++ b/script/get-aocc/customize.py @@ -71,6 +71,8 @@ def preprocess(i): def detect_version(i): + logger = i['automation'].logger + r = i['automation'].parse_version({'match_text': r'CLANG:\sAOCC_([\d.]+-Build#[\d]+)', 'group_number': 1, 'env_key': 'MLC_AOCC_VERSION', @@ -79,7 +81,7 @@ def detect_version(i): return r version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(fi['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-aria2/customize.py b/script/get-aria2/customize.py index bb9529ec8..f795c314b 100644 --- a/script/get-aria2/customize.py +++ b/script/get-aria2/customize.py @@ -8,6 +8,7 @@ def preprocess(i): # Pre-set by CM os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger recursion_spaces = i['recursion_spaces'] automation = i['automation'] run_script_input = i['run_script_input'] @@ -64,7 +65,7 @@ def preprocess(i): version, archive_with_ext) env['MLC_ARIA2_DOWNLOAD_URL'] = url - print('URL to download ARIA2: {}'.format(url)) + logger.info('URL to download ARIA2: {}'.format(url)) r = automation.run_native_script( {'run_script_input': run_script_input, 'env': env, 'script_name': 'install'}) @@ -102,7 +103,7 @@ def preprocess(i): def detect_version(i): env = i['env'] - + logger = i['automation'].logger r = i['automation'].parse_version({'match_text': r'aria2 version\s*([\d.]+)', 'group_number': 1, 'env_key': 'MLC_ARIA2_VERSION', @@ -111,7 +112,7 @@ def detect_version(i): return r version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-aws-cli/customize.py b/script/get-aws-cli/customize.py index 1da3b4d97..cb9f08ab1 100644 --- a/script/get-aws-cli/customize.py +++ b/script/get-aws-cli/customize.py @@ -40,8 +40,9 @@ def detect_version(i): return r version = r['version'] + logger = i['automation'].logger - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-bazel/customize.py b/script/get-bazel/customize.py index 32a629ea3..6a98d4a47 100644 --- a/script/get-bazel/customize.py +++ b/script/get-bazel/customize.py @@ -41,7 +41,9 @@ def detect_version(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-cl/customize.py b/script/get-cl/customize.py index cd6123150..570906b9e 100644 --- a/script/get-cl/customize.py +++ b/script/get-cl/customize.py @@ -123,7 +123,9 @@ def detect_version(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-cmake/customize.py b/script/get-cmake/customize.py index f276ab1bf..d83877077 100644 --- a/script/get-cmake/customize.py +++ b/script/get-cmake/customize.py @@ -40,7 +40,9 @@ def detect_version(i): return r version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-conda/customize.py b/script/get-conda/customize.py index beb6aa1fb..2f09452f4 100644 --- a/script/get-conda/customize.py +++ b/script/get-conda/customize.py @@ -13,6 +13,8 @@ def preprocess(i): recursion_spaces = i['recursion_spaces'] + logger = i['automation'].logger + conda_prefix_name = env.get('MLC_CONDA_PREFIX_NAME', '') r = None file_name = 'conda.exe' if os_info['platform'] == 'windows' else 'conda' @@ -49,7 +51,7 @@ def preprocess(i): if is_true(env.get('MLC_TMP_FAIL_IF_NOT_FOUND', '')): return r - print(recursion_spaces + ' # {}'.format(r['error'])) + logger.error(recursion_spaces + ' # {}'.format(r['error'])) # Attempt to run installer r = automation.run_native_script( @@ -84,7 +86,7 @@ def detect_version(i): def postprocess(i): env = i['env'] - + logger = i['automation'].logger r = detect_version(i) if r['return'] > 0: return r @@ -107,6 +109,6 @@ def postprocess(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-cuda/customize.py b/script/get-cuda/customize.py index 77ac713e9..ee941b5cc 100644 --- a/script/get-cuda/customize.py +++ b/script/get-cuda/customize.py @@ -102,7 +102,9 @@ def detect_version_nvcc(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} @@ -110,7 +112,8 @@ def detect_version_nvcc(i): def detect_version_cuda_lib(i): env = i['env'] - print(env) + logger = i['automation'].logger + logger.info(env) cuda_rt_file_path = env['MLC_CUDA_RT_WITH_PATH'] cuda_lib_path = os.path.dirname(cuda_rt_file_path) cuda_path = os.path.abspath(os.path.join(cuda_lib_path, os.pardir)) @@ -128,7 +131,7 @@ def detect_version_cuda_lib(i): env['MLC_CUDA_VERSION'] = cuda_version version = cuda_version - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} @@ -138,7 +141,8 @@ def postprocess(i): os_info = i['os_info'] env = i['env'] - + logger = i['automation'].logger + r = detect_version(i) if r['return'] > 0: return r @@ -164,7 +168,7 @@ def postprocess(i): parent_path = os.path.dirname(parent_path) while os.path.isdir(parent_path): if os.path.exists(os.path.join(parent_path, "include")): - print("Path is " + parent_path) + logger.info("Path is " + parent_path) found_path = parent_path cuda_path = found_path env['MLC_CUDA_INSTALLED_PATH'] = cuda_path diff --git a/script/get-cudnn/customize.py b/script/get-cudnn/customize.py index 1e47255e0..c51e210b5 100644 --- a/script/get-cudnn/customize.py +++ b/script/get-cudnn/customize.py @@ -12,6 +12,8 @@ def preprocess(i): env = i['env'] + logger = i['automation'].logger + env['MLC_TMP_RUN_COPY_SCRIPT'] = "no" # If TAR file is not explicitly specified, search @@ -106,7 +108,7 @@ def preprocess(i): return { 'return': 1, 'error': 'Please envoke mlcr get,cudnn --tar_file={full path to the cuDNN tar file}'} - print('Untaring file - can take some time ...') + logger.info('Untaring file - can take some time ...') my_tar = tarfile.open(os.path.expanduser(env['MLC_CUDNN_TAR_FILE_PATH'])) folder_name = my_tar.getnames()[0] @@ -133,7 +135,7 @@ def preprocess(i): print( "Copying cudnn include files to {}(CUDA_INCLUDE_PATH)".format(cuda_inc_path)) shutil.copytree(inc_path, cuda_inc_path, dirs_exist_ok=True) - print("Copying cudnn lib files to {}CUDA_LIB_PATH".format(cuda_lib_path)) + logger.info("Copying cudnn lib files to {}CUDA_LIB_PATH".format(cuda_lib_path)) shutil.copytree(lib_path, cuda_lib_path, dirs_exist_ok=True) except BaseException: # Need to copy to system path via run.sh diff --git a/script/get-dataset-coco/customize.py b/script/get-dataset-coco/customize.py index c4d445ac6..e8798fbaf 100644 --- a/script/get-dataset-coco/customize.py +++ b/script/get-dataset-coco/customize.py @@ -11,6 +11,7 @@ def preprocess(i): automation = i['automation'] env = i['env'] meta = i['meta'] + logger = i['automation'].logger quiet = is_true(env.get('MLC_QUIET', False)) # Check if path is there to detect existing data set @@ -38,8 +39,8 @@ def preprocess(i): return { 'return': 1, 'error': 'COCO dataset is not detected in "{}"'.format(path)} - print('') - print('Detected COCO dataset {} {}'.format(tp, ver)) + logger.info('') + logger.info('Detected COCO dataset {} {}'.format(tp, ver)) env['MLC_DATASET_COCO_DETECTED'] = 'yes' env['MLC_DATASET_COCO_PATH'] = path @@ -142,9 +143,9 @@ def preprocess(i): env['MLC_DATASET_COCO_MD5SUM_ANN'] = md5sum_ann if not detected: - print('') - print('URL for data: {}'.format(url_data_full)) - print('URL for annotations: {}'.format(url_ann_full)) + logger.info('') + logger.info('URL for data: {}'.format(url_data_full)) + logger.info('URL for annotations: {}'.format(url_ann_full)) # Add version and type to tags extra_cache_tags = [] @@ -165,6 +166,8 @@ def postprocess(i): path_to = env.get('MLC_TO', '') + logger = i['automation'].logger + # Check if detected or downloaded if env.get('MLC_DATASET_COCO_DETECTED', '').lower() == 'yes' or path_to != '': @@ -181,9 +184,9 @@ def postprocess(i): path_data = env['MLC_DATASET_COCO_DATA_PATH'] path_ann = env['MLC_DATASET_COCO_ANNOTATIONS_PATH'] - print('') - print(path_all) - print('') + logger.info('') + logger.info(path_all) + logger.info('') path_data_full = os.path.join(path_data, tp_ver) path_ann_full = os.path.join(path_ann, 'annotations') @@ -204,7 +207,7 @@ def postprocess(i): command2 = ' ln -s ' + path_ann_full + ' annotations' for command in [command1, command2]: - print(command) + logger.info(command) os.system(command) env['MLC_DATASET_COCO_PATH'] = path_all diff --git a/script/get-dataset-coco2014/customize.py b/script/get-dataset-coco2014/customize.py index d48db2137..9b7f2a467 100644 --- a/script/get-dataset-coco2014/customize.py +++ b/script/get-dataset-coco2014/customize.py @@ -22,6 +22,7 @@ def preprocess(i): def postprocess(i): + logger = i["automation"].logger env = i['env'] if is_true(env.get('MLC_GENERATE_SAMPLE_ID', '')): env['MLC_COCO2014_SAMPLE_ID_PATH'] = os.path.join( diff --git a/script/get-dataset-cognata-mlcommons/customize.py b/script/get-dataset-cognata-mlcommons/customize.py index 937d42de0..5d00d011a 100644 --- a/script/get-dataset-cognata-mlcommons/customize.py +++ b/script/get-dataset-cognata-mlcommons/customize.py @@ -64,6 +64,8 @@ def postprocess(i): automation = i['automation'] mlc = automation.action_object + logger = automation.logger + cur_dir = os.getcwd() quiet = is_true(env.get('MLC_QUIET', False)) @@ -101,8 +103,8 @@ def postprocess(i): cfg['real_path'] = dataset_path - print('') - print('Used dataset path: {}'.format(dataset_path)) + logger.info('') + logger.info('Used dataset path: {}'.format(dataset_path)) env['MLC_DATASET_MLCOMMONS_COGNATA_PATH'] = dataset_path @@ -121,8 +123,8 @@ def postprocess(i): if cfg.get('processed', False): if not utils.check_if_true_yes_on( env, 'MLC_DATASET_MLCOMMONS_COGNATA_UPDATE'): - print('') - print('Already processed: use --update to update this dataset') + logger.info('') + logger.info('Already processed: use --update to update this dataset') return {'return': 0} @@ -152,7 +154,7 @@ def postprocess(i): if x != '': first_url = x else: - print('') + logger.info('') first_url = input( 'Please register at https://mlcommons.org/datasets/cognata and enter private URL: ') @@ -232,12 +234,12 @@ def postprocess(i): return {'return': 0, 'error': 'no sets found'} ########################################################################## - print('') - print('Available or selected serial numbers (use --serial_numbers=a,b,c to download specific subsets):') - print('') + logger.info('') + logger.info('Available or selected serial numbers (use --serial_numbers=a,b,c to download specific subsets):') + logger.info('') for d in data: s = d[serial_key] - print(s) + logger.info(s) for d in data: url = d[url_key] @@ -253,8 +255,8 @@ def postprocess(i): if not os.path.isfile(dataset_path2): - print('') - print('Downloading {} ...'.format(url_export)) + logger.info('') + logger.info('Downloading {} ...'.format(url_export)) r = mlc.access({'action': 'run', 'automation': 'script', @@ -267,8 +269,8 @@ def postprocess(i): return r ########################################################################## - print('') - print('Processing subsets ...') + logger.info('') + logger.info('Processing subsets ...') group_names = [] for s in env.get('MLC_DATASET_MLCOMMONS_COGNATA_GROUP_NAMES', @@ -289,8 +291,8 @@ def postprocess(i): dataset_path2 = os.path.join(dataset_path1, serial_file) dataset_path3 = os.path.join(dataset_path1, d[serial_key]) - print('') - print('Processing {} ...'.format(serial_file)) + logger.info('') + logger.info('Processing {} ...'.format(serial_file)) dataset_key = 'File_Data' url_key = 'File_Link' @@ -332,12 +334,12 @@ def postprocess(i): url = d[url_key] - print('') - print('Downloading {} ...'.format(file_name)) + logger.info('') + logger.info('Downloading {} ...'.format(file_name)) if os.path.isfile(file_name_with_path_done): - print('') - print(' Already processed - skipping ...') + logger.info('') + logger.warning(' Already processed - skipping ...') continue if os.name == 'nt': @@ -349,16 +351,16 @@ def postprocess(i): ' --async-dns=false -x15 -s15 "{}" --dir "{}" -o "{}"'.format( url, dataset_path3, file_name) - print('') - print(cmd) - print('') + logger.info('') + logger.info(cmd) + logger.info('') os.system(cmd) # Unarchive - print('') - print('Extracting file {} ...'.format(file_name_with_path)) - print('') + logger.info('') + logger.info('Extracting file {} ...'.format(file_name_with_path)) + logger.info('') if file_name.endswith('.zip'): @@ -390,7 +392,7 @@ def postprocess(i): # Remove file os.remove(file_name_with_path) - print('') + logger.info('') # Mark that processed this dataset once correctly cfg['processed'] = True diff --git a/script/get-dataset-openimages/customize.py b/script/get-dataset-openimages/customize.py index 9d4539739..b0a23bec5 100644 --- a/script/get-dataset-openimages/customize.py +++ b/script/get-dataset-openimages/customize.py @@ -8,11 +8,11 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] - - print("") + logger = i['automation'].logger + logger.info("") print("Using MLCommons Inference source from '" + env['MLC_MLPERF_INFERENCE_SOURCE'] + "'") - print("") + logger.info("") if os_info['platform'] == 'windows': MLPERF_CLASSES = ['Airplane', 'Antelope', 'Apple', 'Backpack', 'Balloon', 'Banana', diff --git a/script/get-dlrm-data-mlperf-inference/customize.py b/script/get-dlrm-data-mlperf-inference/customize.py index 8f0153094..11724845f 100644 --- a/script/get-dlrm-data-mlperf-inference/customize.py +++ b/script/get-dlrm-data-mlperf-inference/customize.py @@ -9,11 +9,13 @@ def preprocess(i): env = i['env'] + logger = i['automation'].logger + dlrm_data_path = env.get( 'MLC_DLRM_DATA_PATH', env.get( 'DLRM_DATA_PATH', '')) if dlrm_data_path == '': - print( + logger.warning( f'Data path is not given as input through --dlrm_data_path. Using the cache directory:{os.getcwd()} as the data path') dlrm_data_path = os.getcwd() elif not os.path.exists(dlrm_data_path): @@ -42,37 +44,37 @@ def preprocess(i): if variation == "nvidia": if not os.path.exists(os.path.join(dlrm_data_path, "model")): - print(f'model directory is missing inside {dlrm_data_path}') + logger.warning(f'model directory is missing inside {dlrm_data_path}') env['MLC_DLRM_MODEL_DOWNLOAD'] = True if not os.path.exists(os.path.join(dlrm_data_path, "criteo")): - print(f'criteo directory is missing inside {dlrm_data_path}') + logger.warning(f'criteo directory is missing inside {dlrm_data_path}') env['MLC_DLRM_DATASET_DOWNLOAD'] = True if not os.path.exists(os.path.join( dlrm_data_path, "model", "model_weights")): - print( + logger.warning( f'model_weights directory is missing inside {dlrm_data_path}/model') env['MLC_DLRM_MODEL_DOWNLOAD'] = True if not os.path.exists(os.path.join(dlrm_data_path, "criteo", "day23")): - print(f'day23 directory is missing inside {dlrm_data_path}/day23') + logger.warning(f'day23 directory is missing inside {dlrm_data_path}/day23') env['MLC_DLRM_DATASET_DOWNLOAD'] = True if not os.path.exists(os.path.join( dlrm_data_path, "criteo", "day23", "fp32")): - print( + logger.warning( f'fp32 directory is missing inside {dlrm_data_path}/criteo/day23') env['MLC_DLRM_DATASET_DOWNLOAD'] = True if not os.path.exists(os.path.join(dlrm_data_path, "criteo", "day23", "fp32", "day_23_sparse_multi_hot.npz")) and not os.path.exists( os.path.join(dlrm_data_path, "criteo", "day23", "fp32", "day_23_sparse_multi_hot_unpacked")): - print( + logger.warning( f'day_23_sparse_multi_hot.npz or day_23_sparse_multi_hot_unpacked is missing inside {dlrm_data_path}/criteo/day23/fp32') env['MLC_DLRM_DATASET_DOWNLOAD'] = True if not os.path.exists(os.path.join( dlrm_data_path, "criteo", "day23", "fp32", "day_23_dense.npy")): - print( + logger.warning( f'day_23_dense.npy is missing inside {dlrm_data_path}/criteo/day23/fp32') env['MLC_DLRM_DATASET_DOWNLOAD'] = True if not os.path.exists(os.path.join( dlrm_data_path, "criteo", "day23", "fp32", "day_23_labels.npy")): - print( + logger.warning( f'day_23_labels.npy is missing inside {dlrm_data_path}/criteo/day23/fp32') env['MLC_DLRM_DATASET_DOWNLOAD'] = True if not os.path.exists(os.path.join( diff --git a/script/get-docker/customize.py b/script/get-docker/customize.py index 3097e343f..999b2b323 100644 --- a/script/get-docker/customize.py +++ b/script/get-docker/customize.py @@ -64,6 +64,8 @@ def detect_version(i): if r['return'] > 0: return r + logger = i['automation'].logger + version = r['version'] tool = "docker" @@ -71,7 +73,7 @@ def detect_version(i): if "podman" in r['string'].lower(): tool = "podman" - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version, "tool": tool} diff --git a/script/get-gcc/customize.py b/script/get-gcc/customize.py index 01749aba5..3cd898029 100644 --- a/script/get-gcc/customize.py +++ b/script/get-gcc/customize.py @@ -59,8 +59,9 @@ def detect_version(i): return {'return': 0, 'version': -1} return r version = r['version'] + logger = i['automation'].logger - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-generic-python-lib/customize.py b/script/get-generic-python-lib/customize.py index 02c8071c6..4ce85258b 100644 --- a/script/get-generic-python-lib/customize.py +++ b/script/get-generic-python-lib/customize.py @@ -9,6 +9,7 @@ def preprocess(i): env = i['env'] meta = i['meta'] automation = i['automation'] + logger = automation.logger run_script_input = i['run_script_input'] pip_version = env.get('MLC_PIP_VERSION', '').strip().split('.') diff --git a/script/get-generic-sys-util/customize.py b/script/get-generic-sys-util/customize.py index f7c7a37d0..250afdbdc 100644 --- a/script/get-generic-sys-util/customize.py +++ b/script/get-generic-sys-util/customize.py @@ -11,7 +11,7 @@ def preprocess(i): env = i['env'] state = i['state'] automation = i['automation'] - + logger = automation.logger # Use VERSION_CMD as CHECK_CMD if no CHECK_CMD is set if env.get('MLC_SYS_UTIL_VERSION_CMD', '') != '' and env.get( 'MLC_SYS_UTIL_CHECK_CMD', '') == '': @@ -29,7 +29,7 @@ def preprocess(i): r = automation.run_native_script( {'run_script_input': i['run_script_input'], 'env': env, 'script_name': 'detect'}) if r['return'] != 0: # detection failed, do install via prehook_deps - print("detection failed, going for installation") + logger.warning("detection failed, going for installation") env['MLC_GENERIC_SYS_UTIL_INSTALL_NEEDED'] = "yes" return {'return': 0} else: # detection is successful, no need to install @@ -54,9 +54,9 @@ def preprocess(i): package_name = package.get(pm) if os_info['platform'] == 'windows' and not package_name: - print('') - print('WARNING: for now skipping get-generic-sys-util on Windows ...') - print('') + logger.info('') + logger.warning('For now skipping get-generic-sys-util on Windows ...') + logger.info('') return {'return': 0} @@ -68,9 +68,10 @@ def preprocess(i): 'error': f'No package name specified for {util} in the meta'} if not package_name: - if is_true(env.get('MLC_GENERIC_SYS_UTIL_IGNORE_MISSING_PACKAGE', False)): - print( - f"WARNING: No package name specified for {pm} and util name {util}. Ignoring it...") + if str(env.get('MLC_GENERIC_SYS_UTIL_IGNORE_MISSING_PACKAGE', '') + ).lower() in ["1", "true", "yes"]: + logger.warning( + f"No package name specified for {pm} and util name {util}. Ignoring it...") env['MLC_TMP_GENERIC_SYS_UTIL_PACKAGE_INSTALL_IGNORED'] = 'yes' return {'return': 0} else: @@ -130,7 +131,7 @@ def detect_version(i): version_env_key = f"MLC_{env['MLC_SYS_UTIL_NAME'].upper()}_VERSION" version_check_re = env.get('MLC_SYS_UTIL_VERSION_RE', '') group_number = env.get('MLC_TMP_VERSION_DETECT_GROUP_NUMBER', 1) - + logger = i['automation'].logger # Confirm that the regex pattern and file are present if version_check_re == '' or not os.path.exists("tmp-ver.out"): version = "undetected" @@ -144,7 +145,7 @@ def detect_version(i): return r version = r['version'] - print( + logger.info( i['recursion_spaces'] + ' Detected version: {}'.format(version)) diff --git a/script/get-gh-actions-runner/customize.py b/script/get-gh-actions-runner/customize.py index 795c50da6..09d8f8330 100644 --- a/script/get-gh-actions-runner/customize.py +++ b/script/get-gh-actions-runner/customize.py @@ -13,7 +13,7 @@ def preprocess(i): automation = i['automation'] mlc = automation.action_object - + logger = automation.logger quiet = is_true(env.get('MLC_QUIET', False)) cmd = env.get('MLC_GH_ACTIONS_RUNNER_COMMAND', '') @@ -28,7 +28,7 @@ def preprocess(i): cache_rm_tags = "gh,runner,_install" r = mlc.access({'action': 'rm', 'automation': 'cache', 'tags': cache_rm_tags, 'f': True}) - print(r) + logger.info(r) if r['return'] != 0 and r['return'] != 16: # ignore missing ones return r elif cmd == "start": diff --git a/script/get-github-cli/customize.py b/script/get-github-cli/customize.py index 7993b1e3c..e157d387a 100644 --- a/script/get-github-cli/customize.py +++ b/script/get-github-cli/customize.py @@ -10,7 +10,7 @@ def preprocess(i): env = i['env'] recursion_spaces = i['recursion_spaces'] - + logger = i['automation'].logger file_name = 'gh.exe' if os_info['platform'] == 'windows' else 'gh' # Will check env['MLC_TMP_PATH'] if comes from installation script @@ -27,7 +27,7 @@ def preprocess(i): if is_true(env.get('MLC_TMP_FAIL_IF_NOT_FOUND', '')): return r - print(recursion_spaces + ' # {}'.format(r['error'])) + logger.error(recursion_spaces + ' # {}'.format(r['error'])) # Attempt to run installer r = { @@ -54,7 +54,8 @@ def postprocess(i): return r version = r['version'] + logger = i['automation'].logger - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-go/customize.py b/script/get-go/customize.py index 95ff8630a..24a173071 100644 --- a/script/get-go/customize.py +++ b/script/get-go/customize.py @@ -40,8 +40,9 @@ def detect_version(i): return r version = r['version'] + logger = i['automation'].logger - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-huggingface-cli/customize.py b/script/get-huggingface-cli/customize.py index ee0a1ff42..954f7c90c 100644 --- a/script/get-huggingface-cli/customize.py +++ b/script/get-huggingface-cli/customize.py @@ -16,7 +16,7 @@ def preprocess(i): def postprocess(i): env = i['env'] - + logger = i['automation'].logger r = i['automation'].parse_version({'match_text': r'huggingface_hub\s*version:\s*([\d.]+)', 'group_number': 1, 'env_key': 'MLC_GITHUBCLI_VERSION', @@ -26,6 +26,6 @@ def postprocess(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-ipol-src/customize.py b/script/get-ipol-src/customize.py index 4de9d4f9c..a010447c4 100644 --- a/script/get-ipol-src/customize.py +++ b/script/get-ipol-src/customize.py @@ -11,7 +11,7 @@ def preprocess(i): script_path = i['artifact'].path automation = i['automation'] - + logger = automation.logger cm = automation.action_object path = os.getcwd() @@ -27,7 +27,7 @@ def preprocess(i): '{{MLC_IPOL_NUMBER}}', number) - print('Downloading from {}'.format(url)) + logger.info('Downloading from {}'.format(url)) r = cm.access({'action': 'download_file', 'automation': 'utils,dc2743f8450541e3', @@ -37,7 +37,7 @@ def preprocess(i): filename = r['filename'] - print('Unzipping file {}'.format(filename)) + logger.info('Unzipping file {}'.format(filename)) r = cm.access({'action': 'unzip_file', 'automation': 'utils,dc2743f8450541e3', @@ -46,7 +46,7 @@ def preprocess(i): return r if os.path.isfile(filename): - print('Removing file {}'.format(filename)) + logger.info('Removing file {}'.format(filename)) os.remove(filename) # Get sub-directory from filename @@ -60,7 +60,7 @@ def preprocess(i): cmd = 'patch -p0 < {}'.format(os.path.join(script_path, 'patch', '20240127.patch')) - print('Patching code: {}'.format(cmd)) + logger.info('Patching code: {}'.format(cmd)) os.system(cmd) return {'return': 0} diff --git a/script/get-java/customize.py b/script/get-java/customize.py index c646f20b8..406222249 100644 --- a/script/get-java/customize.py +++ b/script/get-java/customize.py @@ -10,7 +10,7 @@ def preprocess(i): env = i['env'] automation = i['automation'] - + logger = automation.logger recursion_spaces = i['recursion_spaces'] run_script_input = i['run_script_input'] @@ -68,7 +68,7 @@ def preprocess(i): env['MLC_JAVA_PREBUILT_URL'] = url env['MLC_JAVA_PREBUILT_FILENAME'] = filename - print('') + logger.info('') print( recursion_spaces + ' Downloading and installing prebuilt Java from {} ...'.format( @@ -88,7 +88,7 @@ def preprocess(i): return {'return': 1, 'error': 'can\'t find target file {}'.format(target_file)} - print('') + logger.info('') print( recursion_spaces + ' Registering file {} ...'.format(target_file)) @@ -126,8 +126,9 @@ def detect_version(i): return r version = r['version'] + logger = i['automation'].logger - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-javac/customize.py b/script/get-javac/customize.py index 7376a523e..2b0c7cb82 100644 --- a/script/get-javac/customize.py +++ b/script/get-javac/customize.py @@ -10,7 +10,7 @@ def preprocess(i): env = i['env'] automation = i['automation'] - + logger = automation.logger recursion_spaces = i['recursion_spaces'] run_script_input = i['run_script_input'] @@ -68,7 +68,7 @@ def preprocess(i): env['MLC_JAVAC_PREBUILT_URL'] = url env['MLC_JAVAC_PREBUILT_FILENAME'] = filename - print('') + logger.info('') print( recursion_spaces + ' Downloading and installing prebuilt Java from {} ...'.format( @@ -88,7 +88,7 @@ def preprocess(i): return {'return': 1, 'error': 'can\'t find target file {}'.format(target_file)} - print('') + logger.info('') print( recursion_spaces + ' Registering file {} ...'.format(target_file)) @@ -126,8 +126,9 @@ def detect_version(i): return r version = r['version'] + logger = i['automation'].logger - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-llvm/customize.py b/script/get-llvm/customize.py index e53a7719f..821333e8a 100644 --- a/script/get-llvm/customize.py +++ b/script/get-llvm/customize.py @@ -56,8 +56,9 @@ def detect_version(i): return r version = r['version'] - - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-ml-model-efficientnet-lite/customize.py b/script/get-ml-model-efficientnet-lite/customize.py index b9a547fee..1f3568ddc 100644 --- a/script/get-ml-model-efficientnet-lite/customize.py +++ b/script/get-ml-model-efficientnet-lite/customize.py @@ -10,6 +10,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + cm = automation.action_object path = os.getcwd() @@ -17,7 +19,7 @@ def preprocess(i): url = env['MLC_PACKAGE_URL'] env['MLC_ML_MODEL_STARTING_WEIGHTS_FILENAME'] = url - print('Downloading from {}'.format(url)) + logger.info('Downloading from {}'.format(url)) r = download_file({'url': url}) if r['return'] > 0: diff --git a/script/get-ml-model-gptj/customize.py b/script/get-ml-model-gptj/customize.py index 997c133ed..8d0ca4e9c 100644 --- a/script/get-ml-model-gptj/customize.py +++ b/script/get-ml-model-gptj/customize.py @@ -7,6 +7,7 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger if env.get('MLC_GPTJ_INTEL_MODEL', '') == 'yes': i['run_script_input']['script_name'] = 'run-intel' @@ -17,7 +18,7 @@ def preprocess(i): 'code', 'gptj-99', 'pytorch-cpu') - print(f"Harness Root: {harness_root}") + logger.info(f"Harness Root: {harness_root}") env['MLC_HARNESS_CODE_ROOT'] = harness_root env['MLC_CALIBRATION_CODE_ROOT'] = os.path.join( env['MLC_MLPERF_INFERENCE_RESULTS_PATH'], 'closed', 'Intel', 'calibration') diff --git a/script/get-ml-model-mobilenet/customize.py b/script/get-ml-model-mobilenet/customize.py index b9a547fee..cbafeb19a 100644 --- a/script/get-ml-model-mobilenet/customize.py +++ b/script/get-ml-model-mobilenet/customize.py @@ -9,6 +9,7 @@ def preprocess(i): env = i['env'] automation = i['automation'] + logger = automation.logger cm = automation.action_object @@ -17,7 +18,7 @@ def preprocess(i): url = env['MLC_PACKAGE_URL'] env['MLC_ML_MODEL_STARTING_WEIGHTS_FILENAME'] = url - print('Downloading from {}'.format(url)) + logger.info('Downloading from {}'.format(url)) r = download_file({'url': url}) if r['return'] > 0: diff --git a/script/get-ml-model-retinanet-nvidia/customize.py b/script/get-ml-model-retinanet-nvidia/customize.py index efcc67e3d..df3b3d9b4 100644 --- a/script/get-ml-model-retinanet-nvidia/customize.py +++ b/script/get-ml-model-retinanet-nvidia/customize.py @@ -29,10 +29,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - env = i['env'] - env['MLC_NVIDIA_RETINANET_EFFICIENT_NMS_CONCAT_MODEL_WITH_PATH'] = os.path.join( - os.getcwd(), "test_fpn_efficientnms_concatall.onnx") - if "MLC_NVIDIA_EFFICIENT_NMS" in env: - env['MLC_NVIDIA_RETINANET_EFFICIENT_NMS_CONCAT_MODEL_WITH_PATH'] = env['MLC_NVIDIA_MODEL_PATCHED_PATH'] - return {'return': 0} diff --git a/script/get-ml-model-rnnt/customize.py b/script/get-ml-model-rnnt/customize.py index a63eb152f..c6ec5aefa 100644 --- a/script/get-ml-model-rnnt/customize.py +++ b/script/get-ml-model-rnnt/customize.py @@ -11,13 +11,15 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + cm = automation.action_object path = os.getcwd() url = env['MLC_PACKAGE_URL'] - print('Downloading from {}'.format(url)) + logger.info('Downloading from {}'.format(url)) r = cm.access({'action': 'download_file', 'automation': 'utils,dc2743f8450541e3', diff --git a/script/get-mlperf-inference-sut-description/customize.py b/script/get-mlperf-inference-sut-description/customize.py index 4c35209e9..9a425eced 100644 --- a/script/get-mlperf-inference-sut-description/customize.py +++ b/script/get-mlperf-inference-sut-description/customize.py @@ -10,6 +10,8 @@ def preprocess(i): state = i['state'] os_info = i['os_info'] + logger = i['automation'].logger + submitter = env.get('MLC_MLPERF_SUBMITTER', 'MLCommons') auto_detected_hw_name = False @@ -45,13 +47,13 @@ def preprocess(i): env['MLC_SUT_PATH'] = sut_path if os.path.exists(sut_path) and is_true(env.get('MLC_SUT_DESC_CACHE', '')): - print(f"Reusing SUT description file {sut}") + logger.info(f"Reusing SUT description file {sut}") state['MLC_SUT_META'] = json.load(open(sut_path)) else: if not os.path.exists(os.path.dirname(sut_path)): os.makedirs(os.path.dirname(sut_path)) - print("Generating SUT description file for " + sut) + logger.info("Generating SUT description file for " + sut) hw_path = os.path.join(os.getcwd(), "hardware", hw_name + ".json") if not os.path.exists(os.path.dirname(hw_path)): os.makedirs(os.path.dirname(hw_path)) diff --git a/script/get-mlperf-tiny-eembc-energy-runner-src/customize.py b/script/get-mlperf-tiny-eembc-energy-runner-src/customize.py index ae9548c8b..157c6b9f8 100644 --- a/script/get-mlperf-tiny-eembc-energy-runner-src/customize.py +++ b/script/get-mlperf-tiny-eembc-energy-runner-src/customize.py @@ -25,6 +25,8 @@ def postprocess(i): env = i['env'] state = i['state'] + logger = i['automation'].logger + env['MLC_EEMBC_ENERGY_RUNNER_SRC'] = os.path.join(os.getcwd(), 'src') datasets_src_path = os.path.join(os.getcwd(), 'src', 'datasets') env['MLC_EEMBC_ENERGY_RUNNER_SRC_DATASETS'] = datasets_src_path @@ -34,8 +36,8 @@ def postprocess(i): sessions_path = os.path.join(home_directory, 'eembc', 'runner', 'sessions') - print('') - print('Path to EEMBC runner sessions: {}'.format(sessions_path)) + logger.info('') + logger.info('Path to EEMBC runner sessions: {}'.format(sessions_path)) env['MLC_EEMBC_ENERGY_RUNNER_SESSIONS'] = sessions_path @@ -50,16 +52,16 @@ def postprocess(i): 'ulp-mlperf', 'datasets') - print('') - print('Path to EEMBC runner datasets: {}'.format(datasets_path)) + logger.info('') + logger.info('Path to EEMBC runner datasets: {}'.format(datasets_path)) if not os.path.isdir(datasets_path): os.makedirs(datasets_path) env['MLC_EEMBC_ENERGY_RUNNER_DATASETS'] = datasets_path - print('') - print('Copying datasets to EEMBC user space ...') + logger.info('') + logger.info('Copying datasets to EEMBC user space ...') shutil.copytree(datasets_src_path, datasets_path, dirs_exist_ok=True) diff --git a/script/get-onnxruntime-prebuilt/customize.py b/script/get-onnxruntime-prebuilt/customize.py index b6045ddd0..3934128d1 100644 --- a/script/get-onnxruntime-prebuilt/customize.py +++ b/script/get-onnxruntime-prebuilt/customize.py @@ -6,6 +6,8 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger + machine = env.get('MLC_HOST_OS_MACHINE', '') if machine == '': machine = 'x86_64' @@ -35,9 +37,9 @@ def preprocess(i): URL = 'https://github.com/microsoft/onnxruntime/releases/download/v{}/{}'.format( version, FILENAME) - print('') - print('Downloading from {}'.format(URL)) - print('') + logger.info('') + logger.info('Downloading from {}'.format(URL)) + logger.info('') env['FOLDER'] = FOLDER env['FILENAME'] = FILENAME diff --git a/script/get-openssl/customize.py b/script/get-openssl/customize.py index 6cdb4a657..b27445f27 100644 --- a/script/get-openssl/customize.py +++ b/script/get-openssl/customize.py @@ -39,7 +39,8 @@ def detect_version(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-python3/customize.py b/script/get-python3/customize.py index 299dc0b59..b93186e56 100644 --- a/script/get-python3/customize.py +++ b/script/get-python3/customize.py @@ -65,7 +65,8 @@ def detect_version(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-qaic-apps-sdk/customize.py b/script/get-qaic-apps-sdk/customize.py index 289c2a70b..09dd7f9f0 100644 --- a/script/get-qaic-apps-sdk/customize.py +++ b/script/get-qaic-apps-sdk/customize.py @@ -43,6 +43,9 @@ def preprocess(i): def detect_version(i): env = i['env'] + + logger = i['automation'].logger + sdk_path = env['MLC_QAIC_APPS_SDK_PATH'] version = None version_xml_path = os.path.join(sdk_path, "versions", "apps.xml") @@ -64,7 +67,7 @@ def detect_version(i): if not version: return {'return': 1, 'error': f'qaic apps sdk version info not found'} - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-qaic-platform-sdk/customize.py b/script/get-qaic-platform-sdk/customize.py index da006b802..fc87668f9 100644 --- a/script/get-qaic-platform-sdk/customize.py +++ b/script/get-qaic-platform-sdk/customize.py @@ -44,6 +44,8 @@ def preprocess(i): def detect_version(i): env = i['env'] + + logger = i['automation'].logger sdk_path = env['MLC_QAIC_PLATFORM_SDK_PATH'] version = None version_xml_path = os.path.join(sdk_path, "versions", "platform.xml") @@ -65,7 +67,7 @@ def detect_version(i): if not version: return {'return': 1, 'error': f'qaic platform sdk version info not found'} - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-rclone/customize.py b/script/get-rclone/customize.py index 0b3a05065..f9b486bed 100644 --- a/script/get-rclone/customize.py +++ b/script/get-rclone/customize.py @@ -91,7 +91,8 @@ def detect_version(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} @@ -101,6 +102,8 @@ def postprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger + gdrive = env.get('MLC_RCLONE_GDRIVE', '') if gdrive == "yes": config = configparser.ConfigParser() @@ -122,8 +125,7 @@ def postprocess(i): with open(default_config_path, 'w') as configfile: default_config.write(configfile) - print({section: dict(default_config[section]) - for section in default_config.sections()}) + logger.info(f"{section: dict(default_config[section]) for section in default_config.sections()}") r = detect_version(i) diff --git a/script/get-rocm/customize.py b/script/get-rocm/customize.py index 351c338aa..aa09192b8 100644 --- a/script/get-rocm/customize.py +++ b/script/get-rocm/customize.py @@ -43,7 +43,8 @@ def detect_version(i): version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger = i['automation'].logger + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-sys-utils-cm/customize.py b/script/get-sys-utils-cm/customize.py index dd2672fd8..75c343df1 100644 --- a/script/get-sys-utils-cm/customize.py +++ b/script/get-sys-utils-cm/customize.py @@ -9,6 +9,8 @@ def preprocess(i): env = i['env'] + logger = i['automation'].logger + automation = i['automation'] cm = automation.action_object @@ -25,9 +27,9 @@ def preprocess(i): # "detect,os"! if os_info['platform'] == 'windows': - print('') - print('This script is not used on Windows') - print('') + logger.info('') + logger.warning('This script is not used on Windows') + logger.info('') # If windows, download here otherwise use run.sh @@ -81,10 +83,10 @@ def preprocess(i): # env['+PATH']=[os.path.join(path, 'bin')] # else: - print('') - print('***********************************************************************') - print('This script will attempt to install minimal system dependencies for CM.') - print('Note that you may be asked for your SUDO password ...') - print('***********************************************************************') + logger.info('') + logger.info('***********************************************************************') + logger.info('This script will attempt to install minimal system dependencies for CM.') + logger.info('Note that you may be asked for your SUDO password ...') + logger.info('***********************************************************************') return {'return': 0} diff --git a/script/get-sys-utils-min/customize.py b/script/get-sys-utils-min/customize.py index ed1a2519b..17f93a1aa 100644 --- a/script/get-sys-utils-min/customize.py +++ b/script/get-sys-utils-min/customize.py @@ -9,6 +9,8 @@ def preprocess(i): env = i['env'] + logger = i['automation'].logger + automation = i['automation'] cm = automation.action_object @@ -23,22 +25,22 @@ def preprocess(i): for cd in clean_dirs.split(','): if cd != '': if os.path.isdir(cd): - print('Cleaning directory {}'.format(cd)) + logger.info('Cleaning directory {}'.format(cd)) shutil.rmtree(cd) url = env['MLC_PACKAGE_WIN_URL'] urls = [url] if ';' not in url else url.split(';') - print('') - print('Current directory: {}'.format(os.getcwd())) + logger.info('') + logger.info('Current directory: {}'.format(os.getcwd())) for url in urls: url = url.strip() - print('') - print('Downloading from {}'.format(url)) + logger.info('') + logger.info('Downloading from {}'.format(url)) r = download_file({ 'url': url, 'verify': False}) @@ -47,7 +49,7 @@ def preprocess(i): filename = r['filename'] - print('Unzipping file {}'.format(filename)) + logger.info('Unzipping file {}'.format(filename)) r = unzip_file({ 'filename': filename}) @@ -55,10 +57,10 @@ def preprocess(i): return r if os.path.isfile(filename): - print('Removing file {}'.format(filename)) + logger.info('Removing file {}'.format(filename)) os.remove(filename) - print('') + logger.info('') # Add to path env['+PATH'] = [os.path.join(path, 'bin')] diff --git a/script/get-tensorrt/customize.py b/script/get-tensorrt/customize.py index 616111509..9eeb536d7 100644 --- a/script/get-tensorrt/customize.py +++ b/script/get-tensorrt/customize.py @@ -12,6 +12,8 @@ def preprocess(i): env = i['env'] + logger = i['automation'].logger + # Not enforcing dev requirement for now if env.get('MLC_TENSORRT_TAR_FILE_PATH', '') == '' and env.get( 'MLC_TENSORRT_REQUIRE_DEV1', '') != 'yes' and env.get('MLC_HOST_PLATFORM_FLAVOR_', '') != 'aarch64': @@ -95,7 +97,7 @@ def preprocess(i): return {'return': 1, 'error': 'Please envoke mlcr "' + ",".join(tags) + '" --tar_file={full path to the TensorRT tar file}'} - print('Untaring file - can take some time ...') + logger.info('Untaring file - can take some time ...') file_name = "trtexec" my_tar = tarfile.open( diff --git a/script/get-terraform/customize.py b/script/get-terraform/customize.py index 39ae728c2..d17962f71 100644 --- a/script/get-terraform/customize.py +++ b/script/get-terraform/customize.py @@ -39,9 +39,11 @@ def detect_version(i): if r['return'] > 0: return r + logger = i['automation'].logger + version = r['version'] - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-tvm-model/customize.py b/script/get-tvm-model/customize.py index f214f570e..8dafcfba6 100644 --- a/script/get-tvm-model/customize.py +++ b/script/get-tvm-model/customize.py @@ -13,6 +13,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) work_dir = env.get('MLC_TUNE_TVM_MODEL_WORKDIR', '') @@ -31,7 +33,7 @@ def preprocess(i): "Error: the found workdir does not contain database_tuning_record.json") if env.get('MLC_TUNE_TVM_MODEL', '') != '': - print("The \"tune-model\" variation is selected, but at the same time the path to the existing \"work_dir\" is also specified. The compiled model will be based on the found existing \"work_dir\".") + logger.warning("The \"tune-model\" variation is selected, but at the same time the path to the existing \"work_dir\" is also specified. The compiled model will be based on the found existing \"work_dir\".") env["MLC_TUNE_TVM_MODEL"] = "no" return {'return': 0} diff --git a/script/install-bazel/customize.py b/script/install-bazel/customize.py index a3d230c47..08914d8b5 100644 --- a/script/install-bazel/customize.py +++ b/script/install-bazel/customize.py @@ -10,6 +10,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + recursion_spaces = i['recursion_spaces'] need_version = env.get('MLC_VERSION', '') @@ -17,7 +19,7 @@ def preprocess(i): return {'return': 1, 'error': 'internal problem - MLC_VERSION is not defined in env'} - print(recursion_spaces + ' # Requested version: {}'.format(need_version)) + logger.info(f"{recursion_spaces} # Requested version: {need_version}") # if 'MLC_GIT_CHECKOUT' not in env: # env['MLC_GIT_CHECKOUT'] = 'releases/gcc-' + need_version diff --git a/script/install-cmake-prebuilt/customize.py b/script/install-cmake-prebuilt/customize.py index ccdc6ebee..ca2f1e367 100644 --- a/script/install-cmake-prebuilt/customize.py +++ b/script/install-cmake-prebuilt/customize.py @@ -11,6 +11,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + recursion_spaces = i['recursion_spaces'] need_version = env.get('MLC_VERSION', '') @@ -18,7 +20,7 @@ def preprocess(i): return {'return': 1, 'error': 'internal problem - MLC_VERSION is not defined in env'} - print(recursion_spaces + ' # Requested version: {}'.format(need_version)) + logger.info(f"{recursion_spaces} # Requested version: {need_version}") version_split = need_version.split(".") while len(version_split) < 3: @@ -66,10 +68,10 @@ def preprocess(i): package_url = 'https://github.com/Kitware/CMake/releases/download/v' + \ need_version + '/' + package_name - print(recursion_spaces + ' # Prepared package URL: {}'.format(package_url)) + logger.info(f"{recursion_spaces} # Prepared package URL: {package_url}") - print('') - print('Downloading from {} ...'.format(package_url)) + logger.info('') + logger.info(f"Downloading from {package_url} ...") r = download_file({ 'url': package_url}) @@ -80,7 +82,7 @@ def preprocess(i): # Check what to do with this file depending on OS if os_info['platform'] == 'windows': - print('Unzipping file {}'.format(filename)) + logger.info(f"Unzipping file {filename}") r = unzip_file({ 'strip_folders': 1, @@ -89,7 +91,7 @@ def preprocess(i): return r if os.path.isfile(filename): - print('Removing file {}'.format(filename)) + logger.info(f"Removing file {filename}") os.remove(filename) path_bin = os.path.join(os.getcwd(), 'bin') diff --git a/script/install-diffusers-from-src/customize.py b/script/install-diffusers-from-src/customize.py index 300164858..a587d715b 100644 --- a/script/install-diffusers-from-src/customize.py +++ b/script/install-diffusers-from-src/customize.py @@ -18,5 +18,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - return {'return': 0} diff --git a/script/install-gcc-src/customize.py b/script/install-gcc-src/customize.py index 5d37ab787..dba1f0d56 100644 --- a/script/install-gcc-src/customize.py +++ b/script/install-gcc-src/customize.py @@ -13,6 +13,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + recursion_spaces = i['recursion_spaces'] need_version = env.get('MLC_VERSION', '') @@ -20,7 +22,7 @@ def preprocess(i): return {'return': 1, 'error': 'internal problem - MLC_VERSION is not defined in env'} - print(recursion_spaces + ' # Requested version: {}'.format(need_version)) + logger.info(f"{recursion_spaces} # Requested version: {need_version}") if 'MLC_GIT_CHECKOUT' not in env: env['MLC_GIT_CHECKOUT'] = 'releases/gcc-' + need_version diff --git a/script/install-generic-conda-package/customize.py b/script/install-generic-conda-package/customize.py index 33c2ad57c..43874ae16 100644 --- a/script/install-generic-conda-package/customize.py +++ b/script/install-generic-conda-package/customize.py @@ -27,8 +27,10 @@ def preprocess(i): def detect_version(i): + logger = i['automation'].logger + # TBD - print(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/install-gflags/customize.py b/script/install-gflags/customize.py index c92d1d7af..c1437b580 100644 --- a/script/install-gflags/customize.py +++ b/script/install-gflags/customize.py @@ -13,6 +13,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + recursion_spaces = i['recursion_spaces'] need_version = env.get('MLC_VERSION', '') @@ -20,12 +22,8 @@ def preprocess(i): return {'return': 1, 'error': 'internal problem - MLC_VERSION is not defined in env'} - print(recursion_spaces + ' # Requested version: {}'.format(need_version)) + logger.info(f"{recursion_spaces} # Requested version: {need_version}") return {'return': 0} -def postprocess(i): - inp = i['input'] - env = i['env'] - return {'return': 0} diff --git a/script/install-llvm-prebuilt/customize.py b/script/install-llvm-prebuilt/customize.py index 45417febc..ce223284e 100644 --- a/script/install-llvm-prebuilt/customize.py +++ b/script/install-llvm-prebuilt/customize.py @@ -10,6 +10,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + recursion_spaces = i['recursion_spaces'] need_version = env.get('MLC_VERSION', '') @@ -18,7 +20,7 @@ def preprocess(i): return {'return': 1, 'error': 'internal problem - MLC_VERSION is not defined in env'} - print(recursion_spaces + ' # Requested version: {}'.format(need_version)) + logger.info(f"{recursion_spaces} # Requested version: {need_version}") host_os_bits = env['MLC_HOST_OS_BITS'] @@ -60,12 +62,12 @@ def preprocess(i): package_name = 'LLVM-' + need_version + '-win' + host_os_bits + '.exe' clang_file_name = "clang.exe" - print('') - print('WARNING: Please copy the following path and then paste it') - print(' when LLVM installer asks you about the "Destination Folder":') - print('') - print(os.getcwd()) - print('') + logger.info('') + logger.warning('WARNING: Please copy the following path and then paste it') + logger.info(' when LLVM installer asks you about the "Destination Folder":') + logger.info('') + logger.info(fos.getcwd()) + logger.info('') input('Press Enter to continue!') else: @@ -164,10 +166,10 @@ def preprocess(i): package_url = 'https://github.com/llvm/llvm-project/releases/download/llvmorg-' + \ need_version + '/' + package_name - print(recursion_spaces + ' # Prepared package URL: {}'.format(package_url)) + logger.info(f"{recursion_spaces} # Prepared package URL: {package_url}") - print('') - print('Downloading from {} ...'.format(package_url)) + logger.info('') + logger.info(f"Downloading from {package_url} ...") cm = automation.action_object diff --git a/script/install-openssl/customize.py b/script/install-openssl/customize.py index 208ca60f6..2e038a4d5 100644 --- a/script/install-openssl/customize.py +++ b/script/install-openssl/customize.py @@ -6,6 +6,8 @@ def preprocess(i): os_info = i['os_info'] + logger = i['automation'].logger + if os_info['platform'] == 'windows': return {'return': 1, 'error': 'Windows is not supported in this script yet'} @@ -20,28 +22,8 @@ def preprocess(i): return {'return': 1, 'error': 'internal problem - MLC_VERSION is not defined in env'} - print(recursion_spaces + ' # Requested version: {}'.format(need_version)) + logger.info(f"{recursion_spaces} # Requested version: {need_version}") return {'return': 0} -def postprocess(i): - inp = i['input'] - env = i['env'] - tags = inp['tags'] - tag_list = tags.split(",") - install_path = os.path.join( - os.getcwd(), - 'openssl-' + - env['MLC_VERSION'] + - 'g', - 'install') - path_lib = os.path.join(install_path, 'lib') - if '+LD_LIBRARY_PATH' not in env: - env['+LD_LIBRARY_PATH'] = [] - env['+LD_LIBRARY_PATH'].append(path_lib) - bin_name = "openssl" - path_bin = os.path.join(install_path, 'bin') - env['MLC_OPENSSL_INSTALLED_PATH'] = path_bin - env['MLC_OPENSSL_BIN_WITH_PATH'] = os.path.join(path_bin, bin_name) - return {'return': 0} diff --git a/script/install-python-src/customize.py b/script/install-python-src/customize.py index cf5f95f88..37ac091c8 100644 --- a/script/install-python-src/customize.py +++ b/script/install-python-src/customize.py @@ -6,6 +6,8 @@ def preprocess(i): os_info = i['os_info'] + logger = i['automation'].logger + if os_info['platform'] == 'windows': return {'return': 1, 'error': 'Windows is not supported in this script yet'} @@ -20,7 +22,7 @@ def preprocess(i): return {'return': 1, 'error': 'internal problem - MLC_VERSION is not defined in env'} - print(recursion_spaces + ' # Requested version: {}'.format(need_version)) + logger.info(f"{recursion_spaces} # Requested version: {need_version}") path_bin = os.path.join(os.getcwd(), 'install', 'bin') diff --git a/script/install-python-venv/customize.py b/script/install-python-venv/customize.py index 79dd031f0..7929e3c96 100644 --- a/script/install-python-venv/customize.py +++ b/script/install-python-venv/customize.py @@ -15,6 +15,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + recursion_spaces = i['recursion_spaces'] # Add extra tags to python @@ -23,7 +25,7 @@ def preprocess(i): name = env.get('MLC_NAME', '') if not quiet and name == '': - print('') + logger.info('') x = input( 'Enter some tag to describe this virtual env (mlperf-inf,octoml-bench,etc): ') x = x.strip() diff --git a/script/install-rapidjson-from-src/customize.py b/script/install-rapidjson-from-src/customize.py index 300164858..a587d715b 100644 --- a/script/install-rapidjson-from-src/customize.py +++ b/script/install-rapidjson-from-src/customize.py @@ -18,5 +18,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - return {'return': 0} diff --git a/script/install-torchvision-from-src/customize.py b/script/install-torchvision-from-src/customize.py index 300164858..a587d715b 100644 --- a/script/install-torchvision-from-src/customize.py +++ b/script/install-torchvision-from-src/customize.py @@ -18,5 +18,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - return {'return': 0} diff --git a/script/plug-prebuilt-cudnn-to-cuda/customize.py b/script/plug-prebuilt-cudnn-to-cuda/customize.py index c37d15b17..9c2939a0f 100644 --- a/script/plug-prebuilt-cudnn-to-cuda/customize.py +++ b/script/plug-prebuilt-cudnn-to-cuda/customize.py @@ -18,6 +18,8 @@ def preprocess(i): meta = i['meta'] automation = i['automation'] + logger = automation.logger + version = env.get('MLC_VERSION') supported_versions = list(meta['versions'].keys()) @@ -42,8 +44,8 @@ def preprocess(i): cudnn_url = f'https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/{filename}' - print('') - print(f'URL to download cuDNN: {cudnn_url}') + logger.info('') + logger.info(f'URL to download cuDNN: {cudnn_url}') env['MLC_CUDNN_TAR_DIR'] = cudnn_dir env['MLC_CUDNN_UNTAR_PATH'] = os.path.join(cur_dir, cudnn_dir) diff --git a/script/plug-prebuilt-cusparselt-to-cuda/customize.py b/script/plug-prebuilt-cusparselt-to-cuda/customize.py index ec679ac7d..d5564c0a8 100644 --- a/script/plug-prebuilt-cusparselt-to-cuda/customize.py +++ b/script/plug-prebuilt-cusparselt-to-cuda/customize.py @@ -18,6 +18,8 @@ def preprocess(i): meta = i['meta'] automation = i['automation'] + logger = automation.logger + version = env.get('MLC_VERSION') supported_versions = list(meta['versions'].keys()) @@ -42,8 +44,8 @@ def preprocess(i): cusparselt_url = f'https://developer.download.nvidia.com/compute/cusparselt/redist/libcusparse_lt/linux-x86_64/{filename}' - print('') - print(f'URL to download CUSPARSELT: {cusparselt_url}') + logger.info('') + logger.info(f'URL to download CUSPARSELT: {cusparselt_url}') env['MLC_CUSPARSELT_TAR_DIR'] = cusparselt_dir env['MLC_CUSPARSELT_UNTAR_PATH'] = os.path.join(cur_dir, cusparselt_dir) diff --git a/script/preprocess-mlperf-inference-submission/customize.py b/script/preprocess-mlperf-inference-submission/customize.py index a394b4446..788f8aabc 100644 --- a/script/preprocess-mlperf-inference-submission/customize.py +++ b/script/preprocess-mlperf-inference-submission/customize.py @@ -9,15 +9,17 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger + submission_dir = env.get("MLC_MLPERF_INFERENCE_SUBMISSION_DIR", "") if submission_dir == "": - print("Please set --env.MLC_MLPERF_INFERENCE_SUBMISSION_DIR") + logger.error("Please set --env.MLC_MLPERF_INFERENCE_SUBMISSION_DIR") return {'return': 1, 'error': 'MLC_MLPERF_INFERENCE_SUBMISSION_DIR is not specified'} if not os.path.exists(submission_dir): - print("Please set --env.MLC_MLPERF_INFERENCE_SUBMISSION_DIR to a valid submission directory") + logger.error("Please set --env.MLC_MLPERF_INFERENCE_SUBMISSION_DIR to a valid submission directory") return {'return': 1, 'error': 'MLC_MLPERF_INFERENCE_SUBMISSION_DIR is not existing'} @@ -26,7 +28,7 @@ def preprocess(i): submission_processed = f"{submission_dir}_processed" if os.path.exists(submission_processed): - print(f"Cleaning {submission_processed}") + logger.info(f"Cleaning {submission_processed}") shutil.rmtree(submission_processed) version = env.get('MLC_MLPERF_SUBMISSION_CHECKER_VERSION', '') diff --git a/script/process-mlperf-accuracy/customize.py b/script/process-mlperf-accuracy/customize.py index 967fde0b5..4ef3fbd43 100644 --- a/script/process-mlperf-accuracy/customize.py +++ b/script/process-mlperf-accuracy/customize.py @@ -9,10 +9,12 @@ def preprocess(i): xsep = ';' if os_info['platform'] == 'windows' else ':' env = i['env'] + logger = i['automation'].logger + results_dir = env.get("MLC_MLPERF_ACCURACY_RESULTS_DIR", "") if results_dir == "": - print("Please set MLC_MLPERF_ACCURACY_RESULTS_DIR") + logger.error("Please set MLC_MLPERF_ACCURACY_RESULTS_DIR") return {'return': -1} # In fact, we expect only 1 command line here @@ -229,7 +231,7 @@ def postprocess(i): os_info = i['os_info'] env = i['env'] state = i['state'] - + logger = i['automation'].logger xsep = ';' if os_info['platform'] == 'windows' else ':' results_dir = env.get("MLC_MLPERF_ACCURACY_RESULTS_DIR", "") @@ -240,16 +242,16 @@ def postprocess(i): accuracy_file = os.path.join(result_dir, "accuracy.txt") if os.path.exists(accuracy_file): - print('') - print('Accuracy file: {}'.format(accuracy_file)) - print('') + logger.info('') + logger.info('Accuracy file: {}'.format(accuracy_file)) + logger.info('') x = '' with open(accuracy_file, "r") as fp: x = fp.read() if x != '': - print(x) + logger.info(f"{x}") # Trying to extract accuracy dict for y in x.split('\n'): @@ -265,5 +267,5 @@ def postprocess(i): except ValueError as e: pass - print('') + logger.info('') return {'return': 0} diff --git a/script/prune-bert-models/customize.py b/script/prune-bert-models/customize.py index 9928625f5..e69cde689 100644 --- a/script/prune-bert-models/customize.py +++ b/script/prune-bert-models/customize.py @@ -8,6 +8,8 @@ def preprocess(i): env = i['env'] + logger = i['automation'].logger + ckpt_path = env.get('MLC_BERT_PRUNE_CKPT_PATH', '') if ckpt_path == '': p = env['MLC_ML_MODEL_FILE_WITH_PATH'] @@ -29,17 +31,17 @@ def preprocess(i): out_dir = os.path.join(os.getcwd(), 'pruned-model-output') env['MLC_BERT_PRUNE_OUTPUT_DIR'] = out_dir - print('') + logger.info('') print( 'Local CM cache path to the updated BERT pruner src from NeurIPS 2022: ' + env['MLC_GIT_REPO_BERT_PRUNER_NEURIPS_2022_CHECKOUT_PATH']) - print('') + logger.info('') for k in ["MLC_ML_MODEL_FILE_WITH_PATH", "MLC_BERT_PRUNE_CKPT_PATH", "MLC_BERT_PRUNE_OUTPUT_DIR"]: - print('ENV["{}"]: {}'.format(k, env[k])) + logger.info(f"ENV[\"{k}\"]: {env[k]}") - print('') + logger.info('') return {'return': 0} @@ -48,6 +50,8 @@ def postprocess(i): env = i['env'] - print("Entered postprocess") + logger = i['automation'].logger + + logger.info("Entered postprocess") return {'return': 0} diff --git a/script/push-csv-to-spreadsheet/customize.py b/script/push-csv-to-spreadsheet/customize.py index e3a082660..8008bf918 100644 --- a/script/push-csv-to-spreadsheet/customize.py +++ b/script/push-csv-to-spreadsheet/customize.py @@ -12,5 +12,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - return {'return': 0} diff --git a/script/push-mlperf-inference-results-to-github/customize.py b/script/push-mlperf-inference-results-to-github/customize.py index d056eec77..fc7057ed1 100644 --- a/script/push-mlperf-inference-results-to-github/customize.py +++ b/script/push-mlperf-inference-results-to-github/customize.py @@ -44,5 +44,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - return {'return': 0} diff --git a/script/run-all-mlperf-models/customize.py b/script/run-all-mlperf-models/customize.py index 9bfdc51f9..c9b6f68fa 100644 --- a/script/run-all-mlperf-models/customize.py +++ b/script/run-all-mlperf-models/customize.py @@ -13,7 +13,7 @@ def preprocess(i): script_path = i['run_script_input']['path'] automation = i['automation'] - + logger = automation.logger quiet = is_true(env.get('MLC_QUIET', False)) models = env['MODELS'].split(",") @@ -26,7 +26,7 @@ def preprocess(i): if devices: devices = devices.split(",") - print(backends) + logger.info(f"BACKENDS: {backends}") implementation = env['IMPLEMENTATION'] power = env.get('POWER', '') @@ -101,7 +101,7 @@ def preprocess(i): run_script_content += "\n\n" + "\n\n".join(cmds) with open(os.path.join(script_path, run_file_name + ".sh"), 'w') as f: f.write(run_script_content) - print(cmds) + logger.info(f"CMDS: {cmds}") return {'return': 0} diff --git a/script/run-docker-container/customize.py b/script/run-docker-container/customize.py index c636f4fa7..62eb7f535 100644 --- a/script/run-docker-container/customize.py +++ b/script/run-docker-container/customize.py @@ -14,6 +14,8 @@ def preprocess(i): mlc = i['automation'].action_object + logger = i['automation'].logger + interactive = env.get('MLC_DOCKER_INTERACTIVE_MODE', '') if is_true(interactive): @@ -51,9 +53,9 @@ def preprocess(i): DOCKER_CONTAINER = docker_image_repo + "/" + \ docker_image_name + ":" + docker_image_tag - print('') - print('Checking existing Docker container:') - print('') + logger.info('') + logger.info('Checking existing Docker container:') + logger.info('') # CMD = f"""{env['MLC_CONTAINER_TOOL']} ps --format=json --filter "ancestor={DOCKER_CONTAINER}" """ CMD = f"""{env['MLC_CONTAINER_TOOL']} ps --format """ + \ '"{{ .ID }},"' + f""" --filter "ancestor={DOCKER_CONTAINER}" """ @@ -61,8 +63,8 @@ def preprocess(i): CMD += " 2> nul" else: CMD += " 2> /dev/null" - print(' ' + CMD) - print('') + logger.info(' ' + CMD) + logger.info('') try: out = subprocess.check_output( @@ -81,7 +83,7 @@ def preprocess(i): if existing_container_id and is_true( env.get('MLC_DOCKER_REUSE_EXISTING_CONTAINER', '')): - print(f"Reusing existing container {existing_container_id}") + logger.info(f"Reusing existing container {existing_container_id}") env['MLC_DOCKER_CONTAINER_ID'] = existing_container_id else: @@ -89,7 +91,7 @@ def preprocess(i): print( f"""Not using existing container {existing_container_id} as env['MLC_DOCKER_REUSE_EXISTING_CONTAINER'] is not set""") else: - print("No existing container") + logger.info("No existing container") if env.get('MLC_DOCKER_CONTAINER_ID', '') != '': del (env['MLC_DOCKER_CONTAINER_ID']) # not valid ID @@ -100,11 +102,11 @@ def preprocess(i): else: CMD += " 2> /dev/null" - print('') - print('Checking Docker images:') - print('') - print(' ' + CMD) - print('') + logger.info('') + logger.info('Checking Docker images:') + logger.info('') + logger.info(' ' + CMD) + logger.info('') try: docker_image = subprocess.check_output( @@ -117,7 +119,7 @@ def preprocess(i): if is_false(recreate_image): if docker_image: - print("Docker image exists with ID: " + docker_image) + logger.info("Docker image exists with ID: " + docker_image) env['MLC_DOCKER_IMAGE_EXISTS'] = "yes" # elif recreate_image == "yes": @@ -131,6 +133,8 @@ def postprocess(i): env = i['env'] + logger = i['automation'].logger + # Updating Docker info update_docker_info(env) @@ -258,11 +262,11 @@ def postprocess(i): CMD += ' && echo "ID=$ID"' - print('=========================') - print("Container launch command:") - print('') - print(CMD) - print('') + logger.info('=========================') + logger.info("Container launch command:") + logger.info('') + logger.info(f"{CMD}") + logger.info('') print( "Running " + run_cmd + @@ -270,7 +274,7 @@ def postprocess(i): record_script({'cmd': CMD, 'env': env}) - print('') + logger.info('') # Execute the command try: result = subprocess.run( @@ -280,12 +284,12 @@ def postprocess(i): stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - print("Command Output:", result.stdout) + logger.info("Command Output:", result.stdout) except subprocess.CalledProcessError as e: - print("Error Occurred!") - print(f"Command: {e.cmd}") - print(f"Return Code: {e.returncode}") - print(f"Error Output: {e.stderr}") + logger.error("Error Occurred!") + logger.info(f"Command: {e.cmd}") + logger.info(f"Return Code: {e.returncode}") + logger.error(f"Error Output: {e.stderr}") return {'return': 1, 'error': e.stderr} docker_out = result.stdout @@ -300,7 +304,7 @@ def postprocess(i): ID = line[3:] env['MLC_DOCKER_CONTAINER_ID'] = ID - print(docker_out) + logger.info(f"{docker_out}") else: x = "'" @@ -319,14 +323,14 @@ def postprocess(i): " " + docker_image_repo + "/" + docker_image_name + ":" + docker_image_tag CMD = CONTAINER + " bash -c " + x + run_cmd_prefix + run_cmd + x2 + x - print('') - print("Container launch command:") - print('') - print(CMD) + logger.info('') + logger.info("Container launch command:") + logger.info('') + logger.info(f"{CMD}") record_script({'cmd': CMD, 'env': env}) - print('') + logger.info('') docker_out = os.system(CMD) if docker_out != 0: if docker_out % 256 == 0: diff --git a/script/run-mlperf-automotive-app/customize.py b/script/run-mlperf-automotive-app/customize.py index 9309390a6..c828776c5 100644 --- a/script/run-mlperf-automotive-app/customize.py +++ b/script/run-mlperf-automotive-app/customize.py @@ -21,6 +21,7 @@ def preprocess(i): state = i['state'] script_path = i['run_script_input']['path'] mlc = i['automation'].action_object + logger = i['automation'].logger if is_true(env.get('MLC_RUN_DOCKER_CONTAINER', '')): return {'return': 0} @@ -191,12 +192,12 @@ def preprocess(i): if clean: path_to_clean = output_dir - print('=========================================================') - print('Cleaning results in {}'.format(path_to_clean)) + logger.info('=========================================================') + logger.info('Cleaning results in {}'.format(path_to_clean)) if os.path.exists(path_to_clean): shutil.rmtree(path_to_clean) - print('=========================================================') + logger.info('=========================================================') if is_true(str(env.get('MLC_MLPERF_USE_DOCKER', ''))): action = "docker" @@ -242,7 +243,7 @@ def preprocess(i): "MLC_TMP_"): del env_copy[key] - print(f"\nRunning loadgen scenario: {scenario} and mode: {mode}") + logger.info(f"\nRunning loadgen scenario: {scenario} and mode: {mode}") ii = {'action': action, 'automation': 'script', 'tags': scenario_tags, 'quiet': 'true', 'env': env_copy, 'input': inp, 'state': state, 'add_deps': copy.deepcopy(add_deps), 'add_deps_recursive': copy.deepcopy(add_deps_recursive), 'ad': ad, 'adr': copy.deepcopy(adr), 'v': verbose, 'print_env': print_env, 'print_deps': print_deps, 'dump_version_info': dump_version_info} @@ -293,10 +294,10 @@ def preprocess(i): # executing CM import mlperf_utils # noqa - print(sut) + logger.info(f"{sut}") result_table, headers = mlperf_utils.get_result_table( state["mlc-mlperf-inference-results"][sut]) - print(tabulate(result_table, headers=headers, tablefmt="pretty")) + logger.info(f"{tabulate(result_table, headers=headers, tablefmt='pretty')}") print( f"\nThe MLPerf inference results are stored at {output_dir}\n") @@ -348,18 +349,18 @@ def postprocess(i): env = i['env'] state = i['state'] - + logger = i['automation'].logger if env.get('MLC_MLPERF_IMPLEMENTATION', '') == 'reference': x1 = env.get('MLC_MLPERF_INFERENCE_SOURCE', '') x2 = env.get('MLC_MLPERF_INFERENCE_CONF_PATH', '') if x1 != '' and x2 != '': - print('') + logger.info('') print( 'Path to the MLPerf inference benchmark reference sources: {}'.format(x1)) print( 'Path to the MLPerf inference reference configuration file: {}'.format(x2)) - print('') + logger.info('') return {'return': 0} diff --git a/script/run-mlperf-inference-app/customize.py b/script/run-mlperf-inference-app/customize.py index 2e9c279d2..7adc3638f 100644 --- a/script/run-mlperf-inference-app/customize.py +++ b/script/run-mlperf-inference-app/customize.py @@ -21,7 +21,7 @@ def preprocess(i): inp = i['input'] state = i['state'] script_path = i['run_script_input']['path'] - + logger = i['automation'].logger if is_true(env.get('MLC_RUN_DOCKER_CONTAINER', '')): return {'return': 0} @@ -215,12 +215,12 @@ def preprocess(i): if clean: path_to_clean = output_dir - print('=========================================================') - print('Cleaning results in {}'.format(path_to_clean)) + logger.info('=========================================================') + logger.info('Cleaning results in {}'.format(path_to_clean)) if os.path.exists(path_to_clean): shutil.rmtree(path_to_clean) - print('=========================================================') + logger.info('=========================================================') if is_true(env.get('MLC_MLPERF_USE_DOCKER', '')): action = "docker" @@ -270,7 +270,7 @@ def preprocess(i): env_copy = copy.deepcopy(env) const_copy = copy.deepcopy(const) - print(f"\nRunning loadgen scenario: {scenario} and mode: {mode}") + logger.info(f"\nRunning loadgen scenario: {scenario} and mode: {mode}") ii = {'action': action, 'automation': 'script', 'tags': scenario_tags, 'quiet': 'true', 'env': env_copy, 'const': const_copy, 'input': inp, 'state': state, 'add_deps': copy.deepcopy(add_deps), 'add_deps_recursive': copy.deepcopy(add_deps_recursive), 'ad': ad, 'adr': copy.deepcopy(adr), 'print_env': print_env, 'print_deps': print_deps, 'dump_version_info': dump_version_info} @@ -335,10 +335,10 @@ def preprocess(i): # executing CM from tabulate import tabulate # noqa - print(sut) + logger.info(f"{sut}") result_table, headers = mlperf_utils.get_result_table( state["mlc-mlperf-inference-results"][sut]) - print(tabulate(result_table, headers=headers, tablefmt="pretty")) + logger.info(f"{tabulate(result_table, headers=headers, tablefmt='pretty')}") print( f"\nThe MLPerf inference results are stored at {output_dir}\n") @@ -390,18 +390,18 @@ def postprocess(i): env = i['env'] state = i['state'] - + logger = i['automation'].logger if env.get('MLC_MLPERF_IMPLEMENTATION', '') == 'reference': x1 = env.get('MLC_MLPERF_INFERENCE_SOURCE', '') x2 = env.get('MLC_MLPERF_INFERENCE_CONF_PATH', '') if x1 != '' and x2 != '': - print('') + logger.info('') print( 'Path to the MLPerf inference benchmark reference sources: {}'.format(x1)) print( 'Path to the MLPerf inference reference configuration file: {}'.format(x2)) - print('') + logger.info('') return {'return': 0} diff --git a/script/run-mlperf-inference-mobilenet-models/customize.py b/script/run-mlperf-inference-mobilenet-models/customize.py index ee9ba88d8..341efd37d 100644 --- a/script/run-mlperf-inference-mobilenet-models/customize.py +++ b/script/run-mlperf-inference-mobilenet-models/customize.py @@ -19,6 +19,7 @@ def preprocess(i): adr = i['input'].get('adr') automation = i['automation'] + logger = automation.logger # mlc = i['automation'].action_object # cache_action = i['automation'].cache_action cache_action = mlc @@ -189,7 +190,7 @@ def preprocess(i): if is_true(env.get('MLC_MLPERF_POWER', '')): mlc_input['power'] = 'yes' - print(mlc_input) + logger.info(f"{mlc_input}") r = mlc.access(mlc_input) if r['return'] > 0: return r @@ -198,7 +199,7 @@ def preprocess(i): if is_true(env.get('MLC_MINIMIZE_DISK_USAGE', '')): r = cache_action.access(clean_input) if r['return'] > 0: - print(r) + logger.info(f"{r}") # return r else: importlib.reload(mlc.action) @@ -209,7 +210,7 @@ def preprocess(i): ''' r = cache_action.access(clean_input) if r['return'] > 0: - print(r) + logger.info(fr) # return r else: importlib.reload(mlc.action) diff --git a/script/run-mlperf-inference-submission-checker/customize.py b/script/run-mlperf-inference-submission-checker/customize.py index 6dcd5e1cf..a23bf2947 100644 --- a/script/run-mlperf-inference-submission-checker/customize.py +++ b/script/run-mlperf-inference-submission-checker/customize.py @@ -8,6 +8,7 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger q = '"' if os_info['platform'] == 'windows' else "'" submission_dir = env.get("MLC_MLPERF_INFERENCE_SUBMISSION_DIR", "") @@ -84,7 +85,7 @@ def preprocess(i): report_generator_file = os.path.join(env['MLC_MLPERF_INFERENCE_SOURCE'], "tools", "submission", "generate_final_report.py") env['MLC_RUN_CMD'] = CMD - print(CMD) + logger.info(f"{CMD}") env['MLC_POST_RUN_CMD'] = env['MLC_PYTHON_BIN_WITH_PATH'] + ' ' + q + report_generator_file + q + ' --input summary.csv ' + \ x_version + \ x_submission_repo_name + \ diff --git a/script/run-mlperf-power-client/customize.py b/script/run-mlperf-power-client/customize.py index f7d3cd989..312fb7ecb 100644 --- a/script/run-mlperf-power-client/customize.py +++ b/script/run-mlperf-power-client/customize.py @@ -42,5 +42,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - return {'return': 0} diff --git a/script/run-mlperf-power-server/customize.py b/script/run-mlperf-power-server/customize.py index e4117c93d..78bdcfbba 100644 --- a/script/run-mlperf-power-server/customize.py +++ b/script/run-mlperf-power-server/customize.py @@ -7,7 +7,7 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] - + logger = i['automation'].logger # Initialize ConfigParser config = configparser.ConfigParser() @@ -66,7 +66,7 @@ def preprocess(i): with open('tmp-power-server.conf', 'w') as configfile: config.write(configfile) - print({section: dict(config[section]) for section in config.sections()}) + logger.info(f"{section: dict(config[section]) for section in config.sections()}") if env['MLC_HOST_OS_TYPE'] == "windows": cmd_prefix = "" @@ -87,5 +87,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - return {'return': 0} diff --git a/script/run-terraform/customize.py b/script/run-terraform/customize.py index 15687e6a9..77faca003 100644 --- a/script/run-terraform/customize.py +++ b/script/run-terraform/customize.py @@ -8,6 +8,7 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger script_dir = i['run_script_input']['path'] config_dir = os.path.join( script_dir, env.get( @@ -15,7 +16,7 @@ def preprocess(i): env['MLC_TERRAFORM_CONFIG_DIR'] = config_dir cache_dir = os.getcwd() - print(f"Running terraform from {cache_dir}") + logger.info(f"Running terraform from {cache_dir}") shutil.copy(os.path.join(config_dir, "main.tf"), cache_dir) env['MLC_TERRAFORM_RUN_DIR'] = cache_dir @@ -24,6 +25,7 @@ def preprocess(i): def postprocess(i): + logger = i["automation"].logger env = i['env'] if env.get('MLC_DESTROY_TERRAFORM'): return {'return': 0} @@ -85,6 +87,3 @@ def postprocess(i): return {'return': 0} -def print_attr(instance_attributes, key): - if key in instance_attributes: - print(key.upper() + ": " + str(instance_attributes[key])) diff --git a/script/run-vllm-server/customize.py b/script/run-vllm-server/customize.py index 68eceb84d..b82e3219a 100644 --- a/script/run-vllm-server/customize.py +++ b/script/run-vllm-server/customize.py @@ -10,8 +10,11 @@ def preprocess(i): meta = i['meta'] automation = i['automation'] - # Required parameter check - model_name = env.get("MLC_VLLM_SERVER_MODEL_NAME") + logger = automation.logger + + cmd_args = "" + + model_name = env.get("MLC_VLLM_SERVER_MODEL_NAME", False) if not model_name: return {'return': 1, 'error': 'Model name not specified'} @@ -93,7 +96,7 @@ def preprocess(i): cmd_args += f" {arg_name}" cmd = f"{env['MLC_PYTHON_BIN_WITH_PATH']} -m vllm.entrypoints.openai.api_server {cmd_args}" - print(cmd) + logger.info(f"{cmd}") env['MLC_VLLM_RUN_CMD'] = cmd diff --git a/script/runtime-system-infos/customize.py b/script/runtime-system-infos/customize.py index b54abbdac..877b87141 100644 --- a/script/runtime-system-infos/customize.py +++ b/script/runtime-system-infos/customize.py @@ -36,6 +36,7 @@ def preprocess(i): return {'return': 1, 'error': 'Windows is not supported in this script yet'} env = i['env'] + logger = i['automation'].logger if env.get("MLC_RUN_DIR", "") == "": env['MLC_RUN_DIR'] = os.getcwd() @@ -46,11 +47,11 @@ def preprocess(i): interval = int(env.get('MLC_SYSTEM_INFO_MEASUREMENT_INTERVAL', '2')) - print(f"The system dumps are created to the folder:{logs_dir}") + logger.info(f"The system dumps are created to the folder:{logs_dir}") - print("WARNING: Currently the script is in its development stage. Only memory measurements supports as of now!") + logger.warning("Currently the script is in its development stage. Only memory measurements supports as of now!") - print("Started measuring system info!") + logger.info("Started measuring system info!") csv_headers = [ 'timestamp', diff --git a/script/set-venv/customize.py b/script/set-venv/customize.py index f1e0f726b..ee6da6e58 100644 --- a/script/set-venv/customize.py +++ b/script/set-venv/customize.py @@ -13,6 +13,8 @@ def preprocess(i): automation = i['automation'] + logger = automation.logger + quiet = is_true(env.get('MLC_QUIET', False)) ############################################################ @@ -49,9 +51,9 @@ def preprocess(i): cmd = python_path + ' -m venv ' + name + create_dir.format(name) - print('====================================================================') + logger.info('====================================================================') - print('Creating venv: "{}" ...'.format(cmd)) + logger.info('Creating venv: "{}" ...'.format(cmd)) os.system(cmd) if os.path.isfile(activate_script2): @@ -86,11 +88,11 @@ def preprocess(i): with open(script_file, 'w') as f: f.write(cmd) - print('====================================================================') - print('Please run the following command:') - print('') - print(xcmd) - print('====================================================================') + logger.info('====================================================================') + logger.info('Please run the following command:') + logger.info('') + logger.info(f"{xcmd}") + logger.info('====================================================================') return {'return': 0} diff --git a/script/submit-mlperf-results/customize.py b/script/submit-mlperf-results/customize.py index ae5824af2..40f3d8777 100644 --- a/script/submit-mlperf-results/customize.py +++ b/script/submit-mlperf-results/customize.py @@ -10,7 +10,7 @@ def preprocess(i): env = i['env'] meta = i['meta'] automation = i['automation'] - + logger = automation.logger server = env['MLC_MLPERF_SUBMISSION_URL'] benchmark = env['MLC_MLPERF_BENCHMARK'] submitter_id = env['MLC_MLPERF_SUBMITTER_ID'] @@ -39,12 +39,12 @@ def preprocess(i): # print(signed_url) # print(submission_id) - r = upload_file_to_signed_url(file_path, signed_url) + r = upload_file_to_signed_url(file_path, signed_url, logger) if r['return'] > 0: return r r = trigger_submission_checker( - server, submitter_id, benchmark, submission_id) + server, submitter_id, benchmark, submission_id, logger) if r['return'] > 0: return r @@ -103,7 +103,7 @@ def get_signed_url(server, benchmark, submitter_id, submitter_name, file_path): 'submission_id': submission_id} -def upload_file_to_signed_url(file_path, signed_url): +def upload_file_to_signed_url(file_path, signed_url, logger): """ Uploads a file to a signed URL using HTTP PUT. @@ -129,14 +129,14 @@ def upload_file_to_signed_url(file_path, signed_url): ) if response.status_code in [200, 201, 204]: - print("File uploaded successfully!") + logger.info("File uploaded successfully!") return { 'return': 0 } else: print( f"Failed to upload file. Status code: {response.status_code}") - print("Response:", response.text) + logger.info("Response:", response.text) return { 'return': response.status_code, @@ -144,14 +144,14 @@ def upload_file_to_signed_url(file_path, signed_url): } except FileNotFoundError: - print("Error: File not found.") + logger.error("Error: File not found.") return { 'return': 400, 'error': f'''File {file_path} not found''' } except requests.exceptions.RequestException as e: - print(f"Request failed: {e}") + logger.error(f"Request failed: {e}") return { 'return': 500, 'error': str(e) @@ -159,7 +159,7 @@ def upload_file_to_signed_url(file_path, signed_url): def trigger_submission_checker( - server_url, submitter_id, benchmark, submission_id): + server_url, submitter_id, benchmark, submission_id, logger): """ Sends a POST request with URL-encoded form data. @@ -187,12 +187,12 @@ def trigger_submission_checker( response = requests.post(url, data=payload, headers=headers) if response.ok: - print("Submission Check Request successful!") + logger.info("Submission Check Request successful!") pass else: - print( + logger.error( f"Submission Check Request failed with status code: {response.status_code}") - print("Response:", response.text) + logger.error("Response:", response.text) return { "return": 0, @@ -200,12 +200,10 @@ def trigger_submission_checker( } except requests.exceptions.RequestException as e: - print("An error occurred:", e) + logger.error("An error occurred:", e) return { "return": 500, "error": str(e) } -def postprocess(i): - return {'return': 0} diff --git a/script/tar-my-folder/customize.py b/script/tar-my-folder/customize.py index a8407ff2c..0ce726cdd 100644 --- a/script/tar-my-folder/customize.py +++ b/script/tar-my-folder/customize.py @@ -8,6 +8,7 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger input_dir = env.get("MLC_TAR_INPUT_DIR", "") if input_dir == "": return {'return': 1, 'error': 'Please set MLC_TAR_INPUT_DIR'} @@ -39,8 +40,8 @@ def preprocess(i): str(cd_dir) + ' -czf ' + os.path.join(output_dir, output_file) + ' ' + input_dirname - print(CMD) + logger.info(f"{CMD}") ret = os.system(CMD) - print("Tar file " + os.path.join(output_dir, output_file) + " created") + logger.info(f"Tar file {os.path.join(output_dir, output_file)} created") return {'return': ret} diff --git a/script/truncate-mlperf-inference-accuracy-log/customize.py b/script/truncate-mlperf-inference-accuracy-log/customize.py index 3e609188f..abe20dcdb 100644 --- a/script/truncate-mlperf-inference-accuracy-log/customize.py +++ b/script/truncate-mlperf-inference-accuracy-log/customize.py @@ -8,10 +8,11 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] + logger = i['automation'].logger submission_dir = env.get("MLC_MLPERF_INFERENCE_SUBMISSION_DIR", "") if submission_dir == "": - print("Please set MLC_MLPERF_INFERENCE_SUBMISSION_DIR") + logger.error("Please set MLC_MLPERF_INFERENCE_SUBMISSION_DIR") return {'return': 1, 'error': 'MLC_MLPERF_INFERENCE_SUBMISSION_DIR is not specified in env in run-mlperf-accuracy-log-truncator'} submitter = env.get("MLC_MLPERF_SUBMITTER", "CTuning") diff --git a/script/wrapper-reproduce-octoml-tinyml-submission/customize.py b/script/wrapper-reproduce-octoml-tinyml-submission/customize.py index 27907b617..19a5a669c 100644 --- a/script/wrapper-reproduce-octoml-tinyml-submission/customize.py +++ b/script/wrapper-reproduce-octoml-tinyml-submission/customize.py @@ -39,5 +39,3 @@ def preprocess(i): return {'return': 0} -def postprocess(i): - return {'return': 0} From 24252161d274279c6f5cbd1ec54c334714f63ffa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 24 Apr 2025 12:42:02 +0000 Subject: [PATCH 2/4] [Automated Commit] Format Codebase [skip ci] --- .../customize.py | 9 ++++++--- script/app-mlperf-inference/customize.py | 3 ++- script/benchmark-program/customize.py | 3 ++- script/compile-program/customize.py | 3 ++- script/detect-sudo/customize.py | 15 ++++++++++----- script/download-file/customize.py | 3 ++- .../customize.py | 16 ++++++++++++---- .../customize.py | 16 ++++++++++++---- script/get-aocc/customize.py | 4 +++- script/get-aria2/customize.py | 4 +++- script/get-aws-cli/customize.py | 4 +++- script/get-bazel/customize.py | 4 +++- script/get-cl/customize.py | 4 +++- script/get-cmake/customize.py | 4 +++- script/get-conda/customize.py | 4 +++- script/get-cuda/customize.py | 10 +++++++--- script/get-cudnn/customize.py | 3 ++- .../get-dataset-cognata-mlcommons/customize.py | 6 ++++-- .../get-dlrm-data-mlperf-inference/customize.py | 9 ++++++--- script/get-docker/customize.py | 6 ++++-- script/get-gcc/customize.py | 4 +++- script/get-github-cli/customize.py | 4 +++- script/get-go/customize.py | 4 +++- script/get-huggingface-cli/customize.py | 4 +++- script/get-java/customize.py | 4 +++- script/get-javac/customize.py | 4 +++- script/get-llvm/customize.py | 6 ++++-- .../get-ml-model-retinanet-nvidia/customize.py | 2 -- script/get-openssl/customize.py | 4 +++- script/get-python3/customize.py | 4 +++- script/get-qaic-apps-sdk/customize.py | 4 +++- script/get-qaic-platform-sdk/customize.py | 4 +++- script/get-rclone/customize.py | 7 +++++-- script/get-rocm/customize.py | 4 +++- script/get-sys-utils-cm/customize.py | 9 ++++++--- script/get-terraform/customize.py | 4 +++- script/install-diffusers-from-src/customize.py | 2 -- .../install-generic-conda-package/customize.py | 4 +++- script/install-gflags/customize.py | 2 -- script/install-llvm-prebuilt/customize.py | 6 ++++-- script/install-openssl/customize.py | 2 -- script/install-rapidjson-from-src/customize.py | 2 -- script/install-torchvision-from-src/customize.py | 2 -- .../customize.py | 3 ++- script/push-csv-to-spreadsheet/customize.py | 2 -- .../customize.py | 2 -- script/run-mlperf-automotive-app/customize.py | 6 ++++-- script/run-mlperf-inference-app/customize.py | 6 ++++-- script/run-mlperf-power-client/customize.py | 2 -- script/run-mlperf-power-server/customize.py | 5 ++--- script/run-terraform/customize.py | 2 -- script/runtime-system-infos/customize.py | 3 ++- script/set-venv/customize.py | 9 ++++++--- script/submit-mlperf-results/customize.py | 2 -- .../customize.py | 2 -- 55 files changed, 170 insertions(+), 96 deletions(-) diff --git a/script/app-mlperf-inference-mlcommons-cpp/customize.py b/script/app-mlperf-inference-mlcommons-cpp/customize.py index 6ca58e3bc..36b13cd7c 100644 --- a/script/app-mlperf-inference-mlcommons-cpp/customize.py +++ b/script/app-mlperf-inference-mlcommons-cpp/customize.py @@ -14,9 +14,12 @@ def preprocess(i): logger = i['automation'].logger if os_info['platform'] == 'windows': - logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') - logger.warning('This script was not thoroughly tested on Windows and compilation may fail - please help us test and improve it!') - logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') + logger.info( + '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') + logger.warning( + 'This script was not thoroughly tested on Windows and compilation may fail - please help us test and improve it!') + logger.info( + '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') # # Currently support only LLVM on Windows # print ('# Forcing LLVM on Windows') # r = automation.update_deps({'deps':meta['post_deps'], 'update_deps':{'compile-program': {'adr':{'compiler':{'tags':'llvm'}}}}}) diff --git a/script/app-mlperf-inference/customize.py b/script/app-mlperf-inference/customize.py index 3a2c0cf57..5eb368fb1 100644 --- a/script/app-mlperf-inference/customize.py +++ b/script/app-mlperf-inference/customize.py @@ -540,7 +540,8 @@ def postprocess(i): data = file.read().replace('\n', '\t') if 'TEST PASS' not in data: - logger.warning("\nDeterministic TEST01 failed... Trying with non-determinism.\n") + logger.warning( + "\nDeterministic TEST01 failed... Trying with non-determinism.\n") # #Normal test failed, trying the check with non-determinism baseline_accuracy_file = os.path.join( diff --git a/script/benchmark-program/customize.py b/script/benchmark-program/customize.py index d0ce03b1d..be97afe39 100644 --- a/script/benchmark-program/customize.py +++ b/script/benchmark-program/customize.py @@ -104,7 +104,8 @@ def preprocess(i): env['MLC_POST_RUN_CMD'] = post_run_cmd # Print info - logger.info('***************************************************************************') + logger.info( + '***************************************************************************') logger.info('CM script::benchmark-program/run.sh') logger.info('') logger.info('Run Directory: {}'.format(env.get('MLC_RUN_DIR', ''))) diff --git a/script/compile-program/customize.py b/script/compile-program/customize.py index b0cad6347..82f738729 100644 --- a/script/compile-program/customize.py +++ b/script/compile-program/customize.py @@ -30,7 +30,8 @@ def preprocess(i): # If windows, need to extend it more ... if os_info['platform'] == 'windows' and env.get( 'MLC_COMPILER_FAMILY', '') != 'LLVM': - logger.warning("Compile-program script should be extended to support flags for non-LLVM compilers on Windows") + logger.warning( + "Compile-program script should be extended to support flags for non-LLVM compilers on Windows") return {'return': 0} LDFLAGS = env.get('+ LDFLAGS', []) diff --git a/script/detect-sudo/customize.py b/script/detect-sudo/customize.py index e2eae7a12..a749acd2a 100644 --- a/script/detect-sudo/customize.py +++ b/script/detect-sudo/customize.py @@ -27,7 +27,8 @@ def preprocess(i): env['MLC_SUDO'] = '' # root user does not need sudo env['MLC_SUDO_USER'] = "yes" else: - if can_execute_sudo_without_password(logger) or prompt_sudo(logger) == 0: + if can_execute_sudo_without_password( + logger) or prompt_sudo(logger) == 0: env['MLC_SUDO_USER'] = "yes" env['MLC_SUDO'] = 'sudo' @@ -70,9 +71,11 @@ def prompt_retry(logger, timeout=10, default_retry=False): # Check if we're in an interactive terminal if not sys.stdin.isatty(): if default_retry: - logger.info(f"Non-interactive environment detected. Automatically retrying.") + logger.info( + f"Non-interactive environment detected. Automatically retrying.") else: - logger.warning(f"Non-interactive environment detected. Skipping retry.") + logger.warning( + f"Non-interactive environment detected. Skipping retry.") return default_retry # Automatically use the default in non-interactive terminals print( @@ -126,12 +129,14 @@ def get_input(): def prompt_sudo(logger): - if os.geteuid() != 0 and not is_user_in_sudo_group(logger): # No sudo required for root user + if os.geteuid() != 0 and not is_user_in_sudo_group( + logger): # No sudo required for root user # Prompt for the password if not os.isatty(sys.stdin.fileno()): - logger.warning("Skipping password prompt - non-interactive terminal detected!") + logger.warning( + "Skipping password prompt - non-interactive terminal detected!") password = None else: # password = getpass.getpass("Enter password (-1 to skip): ") diff --git a/script/download-file/customize.py b/script/download-file/customize.py index 95eab3b09..2a3609e69 100644 --- a/script/download-file/customize.py +++ b/script/download-file/customize.py @@ -181,7 +181,8 @@ def preprocess(i): url = env.get('MLC_DOWNLOAD_URL' + str(i), '') if url == '': break - logger.error(f"Download from {oldurl} failed, trying from {url}") + logger.error( + f"Download from {oldurl} failed, trying from {url}") if r['return'] > 0: return r diff --git a/script/generate-mlperf-inference-submission/customize.py b/script/generate-mlperf-inference-submission/customize.py index 4cb8e03e3..05c681b20 100644 --- a/script/generate-mlperf-inference-submission/customize.py +++ b/script/generate-mlperf-inference-submission/customize.py @@ -281,7 +281,8 @@ def generate_submission(env, state, inp, submission_division, logger): else: new_res = res.replace(" ", "_") - logger.info(f"The SUT folder name for submission generation is: {new_res}") + logger.info( + f"The SUT folder name for submission generation is: {new_res}") platform_prefix = inp.get('platform_prefix', '') if platform_prefix: @@ -468,7 +469,8 @@ def generate_submission(env, state, inp, submission_division, logger): saved_system_meta_file_path = os.path.join( result_mode_path, "system_meta.json") else: - logger.error("WARNING: system_meta.json was not found in the SUT root or mode directory inside the results folder. CM is automatically creating one using the system defaults. Please modify them as required.") + logger.error( + "WARNING: system_meta.json was not found in the SUT root or mode directory inside the results folder. CM is automatically creating one using the system defaults. Please modify them as required.") if os.path.exists(saved_system_meta_file_path): with open(saved_system_meta_file_path, "r") as f: saved_system_meta = json.load(f) @@ -746,12 +748,18 @@ def postprocess(i): # if submission division is not assigned, default value would be taken in # submission_generation function if env.get('MLC_MLPERF_SUBMISSION_DIVISION', '') == '': - r = generate_submission(env, state, inp, submission_division="", logger=logger) + r = generate_submission( + env, + state, + inp, + submission_division="", + logger=logger) if r['return'] > 0: return r else: for submission_division in submission_divisions: - r = generate_submission(env, state, inp, submission_division, logger=logger) + r = generate_submission( + env, state, inp, submission_division, logger=logger) if r['return'] > 0: return r diff --git a/script/generate-mlperf-inference-user-conf/customize.py b/script/generate-mlperf-inference-user-conf/customize.py index a4114ddb8..b08f0b0fb 100644 --- a/script/generate-mlperf-inference-user-conf/customize.py +++ b/script/generate-mlperf-inference-user-conf/customize.py @@ -141,13 +141,16 @@ def preprocess(i): # if env.get("MLC_MLPERF_FIND_PERFORMANCE_MODE", '') == "yes": if metric == "target_qps": if is_true(env.get("MLC_MLPERF_FIND_PERFORMANCE_MODE", '')): - logger.info("In find performance mode: using 1 as target_qps") + logger.info( + "In find performance mode: using 1 as target_qps") else: - logger.info("No target_qps specified. Using 1 as target_qps") + logger.info( + "No target_qps specified. Using 1 as target_qps") conf[metric] = 1 if metric == "target_latency": if is_true(env.get("MLC_MLPERF_FIND_PERFORMANCE_MODE", '')): - logger.info("In find performance mode: using 0.5ms as target_latency") + logger.info( + "In find performance mode: using 0.5ms as target_latency") else: logger.info("No target_latency specified. Using default") if is_false(env.get('MLC_MLPERF_USE_MAX_DURATION', 'yes')) or is_true(env.get( @@ -289,7 +292,12 @@ def preprocess(i): else: env['MLC_MLPERF_ACCURACY_RESULTS_DIR'] = '' - run_exists = run_files_exist(log_mode, OUTPUT_DIR, required_files, env, logger) + run_exists = run_files_exist( + log_mode, + OUTPUT_DIR, + required_files, + env, + logger) if 'MLC_MLPERF_POWER' in env and env.get( 'MLC_MLPERF_SHORT_RANGING_RUN', '') != 'no' and env['MLC_MLPERF_RUN_STYLE'] == "valid" and mode == "performance": diff --git a/script/get-aocc/customize.py b/script/get-aocc/customize.py index 03bae6c3b..197877aab 100644 --- a/script/get-aocc/customize.py +++ b/script/get-aocc/customize.py @@ -81,7 +81,9 @@ def detect_version(i): return r version = r['version'] - logger.info(fi['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + fi['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-aria2/customize.py b/script/get-aria2/customize.py index f795c314b..2f7459cde 100644 --- a/script/get-aria2/customize.py +++ b/script/get-aria2/customize.py @@ -112,7 +112,9 @@ def detect_version(i): return r version = r['version'] - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-aws-cli/customize.py b/script/get-aws-cli/customize.py index cb9f08ab1..24da2b467 100644 --- a/script/get-aws-cli/customize.py +++ b/script/get-aws-cli/customize.py @@ -42,7 +42,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-bazel/customize.py b/script/get-bazel/customize.py index 6a98d4a47..c60553c17 100644 --- a/script/get-bazel/customize.py +++ b/script/get-bazel/customize.py @@ -43,7 +43,9 @@ def detect_version(i): logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-cl/customize.py b/script/get-cl/customize.py index 570906b9e..2c80d4e68 100644 --- a/script/get-cl/customize.py +++ b/script/get-cl/customize.py @@ -125,7 +125,9 @@ def detect_version(i): logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-cmake/customize.py b/script/get-cmake/customize.py index d83877077..ef2047723 100644 --- a/script/get-cmake/customize.py +++ b/script/get-cmake/customize.py @@ -42,7 +42,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-conda/customize.py b/script/get-conda/customize.py index 2f09452f4..81829d9d9 100644 --- a/script/get-conda/customize.py +++ b/script/get-conda/customize.py @@ -109,6 +109,8 @@ def postprocess(i): version = r['version'] - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-cuda/customize.py b/script/get-cuda/customize.py index ee941b5cc..005de5a2c 100644 --- a/script/get-cuda/customize.py +++ b/script/get-cuda/customize.py @@ -104,7 +104,9 @@ def detect_version_nvcc(i): logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} @@ -131,7 +133,9 @@ def detect_version_cuda_lib(i): env['MLC_CUDA_VERSION'] = cuda_version version = cuda_version - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} @@ -142,7 +146,7 @@ def postprocess(i): env = i['env'] logger = i['automation'].logger - + r = detect_version(i) if r['return'] > 0: return r diff --git a/script/get-cudnn/customize.py b/script/get-cudnn/customize.py index c51e210b5..b44fbc49d 100644 --- a/script/get-cudnn/customize.py +++ b/script/get-cudnn/customize.py @@ -135,7 +135,8 @@ def preprocess(i): print( "Copying cudnn include files to {}(CUDA_INCLUDE_PATH)".format(cuda_inc_path)) shutil.copytree(inc_path, cuda_inc_path, dirs_exist_ok=True) - logger.info("Copying cudnn lib files to {}CUDA_LIB_PATH".format(cuda_lib_path)) + logger.info( + "Copying cudnn lib files to {}CUDA_LIB_PATH".format(cuda_lib_path)) shutil.copytree(lib_path, cuda_lib_path, dirs_exist_ok=True) except BaseException: # Need to copy to system path via run.sh diff --git a/script/get-dataset-cognata-mlcommons/customize.py b/script/get-dataset-cognata-mlcommons/customize.py index 5d00d011a..1a070e0ab 100644 --- a/script/get-dataset-cognata-mlcommons/customize.py +++ b/script/get-dataset-cognata-mlcommons/customize.py @@ -124,7 +124,8 @@ def postprocess(i): if not utils.check_if_true_yes_on( env, 'MLC_DATASET_MLCOMMONS_COGNATA_UPDATE'): logger.info('') - logger.info('Already processed: use --update to update this dataset') + logger.info( + 'Already processed: use --update to update this dataset') return {'return': 0} @@ -235,7 +236,8 @@ def postprocess(i): ########################################################################## logger.info('') - logger.info('Available or selected serial numbers (use --serial_numbers=a,b,c to download specific subsets):') + logger.info( + 'Available or selected serial numbers (use --serial_numbers=a,b,c to download specific subsets):') logger.info('') for d in data: s = d[serial_key] diff --git a/script/get-dlrm-data-mlperf-inference/customize.py b/script/get-dlrm-data-mlperf-inference/customize.py index 11724845f..2271c5a36 100644 --- a/script/get-dlrm-data-mlperf-inference/customize.py +++ b/script/get-dlrm-data-mlperf-inference/customize.py @@ -44,10 +44,12 @@ def preprocess(i): if variation == "nvidia": if not os.path.exists(os.path.join(dlrm_data_path, "model")): - logger.warning(f'model directory is missing inside {dlrm_data_path}') + logger.warning( + f'model directory is missing inside {dlrm_data_path}') env['MLC_DLRM_MODEL_DOWNLOAD'] = True if not os.path.exists(os.path.join(dlrm_data_path, "criteo")): - logger.warning(f'criteo directory is missing inside {dlrm_data_path}') + logger.warning( + f'criteo directory is missing inside {dlrm_data_path}') env['MLC_DLRM_DATASET_DOWNLOAD'] = True if not os.path.exists(os.path.join( dlrm_data_path, "model", "model_weights")): @@ -55,7 +57,8 @@ def preprocess(i): f'model_weights directory is missing inside {dlrm_data_path}/model') env['MLC_DLRM_MODEL_DOWNLOAD'] = True if not os.path.exists(os.path.join(dlrm_data_path, "criteo", "day23")): - logger.warning(f'day23 directory is missing inside {dlrm_data_path}/day23') + logger.warning( + f'day23 directory is missing inside {dlrm_data_path}/day23') env['MLC_DLRM_DATASET_DOWNLOAD'] = True if not os.path.exists(os.path.join( dlrm_data_path, "criteo", "day23", "fp32")): diff --git a/script/get-docker/customize.py b/script/get-docker/customize.py index 999b2b323..4f5309e97 100644 --- a/script/get-docker/customize.py +++ b/script/get-docker/customize.py @@ -65,7 +65,7 @@ def detect_version(i): return r logger = i['automation'].logger - + version = r['version'] tool = "docker" @@ -73,7 +73,9 @@ def detect_version(i): if "podman" in r['string'].lower(): tool = "podman" - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version, "tool": tool} diff --git a/script/get-gcc/customize.py b/script/get-gcc/customize.py index 3cd898029..25e39a781 100644 --- a/script/get-gcc/customize.py +++ b/script/get-gcc/customize.py @@ -61,7 +61,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-github-cli/customize.py b/script/get-github-cli/customize.py index e157d387a..4ce75bd43 100644 --- a/script/get-github-cli/customize.py +++ b/script/get-github-cli/customize.py @@ -56,6 +56,8 @@ def postprocess(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-go/customize.py b/script/get-go/customize.py index 24a173071..241aa149d 100644 --- a/script/get-go/customize.py +++ b/script/get-go/customize.py @@ -42,7 +42,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-huggingface-cli/customize.py b/script/get-huggingface-cli/customize.py index 954f7c90c..990c17c28 100644 --- a/script/get-huggingface-cli/customize.py +++ b/script/get-huggingface-cli/customize.py @@ -26,6 +26,8 @@ def postprocess(i): version = r['version'] - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-java/customize.py b/script/get-java/customize.py index 406222249..3b8145d45 100644 --- a/script/get-java/customize.py +++ b/script/get-java/customize.py @@ -128,7 +128,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-javac/customize.py b/script/get-javac/customize.py index 2b0c7cb82..997d9dfff 100644 --- a/script/get-javac/customize.py +++ b/script/get-javac/customize.py @@ -128,7 +128,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-llvm/customize.py b/script/get-llvm/customize.py index 821333e8a..070f8d436 100644 --- a/script/get-llvm/customize.py +++ b/script/get-llvm/customize.py @@ -57,8 +57,10 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-ml-model-retinanet-nvidia/customize.py b/script/get-ml-model-retinanet-nvidia/customize.py index df3b3d9b4..da2c4adeb 100644 --- a/script/get-ml-model-retinanet-nvidia/customize.py +++ b/script/get-ml-model-retinanet-nvidia/customize.py @@ -27,5 +27,3 @@ def preprocess(i): "onnx_generator", "retinanet_anchor_xywh_1x1.npy") return {'return': 0} - - diff --git a/script/get-openssl/customize.py b/script/get-openssl/customize.py index b27445f27..41b2416e7 100644 --- a/script/get-openssl/customize.py +++ b/script/get-openssl/customize.py @@ -40,7 +40,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-python3/customize.py b/script/get-python3/customize.py index b93186e56..64ed74c8e 100644 --- a/script/get-python3/customize.py +++ b/script/get-python3/customize.py @@ -66,7 +66,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-qaic-apps-sdk/customize.py b/script/get-qaic-apps-sdk/customize.py index 09dd7f9f0..ae702daf7 100644 --- a/script/get-qaic-apps-sdk/customize.py +++ b/script/get-qaic-apps-sdk/customize.py @@ -67,7 +67,9 @@ def detect_version(i): if not version: return {'return': 1, 'error': f'qaic apps sdk version info not found'} - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-qaic-platform-sdk/customize.py b/script/get-qaic-platform-sdk/customize.py index fc87668f9..597e4a1fb 100644 --- a/script/get-qaic-platform-sdk/customize.py +++ b/script/get-qaic-platform-sdk/customize.py @@ -67,7 +67,9 @@ def detect_version(i): if not version: return {'return': 1, 'error': f'qaic platform sdk version info not found'} - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-rclone/customize.py b/script/get-rclone/customize.py index f9b486bed..91fa9b685 100644 --- a/script/get-rclone/customize.py +++ b/script/get-rclone/customize.py @@ -92,7 +92,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} @@ -125,7 +127,8 @@ def postprocess(i): with open(default_config_path, 'w') as configfile: default_config.write(configfile) - logger.info(f"{section: dict(default_config[section]) for section in default_config.sections()}") + logger.info( + f"{section: dict(default_config[section]) for section in default_config.sections()}") r = detect_version(i) diff --git a/script/get-rocm/customize.py b/script/get-rocm/customize.py index aa09192b8..8dac34e7f 100644 --- a/script/get-rocm/customize.py +++ b/script/get-rocm/customize.py @@ -44,7 +44,9 @@ def detect_version(i): version = r['version'] logger = i['automation'].logger - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/get-sys-utils-cm/customize.py b/script/get-sys-utils-cm/customize.py index 75c343df1..ed72dac02 100644 --- a/script/get-sys-utils-cm/customize.py +++ b/script/get-sys-utils-cm/customize.py @@ -84,9 +84,12 @@ def preprocess(i): # else: logger.info('') - logger.info('***********************************************************************') - logger.info('This script will attempt to install minimal system dependencies for CM.') + logger.info( + '***********************************************************************') + logger.info( + 'This script will attempt to install minimal system dependencies for CM.') logger.info('Note that you may be asked for your SUDO password ...') - logger.info('***********************************************************************') + logger.info( + '***********************************************************************') return {'return': 0} diff --git a/script/get-terraform/customize.py b/script/get-terraform/customize.py index d17962f71..eeb1c13b7 100644 --- a/script/get-terraform/customize.py +++ b/script/get-terraform/customize.py @@ -43,7 +43,9 @@ def detect_version(i): version = r['version'] - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/install-diffusers-from-src/customize.py b/script/install-diffusers-from-src/customize.py index a587d715b..f4a90798c 100644 --- a/script/install-diffusers-from-src/customize.py +++ b/script/install-diffusers-from-src/customize.py @@ -16,5 +16,3 @@ def preprocess(i): recursion_spaces = i['recursion_spaces'] return {'return': 0} - - diff --git a/script/install-generic-conda-package/customize.py b/script/install-generic-conda-package/customize.py index 43874ae16..865c3ec83 100644 --- a/script/install-generic-conda-package/customize.py +++ b/script/install-generic-conda-package/customize.py @@ -30,7 +30,9 @@ def detect_version(i): logger = i['automation'].logger # TBD - logger.info(i['recursion_spaces'] + ' Detected version: {}'.format(version)) + logger.info( + i['recursion_spaces'] + + ' Detected version: {}'.format(version)) return {'return': 0, 'version': version} diff --git a/script/install-gflags/customize.py b/script/install-gflags/customize.py index c1437b580..f43b25276 100644 --- a/script/install-gflags/customize.py +++ b/script/install-gflags/customize.py @@ -25,5 +25,3 @@ def preprocess(i): logger.info(f"{recursion_spaces} # Requested version: {need_version}") return {'return': 0} - - diff --git a/script/install-llvm-prebuilt/customize.py b/script/install-llvm-prebuilt/customize.py index ce223284e..d7a84815b 100644 --- a/script/install-llvm-prebuilt/customize.py +++ b/script/install-llvm-prebuilt/customize.py @@ -63,8 +63,10 @@ def preprocess(i): clang_file_name = "clang.exe" logger.info('') - logger.warning('WARNING: Please copy the following path and then paste it') - logger.info(' when LLVM installer asks you about the "Destination Folder":') + logger.warning( + 'WARNING: Please copy the following path and then paste it') + logger.info( + ' when LLVM installer asks you about the "Destination Folder":') logger.info('') logger.info(fos.getcwd()) logger.info('') diff --git a/script/install-openssl/customize.py b/script/install-openssl/customize.py index 2e038a4d5..c188d6634 100644 --- a/script/install-openssl/customize.py +++ b/script/install-openssl/customize.py @@ -25,5 +25,3 @@ def preprocess(i): logger.info(f"{recursion_spaces} # Requested version: {need_version}") return {'return': 0} - - diff --git a/script/install-rapidjson-from-src/customize.py b/script/install-rapidjson-from-src/customize.py index a587d715b..f4a90798c 100644 --- a/script/install-rapidjson-from-src/customize.py +++ b/script/install-rapidjson-from-src/customize.py @@ -16,5 +16,3 @@ def preprocess(i): recursion_spaces = i['recursion_spaces'] return {'return': 0} - - diff --git a/script/install-torchvision-from-src/customize.py b/script/install-torchvision-from-src/customize.py index a587d715b..f4a90798c 100644 --- a/script/install-torchvision-from-src/customize.py +++ b/script/install-torchvision-from-src/customize.py @@ -16,5 +16,3 @@ def preprocess(i): recursion_spaces = i['recursion_spaces'] return {'return': 0} - - diff --git a/script/preprocess-mlperf-inference-submission/customize.py b/script/preprocess-mlperf-inference-submission/customize.py index 788f8aabc..1db5d28e9 100644 --- a/script/preprocess-mlperf-inference-submission/customize.py +++ b/script/preprocess-mlperf-inference-submission/customize.py @@ -19,7 +19,8 @@ def preprocess(i): 'error': 'MLC_MLPERF_INFERENCE_SUBMISSION_DIR is not specified'} if not os.path.exists(submission_dir): - logger.error("Please set --env.MLC_MLPERF_INFERENCE_SUBMISSION_DIR to a valid submission directory") + logger.error( + "Please set --env.MLC_MLPERF_INFERENCE_SUBMISSION_DIR to a valid submission directory") return {'return': 1, 'error': 'MLC_MLPERF_INFERENCE_SUBMISSION_DIR is not existing'} diff --git a/script/push-csv-to-spreadsheet/customize.py b/script/push-csv-to-spreadsheet/customize.py index 8008bf918..1326b6edf 100644 --- a/script/push-csv-to-spreadsheet/customize.py +++ b/script/push-csv-to-spreadsheet/customize.py @@ -10,5 +10,3 @@ def preprocess(i): automation = i['automation'] return {'return': 0} - - diff --git a/script/push-mlperf-inference-results-to-github/customize.py b/script/push-mlperf-inference-results-to-github/customize.py index fc7057ed1..9b2df4d0f 100644 --- a/script/push-mlperf-inference-results-to-github/customize.py +++ b/script/push-mlperf-inference-results-to-github/customize.py @@ -42,5 +42,3 @@ def preprocess(i): env['MLC_GIT_PUSH_CMD'] = "git push" return {'return': 0} - - diff --git a/script/run-mlperf-automotive-app/customize.py b/script/run-mlperf-automotive-app/customize.py index c828776c5..c3dda9c7a 100644 --- a/script/run-mlperf-automotive-app/customize.py +++ b/script/run-mlperf-automotive-app/customize.py @@ -243,7 +243,8 @@ def preprocess(i): "MLC_TMP_"): del env_copy[key] - logger.info(f"\nRunning loadgen scenario: {scenario} and mode: {mode}") + logger.info( + f"\nRunning loadgen scenario: {scenario} and mode: {mode}") ii = {'action': action, 'automation': 'script', 'tags': scenario_tags, 'quiet': 'true', 'env': env_copy, 'input': inp, 'state': state, 'add_deps': copy.deepcopy(add_deps), 'add_deps_recursive': copy.deepcopy(add_deps_recursive), 'ad': ad, 'adr': copy.deepcopy(adr), 'v': verbose, 'print_env': print_env, 'print_deps': print_deps, 'dump_version_info': dump_version_info} @@ -297,7 +298,8 @@ def preprocess(i): logger.info(f"{sut}") result_table, headers = mlperf_utils.get_result_table( state["mlc-mlperf-inference-results"][sut]) - logger.info(f"{tabulate(result_table, headers=headers, tablefmt='pretty')}") + logger.info( + f"{tabulate(result_table, headers=headers, tablefmt='pretty')}") print( f"\nThe MLPerf inference results are stored at {output_dir}\n") diff --git a/script/run-mlperf-inference-app/customize.py b/script/run-mlperf-inference-app/customize.py index 7adc3638f..8cf0fbe1c 100644 --- a/script/run-mlperf-inference-app/customize.py +++ b/script/run-mlperf-inference-app/customize.py @@ -270,7 +270,8 @@ def preprocess(i): env_copy = copy.deepcopy(env) const_copy = copy.deepcopy(const) - logger.info(f"\nRunning loadgen scenario: {scenario} and mode: {mode}") + logger.info( + f"\nRunning loadgen scenario: {scenario} and mode: {mode}") ii = {'action': action, 'automation': 'script', 'tags': scenario_tags, 'quiet': 'true', 'env': env_copy, 'const': const_copy, 'input': inp, 'state': state, 'add_deps': copy.deepcopy(add_deps), 'add_deps_recursive': copy.deepcopy(add_deps_recursive), 'ad': ad, 'adr': copy.deepcopy(adr), 'print_env': print_env, 'print_deps': print_deps, 'dump_version_info': dump_version_info} @@ -338,7 +339,8 @@ def preprocess(i): logger.info(f"{sut}") result_table, headers = mlperf_utils.get_result_table( state["mlc-mlperf-inference-results"][sut]) - logger.info(f"{tabulate(result_table, headers=headers, tablefmt='pretty')}") + logger.info( + f"{tabulate(result_table, headers=headers, tablefmt='pretty')}") print( f"\nThe MLPerf inference results are stored at {output_dir}\n") diff --git a/script/run-mlperf-power-client/customize.py b/script/run-mlperf-power-client/customize.py index 312fb7ecb..0c2b9fbcd 100644 --- a/script/run-mlperf-power-client/customize.py +++ b/script/run-mlperf-power-client/customize.py @@ -40,5 +40,3 @@ def preprocess(i): env['MLC_MLPERF_POWER_RUN_CMD'] = cmd return {'return': 0} - - diff --git a/script/run-mlperf-power-server/customize.py b/script/run-mlperf-power-server/customize.py index 78bdcfbba..59056a0d2 100644 --- a/script/run-mlperf-power-server/customize.py +++ b/script/run-mlperf-power-server/customize.py @@ -66,7 +66,8 @@ def preprocess(i): with open('tmp-power-server.conf', 'w') as configfile: config.write(configfile) - logger.info(f"{section: dict(config[section]) for section in config.sections()}") + logger.info( + f"{section: dict(config[section]) for section in config.sections()}") if env['MLC_HOST_OS_TYPE'] == "windows": cmd_prefix = "" @@ -85,5 +86,3 @@ def preprocess(i): env['RUN_CMD'] = cmd return {'return': 0} - - diff --git a/script/run-terraform/customize.py b/script/run-terraform/customize.py index 77faca003..d90962d03 100644 --- a/script/run-terraform/customize.py +++ b/script/run-terraform/customize.py @@ -85,5 +85,3 @@ def postprocess(i): print_attr(instance_attributes, "security_groups") return {'return': 0} - - diff --git a/script/runtime-system-infos/customize.py b/script/runtime-system-infos/customize.py index 877b87141..ae4d7d61b 100644 --- a/script/runtime-system-infos/customize.py +++ b/script/runtime-system-infos/customize.py @@ -49,7 +49,8 @@ def preprocess(i): logger.info(f"The system dumps are created to the folder:{logs_dir}") - logger.warning("Currently the script is in its development stage. Only memory measurements supports as of now!") + logger.warning( + "Currently the script is in its development stage. Only memory measurements supports as of now!") logger.info("Started measuring system info!") diff --git a/script/set-venv/customize.py b/script/set-venv/customize.py index ee6da6e58..daf23ea4f 100644 --- a/script/set-venv/customize.py +++ b/script/set-venv/customize.py @@ -51,7 +51,8 @@ def preprocess(i): cmd = python_path + ' -m venv ' + name + create_dir.format(name) - logger.info('====================================================================') + logger.info( + '====================================================================') logger.info('Creating venv: "{}" ...'.format(cmd)) os.system(cmd) @@ -88,11 +89,13 @@ def preprocess(i): with open(script_file, 'w') as f: f.write(cmd) - logger.info('====================================================================') + logger.info( + '====================================================================') logger.info('Please run the following command:') logger.info('') logger.info(f"{xcmd}") - logger.info('====================================================================') + logger.info( + '====================================================================') return {'return': 0} diff --git a/script/submit-mlperf-results/customize.py b/script/submit-mlperf-results/customize.py index 40f3d8777..db89c4655 100644 --- a/script/submit-mlperf-results/customize.py +++ b/script/submit-mlperf-results/customize.py @@ -205,5 +205,3 @@ def trigger_submission_checker( "return": 500, "error": str(e) } - - diff --git a/script/wrapper-reproduce-octoml-tinyml-submission/customize.py b/script/wrapper-reproduce-octoml-tinyml-submission/customize.py index 19a5a669c..dd290e09d 100644 --- a/script/wrapper-reproduce-octoml-tinyml-submission/customize.py +++ b/script/wrapper-reproduce-octoml-tinyml-submission/customize.py @@ -37,5 +37,3 @@ def preprocess(i): return r return {'return': 0} - - From 1fc88a81dcb5c2c1ddbab1791f5d778f26b58e08 Mon Sep 17 00:00:00 2001 From: anandhu-eng Date: Thu, 24 Apr 2025 18:16:11 +0530 Subject: [PATCH 3/4] code clean --- script/download-file/customize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/download-file/customize.py b/script/download-file/customize.py index 2a3609e69..6200cc223 100644 --- a/script/download-file/customize.py +++ b/script/download-file/customize.py @@ -201,7 +201,7 @@ def preprocess(i): if url == '': break env['MLC_DOWNLOAD_CMD'] += f" || (({del_cmd} {env['MLC_DOWNLOAD_FILENAME']} || true) && wget -nc {extra_download_options} {url})" - logger.info(fenv['MLC_DOWNLOAD_CMD']) + logger.info(f"{env['MLC_DOWNLOAD_CMD']}") elif tool == "curl": if env.get('MLC_DOWNLOAD_FILENAME', '') != '': From 0caa49d864c4511986d94fb2e075d420926036dc Mon Sep 17 00:00:00 2001 From: anandhu-eng Date: Thu, 24 Apr 2025 18:20:20 +0530 Subject: [PATCH 4/4] code clean --- script/get-aocc/customize.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/script/get-aocc/customize.py b/script/get-aocc/customize.py index 197877aab..d5890e103 100644 --- a/script/get-aocc/customize.py +++ b/script/get-aocc/customize.py @@ -82,8 +82,7 @@ def detect_version(i): version = r['version'] logger.info( - fi['recursion_spaces'] + - ' Detected version: {}'.format(version)) + f"{i['recursion_spaces']} Detected version: {version}") return {'return': 0, 'version': version}