Skip to content

Commit 2538de0

Browse files
authored
143 Retry for ml tests. (#146)
* Add pytest-retry enabling retries for flapping ml tests. * Run notebooks and examples with all supported Python versions. Signed-off-by: chenkins <[email protected]> * Fix notebooks require redis - run them in separate tox to enhance parallelization in gh. Signed-off-by: chenkins <[email protected]> --------- Signed-off-by: chenkins <[email protected]>
1 parent e61d56a commit 2538de0

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

.github/workflows/checks.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ jobs:
5252

5353
notebooks:
5454
runs-on: ubuntu-22.04
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
python-version: [ "3.10", "3.11", "3.12" ]
5559
steps:
5660
- uses: actions/checkout@v4
5761
- name: Set up Python ${{ matrix.python-version }}
5862
uses: actions/setup-python@v5
5963
with:
60-
python-version: "3.10"
64+
python-version: ${{ matrix.python-version }}
6165
- name: Start Redis
6266
uses: supercharge/[email protected]
6367
with:
@@ -72,12 +76,16 @@ jobs:
7276

7377
examples:
7478
runs-on: ubuntu-22.04
79+
strategy:
80+
fail-fast: false
81+
matrix:
82+
python-version: [ "3.10", "3.11", "3.12" ]
7583
steps:
7684
- uses: actions/checkout@v4
7785
- name: Set up Python ${{ matrix.python-version }}
7886
uses: actions/setup-python@v5
7987
with:
80-
python-version: "3.10"
88+
python-version: ${{ matrix.python-version }}
8189
- name: Install tox
8290
run: |
8391
python -m pip install --upgrade pip

.github/workflows/main.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ jobs:
5454

5555
notebooks:
5656
runs-on: ubuntu-22.04
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
python-version: [ "3.10", "3.11", "3.12" ]
5761
steps:
5862
- uses: actions/checkout@v4
5963
- name: Set up Python ${{ matrix.python-version }}
6064
uses: actions/setup-python@v5
6165
with:
62-
python-version: "3.10"
66+
python-version: ${{ matrix.python-version }}
6367
- name: Start Redis
6468
uses: supercharge/[email protected]
6569
with:
@@ -74,12 +78,16 @@ jobs:
7478

7579
examples:
7680
runs-on: ubuntu-22.04
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
python-version: [ "3.10", "3.11", "3.12" ]
7785
steps:
7886
- uses: actions/checkout@v4
79-
- name: Set up Python
87+
- name: Set up Python ${{ matrix.python-version }}
8088
uses: actions/setup-python@v5
8189
with:
82-
python-version: "3.10"
90+
python-version: ${{ matrix.python-version }}
8391
- name: Install tox
8492
run: |
8593
python -m pip install --upgrade pip

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ dev = [
6565
"numpydoc",
6666
"pip-tools",
6767
"pytest",
68+
"pytest-retry",
6869
"snakeviz",
6970
"tox",
7071
"twine",

requirements-dev.txt

+3
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ pytest==8.3.4
438438
# via
439439
# flatland-rl (pyproject.toml)
440440
# nbmake
441+
# pytest-retry
442+
pytest-retry==1.7.0
443+
# via flatland-rl (pyproject.toml)
441444
python-dateutil==2.9.0.post0
442445
# via
443446
# arrow

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,6 @@ wcwidth==0.2.13
177177
# via prompt-toolkit
178178
widgetsnbextension==4.0.13
179179
# via ipywidgets
180+
181+
# The following packages are considered to be unsafe in a requirements file:
182+
# setuptools

tox.ini

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
env_list = py{310,311,312},notebooks,py{310,311,312}-ml,py{310,311,312}-verify-install
2+
env_list = py{310,311,312},py{310,311,312}-ml,py{310,311,312}-verify-install
33

44
[gh-actions]
55
python =
@@ -38,6 +38,7 @@ deps =
3838
set_env =
3939
BENCHMARK_EPISODES_FOLDER = {tox_root}/episodes
4040
commands =
41+
python --version
4142
python -m pytest {posargs} --ignore=tests/ml
4243

4344
[testenv:py{310,311,312}-ml]
@@ -49,7 +50,7 @@ deps =
4950
-r requirements-ml.txt
5051
commands =
5152
python --version
52-
python -m pytest {posargs}
53+
python -m pytest --retries 2 --retry-delay 5 {posargs}
5354

5455
[testenv:lint]
5556
base_python = python3.10
@@ -83,22 +84,24 @@ set_env =
8384
commands =
8485
python benchmarks/profile_all_examples.py
8586

86-
[testenv:examples]
87-
base_python = python3.10
87+
[testenv:py{310,311,312}-examples]
88+
platform = linux|linux2|darwin
8889
deps =
8990
-r requirements-dev.txt
9091
commands =
92+
python --version
9193
python benchmarks/run_all_examples.py
9294

93-
[testenv:notebooks]
94-
base_python = python3.10
95+
[testenv:py{310,311,312}-notebooks]
96+
platform = linux|linux2|darwin
9597
allowlist_externals =
9698
bash
9799
pwd
98100
deps =
99101
-r requirements-dev.txt
100102
commands =
101-
python -m pytest --nbmake \
103+
python --version
104+
python -m pytest -s --nbmake \
102105
notebooks/simple-graph-plot-2022.ipynb \
103106
notebooks/Agent-Close-Following.ipynb \
104107
notebooks/simple_example_manual_control.ipynb \

0 commit comments

Comments
 (0)