Skip to content

Commit

Permalink
Add pytests (#127)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
aaravpandya authored May 23, 2024
1 parent 22d2db1 commit dee6972
Show file tree
Hide file tree
Showing 10 changed files with 130,742 additions and 478 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,48 @@ jobs:
shell: bash -l {0}
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo apt update
sudo apt install -y libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev mesa-common-dev libc++1
- name: Cache Conda packages
uses: actions/cache@v4
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ hashFiles('environment.yml') }}
restore-keys: |
${{ runner.os }}-conda-
- name: Setup Conda environment.
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: gpudrive
environment-file: environment.yml
cache-downloads: true

- name: Cache Poetry dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install dependencies and build the project with Poetry
run: |
poetry install
- name: Run tests
run: |
cd build/
ctest --rerun-failed --output-on-failure
ulimit -c unlimited
pytest -v
- name: Upload core dumps
if: failure()
uses: actions/upload-artifact@v3
with:
name: core-dumps
path: /tmp/core*
21 changes: 21 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import subprocess
import pytest
import os

@pytest.fixture(scope="session", autouse=True)
def run_ctest():
build_dir = "build" # Replace this with the path to your build directory
print("Running ctest in", os.path.abspath(build_dir))

# Run ctest in the build directory
try:
result = subprocess.run(["ctest"], check=True, cwd=build_dir, capture_output=True, text=True)
print("ctest stdout:")
print(result.stdout)
print("ctest stderr:")
print(result.stderr)
except subprocess.CalledProcessError as e:
print(f"ctest failed with error code {e.returncode}")
print("Error output:")
print(e.output)
raise # Re-raise the exception to make pytest fail
470 changes: 0 additions & 470 deletions poetry.lock

This file was deleted.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ script = "build.py"
python = "^3.11"
torch = "^2.2.1"
numpy = "^1.26.4"
pytest = "^8.2.1"

[tool.poetry]
name = "gpudrive"
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --ignore=external/madrona/external/SPIRV-Reflect --ignore=external/madrona/external/nanobind --ignore=external/madrona/external/tinyusdz --ignore=external/madrona/external/googletest
6 changes: 3 additions & 3 deletions src/consts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace gpudrive {

namespace consts {

inline constexpr madrona::CountT kMaxAgentCount = 128;
inline constexpr madrona::CountT kMaxRoadEntityCount = 6000;
inline constexpr madrona::CountT kMaxAgentMapObservationsCount = 6000;
inline constexpr madrona::CountT kMaxAgentCount = 40;
inline constexpr madrona::CountT kMaxRoadEntityCount = 4500;
inline constexpr madrona::CountT kMaxAgentMapObservationsCount = 4500;

// Various world / entity size parameters
inline constexpr float worldLength = 40.f;
Expand Down
1 change: 0 additions & 1 deletion src/level_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ static inline void resetAgent(Engine &ctx, Entity agent) {
#endif
}


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

Expand Down
Loading

0 comments on commit dee6972

Please sign in to comment.