-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matteo Bettini <[email protected]>
- Loading branch information
1 parent
00efda3
commit e02744d
Showing
8 changed files
with
193 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
|
||
python -m pip install --upgrade pip | ||
python -m pip install flake8 pytest pytest-cov | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
python -m pip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu --force-reinstall | ||
|
||
cd .. | ||
python -m pip install git+https://github.com/pytorch-labs/tensordict.git | ||
git clone https://github.com/pytorch/rl.git | ||
cd rl | ||
python setup.py develop | ||
cd ../BenchMARL | ||
pip install -e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
python -m pip install vmas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: | ||
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
|
||
name: vmas_tests | ||
|
||
on: | ||
push: | ||
branches: [ $default-branch , "main" ] | ||
pull_request: | ||
branches: [ $default-branch , "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
bash .github/unittest/install_dependencies.sh | ||
- name: Install vmas | ||
run: | | ||
bash .github/unittest/install_vmas.sh | ||
- name: Test with pytest | ||
run: | | ||
pytest test/test_vmas.py --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import importlib | ||
|
||
import pytest | ||
|
||
from benchmarl.algorithms import ( | ||
algorithm_config_registry, | ||
MappoConfig, | ||
MasacConfig, | ||
QmixConfig, | ||
) | ||
from benchmarl.algorithms.common import AlgorithmConfig | ||
from benchmarl.environments import Smacv2Task | ||
from benchmarl.experiment import Experiment | ||
|
||
|
||
_has_smacv2 = importlib.util.find_spec("smacv2") is not None | ||
|
||
|
||
@pytest.mark.skipif(not _has_smacv2, reason="SMACv2 not found") | ||
class TestSmacv2: | ||
@pytest.mark.parametrize("algo_config", algorithm_config_registry.values()) | ||
@pytest.mark.parametrize("task", list(Smacv2Task)) | ||
def test_all_algos( | ||
self, algo_config: AlgorithmConfig, task, experiment_config, mlp_sequence_config | ||
): | ||
if algo_config.supports_discrete_actions(): | ||
task = task.get_from_yaml() | ||
|
||
experiment = Experiment( | ||
algorithm_config=algo_config.get_from_yaml(), | ||
model_config=mlp_sequence_config, | ||
seed=0, | ||
config=experiment_config, | ||
task=task, | ||
) | ||
experiment.run() | ||
|
||
@pytest.mark.parametrize("algo_config", [QmixConfig, MappoConfig, MasacConfig]) | ||
@pytest.mark.parametrize("task", list(Smacv2Task)) | ||
def test_all_tasks( | ||
self, algo_config: AlgorithmConfig, task, experiment_config, mlp_sequence_config | ||
): | ||
task = task.get_from_yaml() | ||
experiment = Experiment( | ||
algorithm_config=algo_config.get_from_yaml(), | ||
model_config=mlp_sequence_config, | ||
seed=0, | ||
config=experiment_config, | ||
task=task, | ||
) | ||
experiment.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import importlib | ||
|
||
import pytest | ||
|
||
from benchmarl.algorithms import algorithm_config_registry | ||
from benchmarl.algorithms.common import AlgorithmConfig | ||
from benchmarl.environments import Task, VmasTask | ||
from benchmarl.experiment import Experiment | ||
|
||
_has_vmas = importlib.util.find_spec("vmas") is not None | ||
|
||
|
||
@pytest.mark.skipif(not _has_vmas, reason="VMAS not found") | ||
class TestVmas: | ||
@pytest.mark.parametrize("algo_config", algorithm_config_registry.values()) | ||
@pytest.mark.parametrize("continuous", [True]) | ||
@pytest.mark.parametrize("task", list(VmasTask)) | ||
def test_all_algos_all_tasks( | ||
self, | ||
algo_config: AlgorithmConfig, | ||
task: Task, | ||
continuous, | ||
experiment_config, | ||
mlp_sequence_config, | ||
): | ||
task = task.get_from_yaml() | ||
|
||
experiment_config.prefer_continuous_actions = continuous | ||
|
||
experiment = Experiment( | ||
algorithm_config=algo_config.get_from_yaml(), | ||
model_config=mlp_sequence_config, | ||
seed=0, | ||
config=experiment_config, | ||
task=task, | ||
) | ||
experiment.run() |