Skip to content

Commit dee6972

Browse files
authored
Add pytests (#127)
* Add pytests * test experts * Changed the padding position (#126) * Mark agents as static if they spawn near goal (#125) * Init static agents * Fix the compile error * Formatting * Add some rendering support * Check the first valid state against goal * Working test on experts * Configure pytests * Add pytest to github workflow * remove sample test * Updated poetry lock * Remove unnecassry imports * Build in release mode * Remove poetry lock file * Reduced consts to use less memory * Update manual.yml * upload dumps * Dont init agents if not valid on first timestep * Add param * Change name and fix test * Change comment * Modified workflow * cache workflow downloads * Revert prev changes
1 parent 22d2db1 commit dee6972

File tree

10 files changed

+130742
-478
lines changed

10 files changed

+130742
-478
lines changed

Diff for: .github/workflows/manual.yml

+29-4
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,48 @@ jobs:
1212
shell: bash -l {0}
1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616

1717
- name: Install system dependencies
1818
run: |
1919
sudo apt update
2020
sudo apt install -y libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev mesa-common-dev libc++1
2121
22+
- name: Cache Conda packages
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/conda_pkgs_dir
26+
key: ${{ runner.os }}-conda-${{ hashFiles('environment.yml') }}
27+
restore-keys: |
28+
${{ runner.os }}-conda-
29+
2230
- name: Setup Conda environment.
23-
uses: conda-incubator/setup-miniconda@v2
31+
uses: conda-incubator/setup-miniconda@v3
2432
with:
2533
activate-environment: gpudrive
2634
environment-file: environment.yml
35+
cache-downloads: true
36+
37+
- name: Cache Poetry dependencies
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.cache/pypoetry
41+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-poetry-
2744
2845
- name: Install dependencies and build the project with Poetry
2946
run: |
3047
poetry install
48+
3149
- name: Run tests
3250
run: |
33-
cd build/
34-
ctest --rerun-failed --output-on-failure
51+
ulimit -c unlimited
52+
pytest -v
53+
54+
- name: Upload core dumps
55+
if: failure()
56+
uses: actions/upload-artifact@v3
57+
with:
58+
name: core-dumps
59+
path: /tmp/core*

Diff for: conftest.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import subprocess
2+
import pytest
3+
import os
4+
5+
@pytest.fixture(scope="session", autouse=True)
6+
def run_ctest():
7+
build_dir = "build" # Replace this with the path to your build directory
8+
print("Running ctest in", os.path.abspath(build_dir))
9+
10+
# Run ctest in the build directory
11+
try:
12+
result = subprocess.run(["ctest"], check=True, cwd=build_dir, capture_output=True, text=True)
13+
print("ctest stdout:")
14+
print(result.stdout)
15+
print("ctest stderr:")
16+
print(result.stderr)
17+
except subprocess.CalledProcessError as e:
18+
print(f"ctest failed with error code {e.returncode}")
19+
print("Error output:")
20+
print(e.output)
21+
raise # Re-raise the exception to make pytest fail

Diff for: poetry.lock

-470
This file was deleted.

Diff for: pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ script = "build.py"
2222
python = "^3.11"
2323
torch = "^2.2.1"
2424
numpy = "^1.26.4"
25+
pytest = "^8.2.1"
2526

2627
[tool.poetry]
2728
name = "gpudrive"

Diff for: pytest.ini

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
addopts = --ignore=external/madrona/external/SPIRV-Reflect --ignore=external/madrona/external/nanobind --ignore=external/madrona/external/tinyusdz --ignore=external/madrona/external/googletest

Diff for: src/consts.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace gpudrive {
88

99
namespace consts {
1010

11-
inline constexpr madrona::CountT kMaxAgentCount = 128;
12-
inline constexpr madrona::CountT kMaxRoadEntityCount = 6000;
13-
inline constexpr madrona::CountT kMaxAgentMapObservationsCount = 6000;
11+
inline constexpr madrona::CountT kMaxAgentCount = 40;
12+
inline constexpr madrona::CountT kMaxRoadEntityCount = 4500;
13+
inline constexpr madrona::CountT kMaxAgentMapObservationsCount = 4500;
1414

1515
// Various world / entity size parameters
1616
inline constexpr float worldLength = 40.f;

Diff for: src/level_gen.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ static inline void resetAgent(Engine &ctx, Entity agent) {
4747
#endif
4848
}
4949

50-
5150
static inline Entity createAgent(Engine &ctx, const MapObject &agentInit) {
5251
auto agent = ctx.makeRenderableEntity<Agent>();
5352

0 commit comments

Comments
 (0)