|
| 1 | +name: Build Treon Reusable Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + runs_on: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + python: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + container: |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + default: null |
| 16 | + test_only_changed: |
| 17 | + required: false |
| 18 | + type: boolean |
| 19 | + default: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + build_treon: |
| 23 | + runs-on: ${{ inputs.runs_on }} |
| 24 | + container: |
| 25 | + image: ${{ inputs.container }} |
| 26 | + options: --device /dev/dri:/dev/dri --group-add 109 --group-add 44 |
| 27 | + volumes: |
| 28 | + - /dev/dri:/dev/dri |
| 29 | + steps: |
| 30 | + - name: Set env variables |
| 31 | + uses: actions/github-script@v7 |
| 32 | + with: |
| 33 | + script: | |
| 34 | + const container = "${{ inputs.container }}"; |
| 35 | + const runsOn = "${{ inputs.runs_on }}"; |
| 36 | + const osName = !container ? "${{ inputs.runs_on }}" : container.replace(':', '-'); |
| 37 | + const testDevice = runsOn === 'gpu' ? 'gpu' : 'cpu'; |
| 38 | + const testReportDir = `${testDevice}-${osName}-${{ inputs.python }}`; |
| 39 | + core.exportVariable('OS_NAME', osName); |
| 40 | + core.exportVariable('TEST_DEVICE', testDevice); |
| 41 | + core.exportVariable('TEST_REPORT_DIR', testReportDir); |
| 42 | + core.exportVariable('GIT_CLONE_PROTECTION_ACTIVE', 'false'); |
| 43 | +
|
| 44 | + #### Installation/preparation #### |
| 45 | + # |
| 46 | + # These steps are also copied to convert_notebooks.yml |
| 47 | + - name: Checkout repository |
| 48 | + uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Get changed files |
| 51 | + if: ${{ inputs.test_only_changed }} |
| 52 | + id: changed-files |
| 53 | + uses: tj-actions/changed-files@v44 |
| 54 | + with: |
| 55 | + files: | |
| 56 | + notebooks/*/** |
| 57 | + requirements.txt |
| 58 | +
|
| 59 | + - name: List all changed files |
| 60 | + if: ${{ inputs.test_only_changed }} |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + touch test_notebooks.txt |
| 64 | + changed_files="${{ steps.changed-files.outputs.all_changed_files }}" |
| 65 | + changed_files=$(echo $changed_files | tr '\\' '/') |
| 66 | + for file in $changed_files; do |
| 67 | + echo "$file was changed" |
| 68 | + echo $file >> test_notebooks.txt |
| 69 | + done |
| 70 | +
|
| 71 | + - name: Dotenv Action |
| 72 | + id: dotenv |
| 73 | + |
| 74 | + with: |
| 75 | + path: ./.github/workflows |
| 76 | + |
| 77 | + - name: Install required packages |
| 78 | + if: ${{ !inputs.container }} |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 82 | + sudo apt-get update -y |
| 83 | + sudo apt-get install libsndfile1 -y |
| 84 | + fi |
| 85 | +
|
| 86 | + - name: Install required packages (container) |
| 87 | + if: ${{ inputs.container }} |
| 88 | + shell: bash |
| 89 | + env: |
| 90 | + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input |
| 91 | + TZ: 'Europe/London' # to prevent tzdata from waiting user input |
| 92 | + run: | |
| 93 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 94 | + apt-get update -y |
| 95 | + apt-get install git curl wget libsndfile1 libssl-dev unzip libsqlite3-dev libedit-dev libgl1 libgl1-mesa-glx libglib2.0-0 -y |
| 96 | + wget https://raw.githubusercontent.com/openvinotoolkit/openvino/master/scripts/install_dependencies/install_openvino_dependencies.sh |
| 97 | + chmod +x ./install_openvino_dependencies.sh |
| 98 | + ./install_openvino_dependencies.sh -c=core -c=dev -c=gpu -y |
| 99 | + fi |
| 100 | +
|
| 101 | + - name: Install GPU Drivers |
| 102 | + if: ${{ inputs.container }} |
| 103 | + shell: bash |
| 104 | + run: | |
| 105 | + wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.15985.7/intel-igc-core_1.0.15985.7_amd64.deb |
| 106 | + wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.15985.7/intel-igc-opencl_1.0.15985.7_amd64.deb |
| 107 | + wget https://github.com/intel/compute-runtime/releases/download/24.05.28454.6/intel-level-zero-gpu-dbgsym_1.3.28454.6_amd64.ddeb |
| 108 | + wget https://github.com/intel/compute-runtime/releases/download/24.05.28454.6/intel-level-zero-gpu_1.3.28454.6_amd64.deb |
| 109 | + wget https://github.com/intel/compute-runtime/releases/download/24.05.28454.6/intel-opencl-icd-dbgsym_24.05.28454.6_amd64.ddeb |
| 110 | + wget https://github.com/intel/compute-runtime/releases/download/24.05.28454.6/intel-opencl-icd_24.05.28454.6_amd64.deb |
| 111 | + wget https://github.com/intel/compute-runtime/releases/download/24.05.28454.6/libigdgmm12_22.3.11_amd64.deb |
| 112 | + dpkg -i *.deb |
| 113 | +
|
| 114 | + - name: Set up Python |
| 115 | + uses: actions/setup-python@v5 |
| 116 | + with: |
| 117 | + python-version: '${{ inputs.python }}' |
| 118 | + env: |
| 119 | + AGENT_TOOLSDIRECTORY: ${{ inputs.container && '/opt/hostedtoolcache' || '' }} |
| 120 | + |
| 121 | + - name: Cache Pip Packages |
| 122 | + id: cachepip |
| 123 | + uses: actions/cache@v3 |
| 124 | + with: |
| 125 | + path: | |
| 126 | + pipcache |
| 127 | + key: ${{ env.PIP_CACHE_KEY }}-${{ env.OS_NAME }}-${{ inputs.python }} |
| 128 | + |
| 129 | + # Cache specific files to reduce downloads or prevent network issues |
| 130 | + - name: Cache Files |
| 131 | + id: cachefiles |
| 132 | + uses: actions/cache@v3 # TODO Consider updating cache action to v4 |
| 133 | + with: |
| 134 | + path: | |
| 135 | + # NOTE: when modifying cache paths, update FILES_CACHE_KEY in .env |
| 136 | + # and change cache paths in both treon.yml and convert_notebooks.yml |
| 137 | + case_00030.zip |
| 138 | + notebooks/ct-segmentation-quantize/kits19_frames_1 |
| 139 | + notebooks/pytorch-post-training-quantization-nncf/output/tiny-imagenet-200.zip |
| 140 | + # omz cache location is set to this with test_replace |
| 141 | + notebooks/optical-character-recognition/open_model_zoo_cache |
| 142 | + notebooks/ct-scan-live-inference/kits19_frames_1 |
| 143 | + notebooks/pytorch-quantization-aware-training/data/tiny-imagenet-200.zip |
| 144 | + key: ${{ env.FILES_CACHE_KEY }} |
| 145 | + |
| 146 | + # PaddleGAN stores cache in ppgan directory in CACHE_DIR |
| 147 | + - name: Set CACHE_DIR |
| 148 | + shell: bash |
| 149 | + run: | |
| 150 | + python -c 'import os;print("CACHE_DIR={0}".format(os.path.expanduser(os.path.join("~", ".cache"))))' |
| 151 | + # replace backslashes with forward slashes for Windows paths |
| 152 | + python -c 'import os;print("CACHE_DIR={0}".format(os.path.expanduser(os.path.join("~", ".cache"))))' | sed -e 's/\\/\//g' >> $GITHUB_ENV |
| 153 | +
|
| 154 | + # PaddleHub stores cache in directory pointed to by HUB_HOME environment variable |
| 155 | + - name: Set HUB_HOME |
| 156 | + shell: bash |
| 157 | + run: | |
| 158 | + echo HUB_HOME=${{ env.CACHE_DIR }}/.paddlehub >> $GITHUB_ENV |
| 159 | +
|
| 160 | + # Cache PaddlePaddle cache directories to prevent CI failing due to network/download issues |
| 161 | + - name: Cache PaddlePaddle cache directories |
| 162 | + id: cacheusercache |
| 163 | + uses: actions/cache@v3 |
| 164 | + with: |
| 165 | + path: | |
| 166 | + ${{ env.HUB_HOME }} |
| 167 | + ${{ env.CACHE_DIR }}/paddle |
| 168 | + ${{ env.CACHE_DIR }}/ppgan |
| 169 | + key: ${{ env.USER_CACHE_KEY }}-${{ env.OS_NAME }} |
| 170 | + |
| 171 | + - name: Cache openvino packages |
| 172 | + if: steps.cachepip.outputs.cache-hit != 'true' |
| 173 | + run: | |
| 174 | + python -m pip install --upgrade pip |
| 175 | + mkdir pipcache |
| 176 | + python -m pip install --cache-dir pipcache --no-deps openvino openvino-dev nncf |
| 177 | + cp -r pipcache pipcache_openvino |
| 178 | + # python -m pip uninstall -y openvino openvino-dev nncf |
| 179 | +
|
| 180 | + # Download a small dataset to use for testing purposes in monai-kidney training notebook |
| 181 | + - name: Download CT files |
| 182 | + if: steps.cachefiles.outputs.cache-hit != 'true' |
| 183 | + run: | |
| 184 | + curl -O https://storage.openvinotoolkit.org/data/test_data/openvino_notebooks/kits19/case_00030.zip |
| 185 | + - name: Copy CT files |
| 186 | + run: | |
| 187 | + mkdir notebooks/ct-segmentation-quantize/kits19 |
| 188 | + mkdir notebooks/ct-segmentation-quantize/kits19/kits19_frames |
| 189 | + unzip case_00030.zip |
| 190 | + cp -r case_00030 case_00001 |
| 191 | + mv case_00030 notebooks/ct-segmentation-quantize/kits19/kits19_frames |
| 192 | + mv case_00001 notebooks/ct-segmentation-quantize/kits19/kits19_frames |
| 193 | +
|
| 194 | + # Prevent test aborting by timeout for 'meter-reader' and 'paddle-ocr-webcam' notebooks |
| 195 | + - name: Download long loading models for 'meter-reader' and 'paddle-ocr-webcam' notebooks |
| 196 | + run: | |
| 197 | + mkdir notebooks/meter-reader/model |
| 198 | + curl -o notebooks/meter-reader/model/meter_det_model.tar.gz 'https://storage.openvinotoolkit.org/repositories/openvino_notebooks/models/meter-reader/meter_det_model.tar.gz' |
| 199 | + curl -o notebooks/meter-reader/model/meter_seg_model.tar.gz 'https://storage.openvinotoolkit.org/repositories/openvino_notebooks/models/meter-reader/meter_seg_model.tar.gz' |
| 200 | + mkdir notebooks/paddle-ocr-webcam/model |
| 201 | + curl -o notebooks/paddle-ocr-webcam/model/ch_PP-OCRv3_det_infer.tar 'https://storage.openvinotoolkit.org/repositories/openvino_notebooks/models/paddle-ocr/ch_PP-OCRv3_det_infer.tar' |
| 202 | + curl -o notebooks/paddle-ocr-webcam/model/ch_PP-OCRv3_rec_infer.tar 'https://storage.openvinotoolkit.org/repositories/openvino_notebooks/models/paddle-ocr/ch_PP-OCRv3_rec_infer.tar' |
| 203 | +
|
| 204 | + - name: Install python dependencies |
| 205 | + run: | |
| 206 | + python -m pip install --upgrade pip |
| 207 | + python -m pip install -r .ci/dev-requirements.txt --cache-dir pipcache |
| 208 | + python -m ipykernel install --user --name openvino_env |
| 209 | +
|
| 210 | + # Cache OpenVINO packages (`mv` works cross-platform) |
| 211 | + - name: Make pipcache directory with OpenVINO packages |
| 212 | + if: steps.cachepip.outputs.cache-hit != 'true' |
| 213 | + run: | |
| 214 | + mv pipcache pipcache_full |
| 215 | + mv pipcache_openvino pipcache |
| 216 | +
|
| 217 | + # Create list of installed pip packages that can be downloaded as artifacts |
| 218 | + # to verify the exact environment of a specific test run |
| 219 | + - name: pip freeze |
| 220 | + run: | |
| 221 | + python -m pip freeze |
| 222 | + python -m pip freeze > pip-freeze-${{ env.TEST_DEVICE }}-${{ github.sha }}-${{ env.OS_NAME }}-${{ inputs.python }}.txt |
| 223 | + - name: Upload pip freeze artifact |
| 224 | + uses: actions/upload-artifact@v4 |
| 225 | + with: |
| 226 | + name: pip-freeze-${{ env.TEST_DEVICE }}-${{ env.OS_NAME }}-${{ inputs.python }} |
| 227 | + path: pip-freeze-${{ env.TEST_DEVICE }}-${{ github.sha }}-${{ env.OS_NAME }}-${{ inputs.python }}.txt |
| 228 | + #### End installation/preparation |
| 229 | + |
| 230 | + - name: Check install |
| 231 | + run: | |
| 232 | + python check_install.py |
| 233 | +
|
| 234 | + # Patch long running cells to run faster |
| 235 | + - name: Patch notebooks |
| 236 | + run: | |
| 237 | + python .ci/patch_notebooks.py . -td ${{ env.TEST_DEVICE }} |
| 238 | +
|
| 239 | + # Test that JupyterLab runs without errors |
| 240 | + - name: Test Jupyterlab |
| 241 | + run: | |
| 242 | + jupyter lab notebooks --help |
| 243 | +
|
| 244 | + # Main notebooks test. Verifies that all notebooks run without errors |
| 245 | + - name: Analysing with treon (Windows) python > 3.8 |
| 246 | + if: runner.os == 'Windows' && inputs.python != '3.8' |
| 247 | + shell: bash |
| 248 | + run: | |
| 249 | + python .ci/validate_notebooks.py \ |
| 250 | + ${{ inputs.test_only_changed && '--test_list test_notebooks.txt' || '' }} \ |
| 251 | + --ignore_list .ci/ignore_treon_win.txt \ |
| 252 | + --report_dir test_report/${{ env.TEST_REPORT_DIR }} \ |
| 253 | + --move_notebooks_dir c:/notebooks \ |
| 254 | + --timeout 1200 |
| 255 | + - name: Analysing with treon (Windows) python 3.8 |
| 256 | + if: runner.os == 'Windows' && inputs.python == '3.8' |
| 257 | + shell: bash |
| 258 | + run: | |
| 259 | + python .ci/validate_notebooks.py \ |
| 260 | + ${{ inputs.test_only_changed && '--test_list test_notebooks.txt' || '' }} \ |
| 261 | + --ignore_list .ci/ignore_treon_win.txt .ci/ignore_treon_py38.txt \ |
| 262 | + --report_dir test_report/${{ env.TEST_REPORT_DIR }} \ |
| 263 | + --move_notebooks_dir c:/notebooks \ |
| 264 | + --timeout 1200 |
| 265 | + - name: Analysing with treon (Linux) python > 3.8 |
| 266 | + if: runner.os == 'Linux' && inputs.python != '3.8' |
| 267 | + shell: bash |
| 268 | + run: | |
| 269 | + python .ci/validate_notebooks.py \ |
| 270 | + ${{ inputs.test_only_changed && '--test_list test_notebooks.txt' || '' }} \ |
| 271 | + --ignore_list .ci/ignore_treon_linux.txt ${{ env.TEST_DEVICE == 'gpu' && '.ci/heavy_ubuntu_gpu.txt' || '' }} \ |
| 272 | + --report_dir test_report/${{ env.TEST_REPORT_DIR }} \ |
| 273 | + --timeout 1200 |
| 274 | + - name: Analysing with treon (Linux) python 3.8 |
| 275 | + if: runner.os == 'Linux' && inputs.python == '3.8' |
| 276 | + shell: bash |
| 277 | + run: | |
| 278 | + python .ci/validate_notebooks.py \ |
| 279 | + ${{ inputs.test_only_changed && '--test_list test_notebooks.txt' || '' }} \ |
| 280 | + --ignore_list .ci/ignore_treon_linux.txt .ci/ignore_treon_py38.txt ${{ env.TEST_DEVICE == 'gpu' && '.ci/heavy_ubuntu_gpu.txt' || '' }} \ |
| 281 | + --report_dir test_report/${{ env.TEST_REPORT_DIR }} \ |
| 282 | + --timeout 1200 |
| 283 | + - name: Analysing with treon (MacOS) python > 3.8 |
| 284 | + if: runner.os == 'MacOS' && inputs.python != '3.8' |
| 285 | + shell: bash |
| 286 | + run: | |
| 287 | + python .ci/validate_notebooks.py \ |
| 288 | + ${{ inputs.test_only_changed && '--test_list test_notebooks.txt' || '' }} \ |
| 289 | + --ignore_list .ci/ignore_treon_mac.txt \ |
| 290 | + --report_dir test_report/${{ env.TEST_REPORT_DIR }} \ |
| 291 | + --timeout 1200 |
| 292 | + - name: Analysing with treon (MacOS) python 3.8 |
| 293 | + if: runner.os == 'MacOS' && inputs.python == '3.8' |
| 294 | + shell: bash |
| 295 | + run: | |
| 296 | + python .ci/validate_notebooks.py \ |
| 297 | + ${{ inputs.test_only_changed && '--test_list test_notebooks.txt' || '' }} \ |
| 298 | + --ignore_list .ci/ignore_treon_mac.txt .ci/ignore_treon_py38.txt \ |
| 299 | + --report_dir test_report/${{ env.TEST_REPORT_DIR }} \ |
| 300 | + --timeout 1200 |
| 301 | +
|
| 302 | + - name: Archive notebook test report |
| 303 | + if: always() |
| 304 | + uses: actions/upload-artifact@v4 |
| 305 | + with: |
| 306 | + name: test_report-${{ env.TEST_REPORT_DIR }} |
| 307 | + path: test_report/ |
| 308 | + |
| 309 | + # Show the cache after running the notebooks |
| 310 | + - name: Show cache |
| 311 | + if: runner.os != 'Windows' |
| 312 | + run: | |
| 313 | + ls -laR ${{ env.CACHE_DIR }} |
| 314 | + du -sh ${{ env.CACHE_DIR }} |
0 commit comments