@@ -12,65 +12,118 @@ permissions:
12
12
13
13
jobs :
14
14
run_tests :
15
- name : Test the code
15
+ name : Test the code on CPU
16
+ runs-on : ubuntu-latest
17
+
16
18
strategy :
17
19
fail-fast : false
18
20
matrix :
19
21
backend : [tensorflow, jax, torch]
20
- runs-on : ubuntu-latest
22
+
21
23
env :
22
24
KERAS_BACKEND : ${{ matrix.backend }}
25
+
23
26
steps :
24
27
- uses : actions/checkout@v4
25
- - name : Set up Python 3.11
26
- uses : actions/setup-python@v5
28
+
29
+ - uses : actions/setup-python@v5
27
30
with :
28
31
python-version : " 3.11"
32
+
29
33
- name : Get pip cache dir
30
34
id : pip-cache
31
35
run : |
32
- python -m pip install --upgrade pip setuptools
36
+ python -m pip install --upgrade pip
33
37
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
34
- - name : pip cache
35
- uses : actions/cache@v4
38
+
39
+ - uses : actions/cache@v4
36
40
with :
37
41
path : ${{ steps.pip-cache.outputs.dir }}
38
42
key : ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
39
43
restore-keys : |
40
44
${{ runner.os }}-pip-
45
+
41
46
- name : Install dependencies
42
- run : |
43
- pip install -r requirements.txt --progress-bar off
44
- pip install --no-deps -e "." --progress-bar off
47
+ run : pip install -r requirements.txt --progress-bar off
48
+
45
49
- name : Test with pytest
50
+ run : pytest keras_rs/
51
+
52
+ run_tests_in_container :
53
+ name : Test the code on TPU
54
+ runs-on : linux-x86-ct6e-44-1tpu
55
+
56
+ strategy :
57
+ fail-fast : false
58
+ matrix :
59
+ backend : [tensorflow, jax]
60
+
61
+ container :
62
+ image : python:3.11-slim
63
+ options : --privileged --network host
64
+
65
+ steps :
66
+ - uses : actions/checkout@v4
67
+
68
+ - name : Install Dependencies
69
+ run : |
70
+ pip install --no-cache-dir -U pip && \
71
+ pip install --no-cache-dir -r requirements-${{ matrix.backend }}-tpu.txt
72
+
73
+ - name : Set Keras Backend
46
74
run : |
47
- pytest keras_rs/
75
+ echo "KERAS_BACKEND=${{ matrix.backend }}" >> $GITHUB_ENV
76
+ echo "TPU_NAME=local" >> $GITHUB_ENV
77
+
78
+ - name : Set TF Specific Environment Variables
79
+ if : ${{ matrix.backend == 'tensorflow'}}
80
+ run : |
81
+ echo "PJRT_DEVICE=TPU" >> $GITHUB_ENV
82
+ echo "NEXT_PLUGGABLE_DEVICE_USE_C_API=true" >> $GITHUB_ENV
83
+ echo "TF_XLA_FLAGS=--tf_mlir_enable_mlir_bridge=true" >> $GITHUB_ENV
84
+ pip show libtpu | grep "^Location: " | sed "s/^Location: \(.*\)$/TF_PLUGGABLE_DEVICE_LIBRARY_PATH=\1\/libtpu\/libtpu.so/1" >> $GITHUB_ENV
85
+
86
+ - name : Verify TF Installation
87
+ if : ${{ matrix.backend == 'tensorflow'}}
88
+ run : python3 -c "import tensorflow as tf; print('Tensorflow devices:', tf.config.list_logical_devices())"
89
+
90
+ - name : Verify JAX Installation
91
+ if : ${{ matrix.backend == 'jax'}}
92
+ run : python3 -c "import jax; print('JAX devices:', jax.devices())"
93
+
94
+ - name : Test with pytest
95
+ run : pytest keras_rs/src/layers/embedding/distributed_embedding_test.py
96
+
48
97
check_format :
49
98
name : Check the code format
50
99
runs-on : ubuntu-latest
100
+
51
101
steps :
52
- - uses : actions/checkout@v4
53
- - name : Set up Python 3.11
54
- uses : actions/setup-python@v5
55
- with :
56
- python-version : " 3.11"
57
- - name : Get pip cache dir
58
- id : pip-cache
59
- run : |
60
- python -m pip install --upgrade pip setuptools
61
- echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
62
- - name : pip cache
63
- uses : actions/cache@v4
64
- with :
65
- path : ${{ steps.pip-cache.outputs.dir }}
66
- key : ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
67
- restore-keys : |
68
- ${{ runner.os }}-pip-
69
- - name : Install dependencies
70
- run : |
71
- pip install -r requirements.txt --progress-bar off
72
- pip install --no-deps -e "." --progress-bar off
73
- - name : Install pre-commit
74
- run : pip install pre-commit && pre-commit install
75
- - name : Run pre-commit
76
- run : pre-commit run --all-files --hook-stage manual
102
+ - uses : actions/checkout@v4
103
+
104
+ - uses : actions/setup-python@v5
105
+ with :
106
+ python-version : " 3.11"
107
+
108
+ - name : Get pip cache dir
109
+ id : pip-cache
110
+ run : |
111
+ python -m pip install --upgrade pip
112
+ echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
113
+
114
+ - uses : actions/cache@v4
115
+ with :
116
+ path : ${{ steps.pip-cache.outputs.dir }}
117
+ key : ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
118
+ restore-keys : |
119
+ ${{ runner.os }}-pip-
120
+
121
+ - name : Install dependencies
122
+ run : |
123
+ pip install -r requirements.txt --progress-bar off
124
+
125
+ - name : Install pre-commit
126
+ run : pip install pre-commit && pre-commit install
127
+
128
+ - name : Run pre-commit
129
+ run : pre-commit run --all-files --hook-stage manual
0 commit comments