Skip to content

Commit cb665d6

Browse files
fcholletShallow Copy Bot
authored andcommitted
Fix KerasFileEditor tests
0 parents  commit cb665d6

File tree

819 files changed

+205225
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

819 files changed

+205225
-0
lines changed

.devcontainer/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Dev container configurations
2+
3+
This directory contains the configuration for dev containers, which is used to
4+
initialize the development environment in **Codespaces**, **Visual Studio
5+
Code**, and **JetBrains IDEs**. The environment is installed with all the
6+
necessary dependencies for development and is ready for linting, formatting, and
7+
running tests.
8+
9+
* **GitHub Codespaces**. Create a codespace for the repo by clicking
10+
the "Code" button on the main page of the repo, selecting the "Codespaces"
11+
tab, and clicking the "+". The configurations will automatically be used.
12+
Follow
13+
[this guide](https://docs.github.com/en/codespaces/developing-in-a-codespace/creating-a-codespace-for-a-repository)
14+
for more details.
15+
16+
* **Visual Studio Code**. Open the root folder of the repo in VS Code. A
17+
notification will pop up to open it in a dev container with the
18+
configuration. Follow
19+
[this guide](https://code.visualstudio.com/docs/devcontainers/tutorial)
20+
for more details.
21+
22+
* **JetBrains IDEs**. Open the `.devcontainer/devcontainer.json` in your
23+
JetBrains IDE. Click the docker icon to create a dev container.
24+
Follow
25+
[this guide](https://www.jetbrains.com/help/idea/connect-to-devcontainer.html)
26+
for more details.

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.10",
3+
"postCreateCommand": "sh ./.devcontainer/setup.sh && pip install -r requirements.txt",
4+
"customizations": {
5+
"vscode": {
6+
"settings": {
7+
"python.testing.pytestEnabled": true,
8+
"editor.formatOnSave": true,
9+
"editor.codeActionsOnSave": {
10+
"source.organizeImports": true
11+
},
12+
"[python]": {
13+
"editor.defaultFormatter": "ms-python.black-formatter"
14+
},
15+
"editor.rulers": [
16+
80
17+
]
18+
},
19+
"extensions": [
20+
"ms-python.python",
21+
"ms-python.isort",
22+
"ms-python.flake8",
23+
"ms-python.black-formatter"
24+
]
25+
}
26+
},
27+
"features": {
28+
"ghcr.io/devcontainers/features/github-cli:1": {}
29+
}
30+
}

.devcontainer/setup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sudo pip install --upgrade pip
2+
sudo pip install -r requirements.txt
3+
echo "bash shell/lint.sh" > .git/hooks/pre-commit
4+
chmod a+x .git/hooks/pre-commit

.github/dependabot.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"
12+
groups:
13+
github-actions:
14+
patterns:
15+
- "*"
16+
- package-ecosystem: "pip"
17+
directory: "/"
18+
schedule:
19+
interval: "monthly"
20+
groups:
21+
python:
22+
patterns:
23+
- "*"
24+
ignore:
25+
# TODO: ignore all updates for JAX GPU due to cuda version issue
26+
- dependency-name: "jax[cuda12_pip]"

.github/workflows/actions.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
release:
8+
types: [created]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version: [3.9]
19+
backend: [tensorflow, jax, torch, numpy]
20+
name: Run tests
21+
runs-on: ubuntu-latest
22+
env:
23+
PYTHON: ${{ matrix.python-version }}
24+
KERAS_HOME: .github/workflows/config/${{ matrix.backend }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Check for changes in keras/src/applications
28+
uses: dorny/paths-filter@v3
29+
id: filter
30+
with:
31+
filters: |
32+
applications:
33+
- 'keras/src/applications/**'
34+
- name: Set up Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
- name: Get pip cache dir
39+
id: pip-cache
40+
run: |
41+
python -m pip install --upgrade pip setuptools
42+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
43+
- name: pip cache
44+
uses: actions/cache@v4
45+
with:
46+
path: ${{ steps.pip-cache.outputs.dir }}
47+
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}
48+
- name: Install dependencies
49+
run: |
50+
pip install -r requirements.txt --progress-bar off --upgrade
51+
pip uninstall -y keras keras-nightly
52+
pip install tf_keras==2.16.0 --progress-bar off --upgrade
53+
pip install -e "." --progress-bar off --upgrade
54+
- name: Test applications with pytest
55+
if: ${{ steps.filter.outputs.applications == 'true' }}
56+
run: |
57+
pytest keras/src/applications --cov=keras/src/applications
58+
coverage xml --include='keras/src/applications/*' -o apps-coverage.xml
59+
- name: Codecov keras.applications
60+
if: ${{ steps.filter.outputs.applications == 'true' }}
61+
uses: codecov/codecov-action@v4
62+
with:
63+
env_vars: PYTHON,KERAS_HOME
64+
flags: keras.applications,keras.applications-${{ matrix.backend }}
65+
files: apps-coverage.xml
66+
token: ${{ secrets.CODECOV_TOKEN }}
67+
fail_ci_if_error: false
68+
- name: Test integrations
69+
if: ${{ matrix.backend != 'numpy'}}
70+
run: |
71+
python integration_tests/import_test.py
72+
python integration_tests/numerical_test.py
73+
- name: Test TF-specific integrations
74+
if: ${{ matrix.backend == 'tensorflow'}}
75+
run: |
76+
python integration_tests/tf_distribute_training_test.py
77+
- name: Test Torch-specific integrations
78+
if: ${{ matrix.backend == 'torch'}}
79+
run: |
80+
pytest integration_tests/torch_workflow_test.py
81+
- name: Test with pytest
82+
run: |
83+
pytest keras --ignore keras/src/applications --cov=keras
84+
coverage xml --omit='keras/src/applications/*,keras/api' -o core-coverage.xml
85+
- name: Codecov keras
86+
uses: codecov/codecov-action@v4
87+
with:
88+
env_vars: PYTHON,KERAS_HOME
89+
flags: keras,keras-${{ matrix.backend }}
90+
files: core-coverage.xml
91+
token: ${{ secrets.CODECOV_TOKEN }}
92+
fail_ci_if_error: false
93+
94+
format:
95+
name: Check the code format
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@v4
99+
- name: Set up Python 3.9
100+
uses: actions/setup-python@v5
101+
with:
102+
python-version: '3.9'
103+
- name: Get pip cache dir
104+
id: pip-cache
105+
run: |
106+
python -m pip install --upgrade pip setuptools
107+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
108+
- name: pip cache
109+
uses: actions/cache@v4
110+
with:
111+
path: ${{ steps.pip-cache.outputs.dir }}
112+
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}
113+
- name: Install dependencies
114+
run: |
115+
pip install -r requirements.txt --progress-bar off --upgrade
116+
pip uninstall -y keras keras-nightly
117+
pip install -e "." --progress-bar off --upgrade
118+
- name: Lint
119+
run: bash shell/lint.sh
120+
- name: Check for API changes
121+
run: |
122+
bash shell/api_gen.sh
123+
git status
124+
clean=$(git status | grep "nothing to commit")
125+
if [ -z "$clean" ]; then
126+
echo "Please run shell/api_gen.sh to generate API."
127+
exit 1
128+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: auto-assignment
2+
on:
3+
issues:
4+
types:
5+
- opened
6+
7+
permissions:
8+
contents: read
9+
issues: write
10+
pull-requests: write
11+
12+
jobs:
13+
welcome:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const script = require('./\.github/workflows/scripts/auto-assignment.js')
21+
script({github, context})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"floatx": "float32",
3+
"epsilon": 1e-07,
4+
"backend": "jax",
5+
"image_data_format": "channels_last"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"floatx": "float32",
3+
"epsilon": 1e-07,
4+
"backend": "numpy",
5+
"image_data_format": "channels_last"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"floatx": "float32",
3+
"epsilon": 1e-07,
4+
"backend": "tensorflow",
5+
"image_data_format": "channels_last"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"floatx": "float32",
3+
"epsilon": 1e-07,
4+
"backend": "torch",
5+
"image_data_format": "channels_first"
6+
}

0 commit comments

Comments
 (0)