Skip to content

Commit 98f4060

Browse files
[GHA] run tests with numpy<2 (#3190)
### Changes - Run precommit tests with numpy-1.24.0 on python3.9 - Add `override_requirements` argument to call-precommit.yml - Use one line install `pip install . -r <path>/requarements.txt` to correctly resolve versions of install packages - Bump minimal version of numpy to 1.24.0 ### Reason for changes - numpy <1.19.3 - fail on installation https://github.com/openvinotoolkit/nncf/actions/runs/12757498767/job/35557883523 - numpy <1.24 - falls by using numpy.typing ### Tests https://github.com/openvinotoolkit/nncf/actions/runs/12767723338/job/35586673309?pr=3190 sdl/job/nightly_trigger/407/
1 parent 438871e commit 98f4060

File tree

4 files changed

+89
-10
lines changed

4 files changed

+89
-10
lines changed
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright (c) 2025 Intel Corporation
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
12+
import re
13+
import sys
14+
from pathlib import Path
15+
16+
CONSTRAINTS_FILE = "constraints.txt"
17+
18+
19+
def main():
20+
arg = sys.argv[1]
21+
overrided_requirements = [r.strip() for r in arg.split(",")]
22+
23+
print("overrided_requirements: ", arg)
24+
25+
file = Path(CONSTRAINTS_FILE)
26+
content = file.read_text()
27+
28+
for new_requirement in overrided_requirements:
29+
new_requirement = new_requirement.strip()
30+
package_name = new_requirement.split("==")[0]
31+
content = re.sub(f"^{package_name}\s*[=><].*", "", content, flags=re.MULTILINE)
32+
content += f"\n{new_requirement}"
33+
34+
print("New constraints:")
35+
print(content)
36+
37+
file.write_text(content)
38+
39+
40+
if __name__ == "__main__":
41+
main()

.github/workflows/call_precommit.yml

+41-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
type: boolean
1414
default: false
1515
required: true
16+
override_requirements:
17+
description: 'Override requirements'
18+
default: ''
19+
type: string
20+
required: false
1621

1722
jobs:
1823
common:
@@ -29,8 +34,12 @@ jobs:
2934
with:
3035
python-version: ${{ inputs.python_version }}
3136
cache: pip
37+
- name: Override constraints
38+
if: ${{ inputs.override_requirements != '' }}
39+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
40+
shell: bash
3241
- name: Install NNCF and test requirements
33-
run: make install-common-test
42+
run: pip install . -r tests/common/requirements.txt
3443
- name: Print installed modules
3544
run: pip list
3645
- name: Run common precommit test scope
@@ -51,8 +60,12 @@ jobs:
5160
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
5261
with:
5362
python-version: ${{ inputs.python_version }}
63+
- name: Override constraints
64+
if: ${{ inputs.override_requirements != '' }}
65+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
66+
shell: bash
5467
- name: Install NNCF and test requirements
55-
run: make install-onnx-test
68+
run: pip install . -r tests/onnx/requirements.txt
5669
- name: Print installed modules
5770
run: pip list
5871
- name: Run ONNX precommit test scope
@@ -74,8 +87,12 @@ jobs:
7487
with:
7588
python-version: ${{ inputs.python_version }}
7689
cache: pip
90+
- name: Override constraints
91+
if: ${{ inputs.override_requirements != '' }}
92+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
93+
shell: bash
7794
- name: Install NNCF and test requirements
78-
run: make install-openvino-test
95+
run: pip install . -r tests/openvino/requirements.txt
7996
- name: Print installed modules
8097
run: pip list
8198
- name: Run OV precommit test scope
@@ -108,8 +125,12 @@ jobs:
108125
run: |
109126
cat /etc/*release
110127
cat /proc/cpuinfo
128+
- name: Override constraints
129+
if: ${{ inputs.override_requirements != '' }}
130+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
131+
shell: bash
111132
- name: Install NNCF and test requirements
112-
run: make install-torch-test
133+
run: pip install . -r tests/torch/requirements.txt
113134
- name: Print installed modules
114135
run: pip list
115136
- name: Run PyTorch precommit test scope
@@ -151,8 +172,12 @@ jobs:
151172
with:
152173
python-version: ${{ inputs.python_version }}
153174
cache: pip
175+
- name: Override constraints
176+
if: ${{ inputs.override_requirements != '' }}
177+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
178+
shell: bash
154179
- name: Install NNCF and test requirements
155-
run: make install-torch-test
180+
run: pip install . -r tests/torch/requirements.txt
156181
- name: Print installed modules
157182
run: pip list
158183
- name: Check CUDA
@@ -181,8 +206,12 @@ jobs:
181206
with:
182207
python-version: ${{ inputs.python_version }}
183208
cache: pip
209+
- name: Override constraints
210+
if: ${{ inputs.override_requirements != '' }}
211+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
212+
shell: bash
184213
- name: Install NNCF and test requirements
185-
run: make install-tensorflow-test
214+
run: pip install . -r tests/tensorflow/requirements.txt
186215
- name: Print installed modules
187216
run: pip list
188217
- name: Run TensorFlow precommit test scope
@@ -204,7 +233,7 @@ jobs:
204233
with:
205234
python-version: ${{ inputs.python_version }}
206235
cache: pip
207-
- name: Install NNCF and test requirements
236+
- name: Install test requirements
208237
run: pip install -r tests/tools/requirements.txt
209238
- name: Print installed modules
210239
run: pip list
@@ -225,9 +254,13 @@ jobs:
225254
with:
226255
python-version: ${{ inputs.python_version }}
227256
cache: pip
257+
- name: Override constraints
258+
if: ${{ inputs.override_requirements != '' }}
259+
run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}"
260+
shell: bash
228261
- name: Install NNCF and test requirements
229262
run: |
230-
pip install -r tests/torch2/requirements.txt -e .
263+
pip install . -r tests/torch2/requirements.txt
231264
- name: Print installed modules
232265
run: pip list
233266
- name: Run torch2 precommit test scope

.github/workflows/weekly.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python_version: ["3.9", "3.11", "3.12"]
15+
include:
16+
- python_version: "3.9"
17+
override_requirements: "numpy==1.24.0"
18+
- python_version: "3.11"
19+
- python_version: "3.12"
1620
uses: ./.github/workflows/call_precommit.yml
1721
with:
1822
python_version: ${{ matrix.python_version }}
23+
override_requirements: ${{ matrix.override_requirements || '' }}
1924
gpu_enabled: false
2025

2126
macos:

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies = [
3838
"natsort>=7.1.0",
3939
"networkx>=2.6, <=3.3",
4040
"ninja>=1.10.0.post2, <1.12",
41-
"numpy>=1.19.1, <2.2.0",
41+
"numpy>=1.24.0, <2.2.0",
4242
"openvino-telemetry>=2023.2.0",
4343
"packaging>=20.0",
4444
"pandas>=1.1.5,<2.3",

0 commit comments

Comments
 (0)