From 4e75605eec985e579ee1e8db9a2bb2fd441a4837 Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Mon, 22 Jul 2024 12:39:10 -0700 Subject: [PATCH] Replace inline pip install with pip install from requirements*.txt (#21106) ### Description Replace inline pip install with pip install from requirements*.txt ### Motivation and Context so that CG can recognize ### Dependency - [x] https://github.com/microsoft/onnxruntime/pull/21085 --- tools/ci_build/build.py | 27 +++++++++---------- .../orttraining-pai-ci-pipeline.yml | 2 +- .../requirements/pybind/requirements.txt | 8 ++++++ .../transformers-test/requirements.txt} | 0 4 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 tools/ci_build/requirements/pybind/requirements.txt rename tools/ci_build/{requirements-transformers-test.txt => requirements/transformers-test/requirements.txt} (100%) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 75fbf5d0851ae..54f7b6c3a8fa7 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -261,9 +261,6 @@ def convert_arg_line_to_args(self, arg_line): "--wheel_name_suffix", help="Suffix to append to created wheel names. This value is currently only used for nightly builds.", ) - parser.add_argument( - "--numpy_version", help="Installs a specific version of numpy before building the python binding." - ) parser.add_argument("--skip-keras-test", action="store_true", help="Skip tests with Keras if keras is installed") # C-Sharp bindings @@ -868,16 +865,6 @@ def update_submodules(source_dir): run_subprocess(["git", "submodule", "update", "--init", "--recursive"], cwd=source_dir) -def install_python_deps(numpy_version=""): - dep_packages = ["setuptools", "wheel", "pytest"] - dep_packages.append(f"numpy=={numpy_version}" if numpy_version else "numpy>=1.16.6") - dep_packages.append("sympy>=1.10") - dep_packages.append("packaging") - dep_packages.append("cerberus") - dep_packages.append("psutil") - run_subprocess([sys.executable, "-m", "pip", "install", *dep_packages]) - - def setup_test_data(source_onnx_model_dir, dest_model_dir_name, build_dir, configs): # create the symlink/shortcut of onnx models dir under build_dir # currently, there're 2 sources of onnx models, one is build in OS image, another is @@ -2146,7 +2133,14 @@ def run_onnxruntime_tests(args, source_dir, ctest_path, build_dir, configs): numpy_init_version = numpy.__version__ pb_init_version = google.protobuf.__version__ run_subprocess( - [sys.executable, "-m", "pip", "install", "-r", "requirements-transformers-test.txt"], + [ + sys.executable, + "-m", + "pip", + "install", + "-r", + "requirements/transformers-test/requirements.txt", + ], cwd=SCRIPT_DIR, ) run_subprocess([sys.executable, "-m", "pytest", "transformers"], cwd=cwd) @@ -2818,7 +2812,10 @@ def main(): run_subprocess([emsdk_file, "activate", emsdk_version], cwd=emsdk_dir) if args.enable_pybind and is_windows(): - install_python_deps(args.numpy_version) + run_subprocess( + [sys.executable, "-m", "pip", "install", "-r", "requirements/pybind/requirements.txt"], + cwd=SCRIPT_DIR, + ) if args.use_rocm and args.rocm_version is None: args.rocm_version = "" diff --git a/tools/ci_build/github/azure-pipelines/orttraining-pai-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/orttraining-pai-ci-pipeline.yml index 0e1afdcc5b8ca..2c520a25cb39e 100644 --- a/tools/ci_build/github/azure-pipelines/orttraining-pai-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/orttraining-pai-ci-pipeline.yml @@ -276,7 +276,7 @@ jobs: onnxruntimetrainingrocm-cibuild-rocm$(RocmVersion)-test \ /bin/bash -c " set -ex; \ - pip install -r /onnxruntime_src/tools/ci_build/requirements-transformers-test.txt; \ + pip install -r /onnxruntime_src/tools/ci_build/requirements/transformers-test/requirements.txt; \ pytest /onnxruntime_src/onnxruntime/test/python/transformers/test_flash_attn_rocm.py -v -n 4 --reruns 1" workingDirectory: $(Build.SourcesDirectory) displayName: 'Run tranformers tests' diff --git a/tools/ci_build/requirements/pybind/requirements.txt b/tools/ci_build/requirements/pybind/requirements.txt new file mode 100644 index 0000000000000..8f00a25627c21 --- /dev/null +++ b/tools/ci_build/requirements/pybind/requirements.txt @@ -0,0 +1,8 @@ +setuptools +wheel +pytest +numpy>=1.19.0 +sympy>=1.10 +packaging +cerberus +psutil diff --git a/tools/ci_build/requirements-transformers-test.txt b/tools/ci_build/requirements/transformers-test/requirements.txt similarity index 100% rename from tools/ci_build/requirements-transformers-test.txt rename to tools/ci_build/requirements/transformers-test/requirements.txt