From 41ffb71287a6ba8c017360a24224150d055ba934 Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Wed, 18 Sep 2024 04:28:20 +0530 Subject: [PATCH 1/5] Added test for cm4mlops, fix setup.py for python3.7 --- .github/workflows/test-cm4mlops.yml | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/test-cm4mlops.yml diff --git a/.github/workflows/test-cm4mlops.yml b/.github/workflows/test-cm4mlops.yml new file mode 100644 index 0000000000..5ba3121f8f --- /dev/null +++ b/.github/workflows/test-cm4mlops.yml @@ -0,0 +1,36 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: cm4mlops test + +on: + pull_request: + branches: [ "main", "dev", "mlperf-inference" ] + paths: + - '.github/workflows/test-cm4mlops.yml' + - 'setup.py' + +jobs: + build: + strategy: + fail-fast: false + matrix: + python-version: ["3.7", "3.8", "3.12"] + on: [ubuntu-latest, windows-latest, macos-latest] + exclude: + - python-version: "3.7" + on: "macos-latest" + runs-on: "${{ matrix.on }}" + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install . + From edd7f41da411fc95b34059535282159773400b21 Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Wed, 18 Sep 2024 04:28:29 +0530 Subject: [PATCH 2/5] Added test for cm4mlops, fix setup.py for python3.7 --- setup.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 45f577ed51..53a9ac0f16 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,21 @@ import platform import os +# Try to use importlib.metadata for Python 3.8+ +try: + if sys.version_info >= (3, 8): + from importlib.metadata import version, PackageNotFoundError + else: + # Fallback to pkg_resources for Python < 3.8 + import pkg_resources + PackageNotFoundError = pkg_resources.DistributionNotFound +except ImportError: + # If importlib.metadata is unavailable, fall back to pkg_resources + import pkg_resources + PackageNotFoundError = pkg_resources.DistributionNotFound + + + class CustomInstallCommand(install): def run(self): self.get_sys_platform() @@ -19,6 +34,16 @@ def run(self): # Call the custom function return self.custom_function() + def is_package_installed(package_name): + try: + if sys.version_info >= (3, 8): + version(package_name) # Tries to get the version of the package + else: + pkg_resources.get_distribution(package_name) # Fallback for < 3.8 + return True + except PackageNotFoundError: + return False + def install_system_packages(self): # List of packages to install via system package manager packages = [] @@ -37,11 +62,8 @@ def install_system_packages(self): if name in sys.modules: pass #nothing needed - elif (spec := importlib.util.find_spec(name)) is not None: - module = importlib.util.module_from_spec(spec) - sys.modules[name] = module - spec.loader.exec_module(module) - #print(f"{name} has been imported") + elif self.is_package_installed(name): + pass else: packages.append("python3-venv") From d7c5a5004f4294b6f58b41f420a1f11d5b764569 Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Wed, 18 Sep 2024 04:33:07 +0530 Subject: [PATCH 3/5] Added test for cm4mlops, fix setup.py for python3.7 --- .github/workflows/test-cm4mlops.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cm4mlops.yml b/.github/workflows/test-cm4mlops.yml index 5ba3121f8f..c89cca16d4 100644 --- a/.github/workflows/test-cm4mlops.yml +++ b/.github/workflows/test-cm4mlops.yml @@ -29,7 +29,7 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Run Test install for cm4mlops run: | python -m pip install --upgrade pip python -m pip install . From bbd4ffb1bdc1403ce6e0e0a6ab04300cb7f0795f Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Wed, 18 Sep 2024 04:34:50 +0530 Subject: [PATCH 4/5] Added test for cm4mlops, fix setup.py for python3.7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 53a9ac0f16..e7c96a97cd 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def run(self): # Call the custom function return self.custom_function() - def is_package_installed(package_name): + def is_package_installed(self, package_name): try: if sys.version_info >= (3, 8): version(package_name) # Tries to get the version of the package From 4b6000c7261e7e0ee5172956e58650f9b168551c Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Wed, 18 Sep 2024 04:41:48 +0530 Subject: [PATCH 5/5] Fix cm4mlops wheel build test --- .../workflows/test-cm4mlops-wheel-macos.yml | 3 ++ .../workflows/test-cm4mlops-wheel-ubuntu.yml | 5 ++- .../workflows/test-cm4mlops-wheel-windows.yml | 3 ++ .github/workflows/test-cm4mlops.yml | 36 ------------------- 4 files changed, 10 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/test-cm4mlops.yml diff --git a/.github/workflows/test-cm4mlops-wheel-macos.yml b/.github/workflows/test-cm4mlops-wheel-macos.yml index a37395802a..fede3adb9f 100644 --- a/.github/workflows/test-cm4mlops-wheel-macos.yml +++ b/.github/workflows/test-cm4mlops-wheel-macos.yml @@ -6,6 +6,9 @@ on: - main - dev - mlperf-inference + paths: + - '.github/workflows/test-cm4mlops-wheel-macos.yml' + - 'setup.py' jobs: build: diff --git a/.github/workflows/test-cm4mlops-wheel-ubuntu.yml b/.github/workflows/test-cm4mlops-wheel-ubuntu.yml index f2e41371c5..4a37a5290e 100644 --- a/.github/workflows/test-cm4mlops-wheel-ubuntu.yml +++ b/.github/workflows/test-cm4mlops-wheel-ubuntu.yml @@ -6,6 +6,9 @@ on: - main - dev - mlperf-inference + paths: + - '.github/workflows/test-cm4mlops-wheel-ubuntu.yml' + - 'setup.py' jobs: build: @@ -13,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, ubuntu-20.04] - python-version: ['3.8', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.11', '3.12'] exclude: - os: ubuntu-latest python-version: "3.8" diff --git a/.github/workflows/test-cm4mlops-wheel-windows.yml b/.github/workflows/test-cm4mlops-wheel-windows.yml index 0978ef5d59..68bf199a7e 100644 --- a/.github/workflows/test-cm4mlops-wheel-windows.yml +++ b/.github/workflows/test-cm4mlops-wheel-windows.yml @@ -6,6 +6,9 @@ on: - main - dev - mlperf-inference + paths: + - '.github/workflows/test-cm4mlops-wheel-windows.yml' + - 'setup.py' jobs: build: diff --git a/.github/workflows/test-cm4mlops.yml b/.github/workflows/test-cm4mlops.yml deleted file mode 100644 index c89cca16d4..0000000000 --- a/.github/workflows/test-cm4mlops.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: cm4mlops test - -on: - pull_request: - branches: [ "main", "dev", "mlperf-inference" ] - paths: - - '.github/workflows/test-cm4mlops.yml' - - 'setup.py' - -jobs: - build: - strategy: - fail-fast: false - matrix: - python-version: ["3.7", "3.8", "3.12"] - on: [ubuntu-latest, windows-latest, macos-latest] - exclude: - - python-version: "3.7" - on: "macos-latest" - runs-on: "${{ matrix.on }}" - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Run Test install for cm4mlops - run: | - python -m pip install --upgrade pip - python -m pip install . -