|
| 1 | +name: Keras 3 OpenVINO Backend |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + runner: |
| 7 | + description: 'Machine on which the tests would run' |
| 8 | + type: string |
| 9 | + required: true |
| 10 | + container: |
| 11 | + description: 'JSON to be converted to the value of the "container" configuration for the job' |
| 12 | + type: string |
| 13 | + required: false |
| 14 | + default: '{"image": null}' |
| 15 | + python-version: |
| 16 | + description: 'Python version to setup. E.g., "3.11"' |
| 17 | + type: string |
| 18 | + required: true |
| 19 | + |
| 20 | +permissions: read-all |
| 21 | + |
| 22 | +env: |
| 23 | + PIP_CACHE_PATH_LINUX: /mount/caches/pip/linux |
| 24 | + PIP_CACHE_PATH_WIN: "C:\\mount\\caches\\pip\\win" |
| 25 | + |
| 26 | +jobs: |
| 27 | + Keras3_OpenVINO_Backend: |
| 28 | + name: Keras 3 OpenVINO Backend |
| 29 | + timeout-minutes: 10 |
| 30 | + defaults: |
| 31 | + run: |
| 32 | + shell: ${{ contains(inputs.runner, 'win') && 'pwsh' || 'bash' }} |
| 33 | + runs-on: ${{ inputs.runner }} |
| 34 | + container: ${{ fromJSON(inputs.container) }} |
| 35 | + env: |
| 36 | + INSTALL_DIR: ${{ github.workspace }}/install |
| 37 | + INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests |
| 38 | + INSTALL_WHEELS_DIR: ${{ github.workspace }}/install/wheels |
| 39 | + KERAS_REPO: ${{ github.workspace }}/keras_repo |
| 40 | + KERAS_HOME: ${{ github.workspace }}/keras_repo/.github/workflows/config/openvino |
| 41 | + |
| 42 | + steps: |
| 43 | + # Needed as ${{ github.workspace }} is not working correctly when using Docker |
| 44 | + - name: Setup Variables |
| 45 | + run: | |
| 46 | + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" |
| 47 | + echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV" |
| 48 | + echo "INSTALL_WHEELS_DIR=$GITHUB_WORKSPACE/install/wheels" >> "$GITHUB_ENV" |
| 49 | + echo "KERAS_REPO=$GITHUB_WORKSPACE/keras" >> "$GITHUB_ENV" |
| 50 | + echo "KERAS_HOME=$GITHUB_WORKSPACE/keras/.github/workflows/config/openvino" >> "$GITHUB_ENV" |
| 51 | +
|
| 52 | + - name: Fetch setup_python and install wheels actions |
| 53 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 54 | + timeout-minutes: 15 |
| 55 | + with: |
| 56 | + sparse-checkout: | |
| 57 | + .github/actions/setup_python/action.yml |
| 58 | + .github/actions/install_ov_wheels/action.yml |
| 59 | + sparse-checkout-cone-mode: false |
| 60 | + path: 'openvino' |
| 61 | + |
| 62 | + - name: Clone Keras 3 repository |
| 63 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 64 | + timeout-minutes: 15 |
| 65 | + with: |
| 66 | + repository: 'keras-team/keras' |
| 67 | + path: ${{ env.KERAS_REPO }} |
| 68 | + ref: 'master' |
| 69 | + |
| 70 | + - name: Download OpenVINO artifacts (wheels) |
| 71 | + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 72 | + with: |
| 73 | + pattern: openvino_[wheels|openvino_tokenizers]* |
| 74 | + path: ${{ env.INSTALL_WHEELS_DIR }} |
| 75 | + merge-multiple: true |
| 76 | + |
| 77 | + - name: Setup Python ${{ inputs.python-version }} |
| 78 | + uses: ./openvino/.github/actions/setup_python |
| 79 | + with: |
| 80 | + version: ${{ inputs.python-version }} |
| 81 | + pip-cache-path: ${{ runner.os == 'Linux' && env.PIP_CACHE_PATH_LINUX || env.PIP_CACHE_PATH_WIN }} |
| 82 | + should-setup-pip-paths: ${{ runner.os != 'macOS' }} |
| 83 | + self-hosted-runner: ${{ runner.os != 'macOS' }} |
| 84 | + |
| 85 | + - name: Install OpenVINO Python wheels |
| 86 | + uses: ./openvino/.github/actions/install_ov_wheels |
| 87 | + with: |
| 88 | + wheels-dir-path: ${{ env.INSTALL_WHEELS_DIR }} |
| 89 | + wheels-to-install: 'openvino openvino_tokenizers' |
| 90 | + |
| 91 | + - name: Install test dependencies |
| 92 | + working-directory: ${{ env.KERAS_REPO }} |
| 93 | + run: | |
| 94 | + pip install -r requirements.txt --upgrade |
| 95 | + # make sure that no other keras is installed via pip |
| 96 | + pip uninstall -y keras keras-nightly |
| 97 | + # manually set keras |
| 98 | + echo "PYTHONPATH=$KERAS_REPO:$PYTHONPATH" >> "$GITHUB_ENV" |
| 99 | +
|
| 100 | + - name: Test integrations |
| 101 | + working-directory: ${{ env.KERAS_REPO }} |
| 102 | + run: | |
| 103 | + python integration_tests/import_test.py --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-keras3_integration1.xml |
| 104 | + python integration_tests/numerical_test.py --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-keras3_integration2.xml |
| 105 | +
|
| 106 | + - name: Test with pytest |
| 107 | + working-directory: ${{ env.KERAS_REPO }} |
| 108 | + run: | |
| 109 | + IGNORE_FILE="keras/src/backend/openvino/excluded_tests.txt" |
| 110 | + IGNORE_ARGS=$(awk '{print "--ignore=" $0}' "$IGNORE_FILE") |
| 111 | + pytest keras --ignore keras/src/applications $IGNORE_ARGS --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-keras3_pytest.xml |
| 112 | +
|
| 113 | + - name: Upload Test Results |
| 114 | + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 |
| 115 | + if: ${{ !cancelled() }} |
| 116 | + with: |
| 117 | + name: test-results-keras3-backend |
| 118 | + path: | |
| 119 | + ${{ env.INSTALL_TEST_DIR }}/TEST*.html |
| 120 | + ${{ env.INSTALL_TEST_DIR }}/TEST*.xml |
| 121 | + if-no-files-found: 'warn' |
0 commit comments