Skip to content

Pass Python strings to TextVectorization standardize on non-TF backends #11808

Pass Python strings to TextVectorization standardize on non-TF backends

Pass Python strings to TextVectorization standardize on non-TF backends #11808

Workflow file for this run

name: Tests
# TODO: Consider enabling all tests (pytest, applications, etc.) with NNX in the future
# Currently only basic flow tests run with NNX enabled
on:
push:
branches: [ master ]
pull_request:
release:
types: [created]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
run_cpu_tests:
strategy:
fail-fast: false
matrix:
backend: [tensorflow, jax, torch, numpy, openvino]
nnx_enabled: [false]
include:
- backend: jax
nnx_enabled: true
container:
image: python:3.11-slim
options: --privileged --network host
name: ${{ format('Run tests on CPU ({0}{1})', matrix.backend, matrix.nnx_enabled && ', NNX' || '') }}
runs-on: linux-x86-n2-16
env:
KERAS_HOME: .github/workflows/config/${{ matrix.backend }}
steps:
- name: Install binary dependencies
run: |
apt-get update
apt-get -y install build-essential
apt-get -y install curl
apt-get -y install git
apt-get -y install gnupg
git config --global --add safe.directory '*'
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v6
- name: Check for changes in keras/src/applications
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: filter
with:
filters: |
applications:
- 'keras/src/applications/**'
- name: Install Python dependencies
run: |
pip install -r requirements.txt
pip install --no-deps tf_keras
- name: Test applications with pytest
if: ${{ steps.filter.outputs.applications == 'true' && matrix.nnx_enabled == false }}
run: |
pytest keras/src/applications --cov=keras/src/applications --cov-config=pyproject.toml
coverage xml --include='keras/src/applications/*' -o apps-coverage.xml
- name: Codecov keras.applications
if: ${{ steps.filter.outputs.applications == 'true' && matrix.nnx_enabled == false }}
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v5
with:
env_vars: PYTHON,KERAS_HOME
flags: keras.applications,keras.applications-${{ matrix.backend }}
files: apps-coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Test integrations
if: ${{ matrix.backend != 'numpy' && matrix.nnx_enabled == false }}
run: |
python integration_tests/import_test.py
python integration_tests/numerical_test.py
- name: Test JAX-specific integrations
if: ${{ matrix.backend == 'jax' && matrix.nnx_enabled == false }}
run: |
python integration_tests/jax_custom_fit_test.py
- name: Test basic flow with NNX
if: ${{ matrix.nnx_enabled == true }}
env:
KERAS_NNX_ENABLED: true
run: |
python integration_tests/import_test.py
python integration_tests/basic_full_flow.py
- name: Test TF-specific integrations
if: ${{ matrix.backend == 'tensorflow'}}
run: |
python integration_tests/tf_distribute_training_test.py
python integration_tests/tf_custom_fit_test.py
- name: Test Torch-specific integrations
if: ${{ matrix.backend == 'torch'}}
run: |
pytest integration_tests/torch_workflow_test.py
python integration_tests/torch_custom_fit_test.py
- name: Run Tests
if: ${{ matrix.nnx_enabled == false }}
run: |
pytest keras --ignore keras/src/applications --cov=keras --cov-config=pyproject.toml $PYTEST_ARGS
coverage xml --omit='keras/src/applications/*,keras/api' -o core-coverage.xml
- name: Run Multi-Device Tests
if: ${{ matrix.backend == 'jax' }}
run: JAX_NUM_CPU_DEVICES=4 pytest keras -m multi_device
- name: Codecov keras
if: ${{ matrix.nnx_enabled == false }}
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v5
with:
env_vars: PYTHON,KERAS_HOME,KERAS_NNX_ENABLED
flags: keras,keras-${{ matrix.backend }}${{ matrix.nnx_enabled == 'true' && '-nnx' || '' }}
files: core-coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
format:
name: Check the code format
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip setuptools
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v5
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('requirements.txt') }}
- name: Install dependencies
run: pip install -r requirements.txt --upgrade
- name: Run pre-commit
run: pre-commit run --all-files --hook-stage manual