forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (130 loc) · 5.63 KB
/
job_python_api_tests.yml
File metadata and controls
147 lines (130 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Python API tests
on:
workflow_call:
inputs:
runner:
description: 'Machine on which the tests would run'
type: string
required: true
image:
description: 'Docker image to use for the job'
type: string
required: false
default: null
affected-components:
description: 'Components that are affected by changes in the commit defined by the Smart CI Action'
type: string
required: true
python-version:
description: 'Python version to setup. E.g., "3.11"'
type: string
required: true
permissions: read-all
env:
PIP_CACHE_PATH: /mount/caches/pip/linux
jobs:
Python_Unit_Tests:
name: Python API tests
if: ${{ fromJSON(inputs.affected-components).Python_API.test || fromJSON(inputs.affected-components).docs_snippets.test }}
timeout-minutes: 30
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.image }}
volumes:
- /mount:/mount
- ${{ github.workspace }}:${{ github.workspace }} # Needed as ${{ github.workspace }} is not working correctly when using Docker
defaults:
run:
shell: bash
env:
DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input
INSTALL_DIR: ${{ github.workspace }}/install
INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests
steps:
# checkout action cleans up the workspace and have to be the first step
- name: Fetch setup_python and install wheels actions
uses: ababushk/checkout@dd591a6a2ac25618db4eda86e7e0d938f88cf01b # cherry_pick_retries
timeout-minutes: 15
with:
sparse-checkout: |
.github/actions
docs/articles_en/assets/snippets
src/bindings/python/scripts/generate_pyapi_stubs.py
src/bindings/python/**/*.pyi
sparse-checkout-cone-mode: false
submodules: 'false'
- name: Download OpenVINO artifacts (wheels)
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: openvino_wheels
path: ${{ env.INSTALL_DIR }}
- name: Download OpenVINO artifacts (tests)
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: openvino_tests
path: ${{ env.INSTALL_DIR }}
- name: Install OpenVINO dependencies (mac)
if: runner.os == 'macOS'
run: brew install pigz
- name: Extract OpenVINO packages
run: pigz -dc openvino_tests.tar.gz | tar -xf - -v
working-directory: ${{ env.INSTALL_DIR }}
- name: Setup Python ${{ inputs.python-version }}
uses: ./.github/actions/setup_python
with:
version: ${{ inputs.python-version }}
pip-cache-path: ${{ runner.os == 'Linux' && env.PIP_CACHE_PATH || '' }}
should-setup-pip-paths: ${{ runner.os == 'Linux' }}
self-hosted-runner: ${{ runner.os == 'Linux' }}
#
# Tests
#
- name: Install OpenVINO Python wheels
uses: ./.github/actions/install_ov_wheels
with:
wheels-dir-path: ${{ env.INSTALL_DIR }}
wheels-to-install: 'openvino'
free-threaded-python: ${{ contains(inputs.python-version, 't') }}
- name: Install Python API tests dependencies
run: python3 -m pip install -r ${INSTALL_TEST_DIR}/bindings/python/requirements_test.txt
#
# Tests
#
- name: Python API Tests
if: fromJSON(inputs.affected-components).Python_API.test
run: |
# for 'template' extension
export LD_LIBRARY_PATH=${INSTALL_TEST_DIR}/:$LD_LIBRARY_PATH
python3 -m pytest -sv ${INSTALL_TEST_DIR}/pyopenvino \
--junitxml=${INSTALL_TEST_DIR}/TEST-Pyngraph.xml \
--ignore=${INSTALL_TEST_DIR}/pyopenvino/tests/test_utils/test_utils.py
- name: Python API Tests -- numpy<2.0.0
if: ${{ fromJSON(inputs.affected-components).Python_API.test && inputs.python-version != '3.14t' }} # Explanation for `3.14t` is in the 178162 ticket
run: |
python3 -m pip uninstall -y numpy
python3 -m pip install "numpy~=1.26.0"
python3 -m pip install -r ${INSTALL_TEST_DIR}/bindings/python/requirements_test.txt
# for 'template' extension
export LD_LIBRARY_PATH=${INSTALL_TEST_DIR}/:$LD_LIBRARY_PATH
python3 -m pytest -sv ${INSTALL_TEST_DIR}/pyopenvino \
--junitxml=${INSTALL_TEST_DIR}/TEST-Pyngraph_new_numpy.xml \
--ignore=${INSTALL_TEST_DIR}/pyopenvino/tests/test_utils/test_utils.py
- name: Docs Python snippets
if: ${{ runner.os != 'macOS' && fromJSON(inputs.affected-components).docs_snippets.test && inputs.python-version != '3.14' && inputs.python-version != '3.14t' }} # Ticket: 178163
run: |
# torch, onnx
python3 -m pip install -r ${INSTALL_TEST_DIR}/python/preprocess/torchvision/requirements.txt -r ${INSTALL_TEST_DIR}/requirements_onnx
# to find 'snippets' module in docs
export PYTHONPATH=docs/articles_en/assets
# for 'template' extension
export LD_LIBRARY_PATH=${INSTALL_TEST_DIR}/:$LD_LIBRARY_PATH
python3 docs/articles_en/assets/snippets/main.py
- name: Upload Test Results
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ !cancelled() }}
with:
name: test-results-python-api-${{ inputs.python-version }}
path: |
${{ env.INSTALL_TEST_DIR }}/TEST*.html
${{ env.INSTALL_TEST_DIR }}/TEST*.xml
if-no-files-found: 'warn'