-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI test for RL examples: Drive and VehicleFollowing #2062
Changes from all commits
1c6566a
9c2fa46
3765fa9
a24e134
f8a16ee
e5c6cb9
d9fa0e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ env: | |
venv_dir: .venv | ||
|
||
jobs: | ||
base-tests-linux: | ||
base-tests: | ||
runs-on: ubuntu-20.04 | ||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository | ||
container: ghcr.io/smarts-project/smarts:v0.6.1-minimal | ||
|
@@ -19,8 +19,8 @@ jobs: | |
- ./smarts/env --ignore=./smarts/env/tests/test_rllib_hiway_env.py | ||
- ./smarts/env/tests/test_rllib_hiway_env.py | ||
- ./smarts/sstudio | ||
- ./examples/tests --ignore=./examples/tests/test_learning.py | ||
- ./smarts/ray | ||
- ./examples/tests/test_examples.py | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -31,12 +31,25 @@ jobs: | |
pip install --upgrade pip | ||
pip install wheel==0.38.4 | ||
pip install -e .[camera_obs,opendrive,test,test_notebook,torch,train,gym,argoverse,envision,sumo] | ||
if echo ${{matrix.tests}} | grep -q -e "env" -e "examples"; then pip install -e .[rllib]; fi | ||
if echo ${{matrix.tests}} | grep -q "/ray"; then pip install -e .[ray]; fi | ||
if echo ${{matrix.tests}} | grep -q -e "test_rllib_hiway_env.py" -e "test_examples.py"; then pip install -e .[rllib]; fi | ||
if echo ${{matrix.tests}} | grep -q -e "/smarts/ray"; then pip install -e .[ray]; fi | ||
- name: Build scenarios | ||
run: | | ||
. ${{env.venv_dir}}/bin/activate | ||
scl scenario build-all \ | ||
scenarios/open_drive/od_4lane \ | ||
scenarios/open_drive/od_merge \ | ||
scenarios/sumo/figure_eight \ | ||
scenarios/sumo/intersections/2lane \ | ||
scenarios/sumo/intersections/4lane \ | ||
scenarios/sumo/intersections/6lane \ | ||
scenarios/sumo/loop \ | ||
scenarios/sumo/straight/3lane_bubble \ | ||
scenarios/sumo/tests/multi_agents_loop \ | ||
scenarios/sumo/zoo_intersection | ||
- name: Run smoke tests | ||
run: | | ||
. ${{env.venv_dir}}/bin/activate | ||
make build-all-scenarios | ||
PYTHONPATH=$PWD PYTHONHASHSEED=42 pytest -v \ | ||
--doctest-modules \ | ||
--forked \ | ||
|
@@ -49,5 +62,36 @@ jobs: | |
--ignore=./smarts/core/tests/test_smarts_memory_growth.py \ | ||
--ignore=./smarts/core/tests/test_env_frame_rate.py \ | ||
--ignore=./smarts/env/tests/test_benchmark.py \ | ||
--ignore=./examples/tests/test_learning.py \ | ||
-k 'not test_long_determinism' | ||
|
||
examples-rl: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How long do these two tests take to run? We would want the total to be ~2 mins or less. Otherwise, we will need to put it on some other schedule than always run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
runs-on: ubuntu-20.04 | ||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository | ||
container: ghcr.io/smarts-project/smarts:v0.6.1-minimal | ||
strategy: | ||
matrix: | ||
tests: | ||
- drive | ||
- platoon | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install dependencies | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/examples/rl/${{matrix.tests}} | ||
python3.8 -m venv ${{env.venv_dir}} | ||
. ${{env.venv_dir}}/bin/activate | ||
pip install --upgrade pip | ||
pip install wheel==0.38.4 | ||
pip install -e ./../../../.[camera_obs,argoverse,sumo,test] | ||
pip install -e ./inference/ | ||
- name: Run smoke tests | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/examples/rl/${{matrix.tests}} | ||
. ${{env.venv_dir}}/bin/activate | ||
PYTHONPATH=$PWD PYTHONHASHSEED=42 pytest -v \ | ||
--doctest-modules \ | ||
--forked \ | ||
--dist=no \ | ||
-n auto \ | ||
${GITHUB_WORKSPACE}/examples/tests/test_rl.py::test_${{matrix.tests}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import argparse | ||
from pathlib import Path | ||
from unittest import mock | ||
|
||
from smarts.core.utils import import_utils | ||
|
||
import_utils.import_module_from_file( | ||
"examples", Path(__file__).parents[1] / "__init__.py" | ||
) | ||
|
||
|
||
def _mock_load_config(load_config): | ||
def func(): | ||
config = load_config() | ||
config.alg["n_steps"] = 4 | ||
config.alg["batch_size"] = 2 | ||
config.alg["n_epochs"] = 2 | ||
config.epochs = 2 * len(config.scenarios) | ||
config.train_steps = 8 | ||
config.checkpoint_freq = 10000 | ||
config.eval_freq = 10000 | ||
return config | ||
|
||
return func | ||
|
||
|
||
def test_platoon(): | ||
"""Tests RL training of `examples/rl/platoon` example.""" | ||
|
||
from examples.rl.platoon.train.run import load_config, main | ||
|
||
args = argparse.Namespace() | ||
args.mode = "train" | ||
args.logdir = None | ||
args.model = None | ||
args.head = False | ||
|
||
with mock.patch( | ||
"examples.rl.platoon.train.run.load_config", | ||
_mock_load_config(load_config), | ||
): | ||
main(args) | ||
|
||
|
||
def test_drive(): | ||
"""Tests RL training of `examples/rl/drive` example.""" | ||
from examples.rl.drive.train.run import load_config, main | ||
|
||
args = argparse.Namespace() | ||
args.mode = "train" | ||
args.logdir = None | ||
args.model = None | ||
args.head = False | ||
|
||
with mock.patch( | ||
"examples.rl.drive.train.run.load_config", | ||
_mock_load_config(load_config), | ||
): | ||
main(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not against it but is there any reason to change the name of the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the addition of more jobs in the same workflow, following the original naming style, each of the job would have been suffixed with
-linux
. The suffix appeared a little repetitive, given the workflow's name ofSMARTS CI Base Tests Linux
which indicates it is for Linux. In short, the change was for aesthetics. This is how the test results look like now.