From ca33835bc7667d587df2c144fda49f4f8da747f9 Mon Sep 17 00:00:00 2001 From: Matteo Bettini <55539777+matteobettini@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:28:10 +0000 Subject: [PATCH] [CI] Run main tests with torchrl nightly and have a separate CI for testing torchrl stable (#53) * Amend * Amend * Amend * Amend * Amend * Amend * Amend * Amend * CI --- .github/unittest/install_dependencies.sh | 7 +-- .../unittest/install_dependencies_nightly.sh | 16 ++++++ .github/unittest/install_vmas.sh | 2 +- .github/workflows/pettingzoo_tests.yml | 2 +- .github/workflows/smacv2_tests.yml | 2 +- .github/workflows/torchrl_stable_tests.yml | 50 +++++++++++++++++++ .github/workflows/unit_tests.yml | 2 +- .github/workflows/vmas_tests.yml | 2 +- 8 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 .github/unittest/install_dependencies_nightly.sh create mode 100644 .github/workflows/torchrl_stable_tests.yml diff --git a/.github/unittest/install_dependencies.sh b/.github/unittest/install_dependencies.sh index e20187a3..0144dfd9 100644 --- a/.github/unittest/install_dependencies.sh +++ b/.github/unittest/install_dependencies.sh @@ -7,10 +7,7 @@ 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 +pip install torchrl + cd ../BenchMARL pip install -e . diff --git a/.github/unittest/install_dependencies_nightly.sh b/.github/unittest/install_dependencies_nightly.sh new file mode 100644 index 00000000..e20187a3 --- /dev/null +++ b/.github/unittest/install_dependencies_nightly.sh @@ -0,0 +1,16 @@ + + +python -m pip install --upgrade pip +python -m pip install flake8 pytest pytest-cov hydra-core tqdm torch_geometric + +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 . diff --git a/.github/unittest/install_vmas.sh b/.github/unittest/install_vmas.sh index 2789fcf6..86c7ebf4 100644 --- a/.github/unittest/install_vmas.sh +++ b/.github/unittest/install_vmas.sh @@ -1,4 +1,4 @@ -python -m pip install git+https://github.com/proroklab/VectorizedMultiAgentSimulator.git +python -m pip install vmas sudo apt-get update sudo apt-get install python3-opengl xvfb diff --git a/.github/workflows/pettingzoo_tests.yml b/.github/workflows/pettingzoo_tests.yml index bcb900e3..3fbd0125 100644 --- a/.github/workflows/pettingzoo_tests.yml +++ b/.github/workflows/pettingzoo_tests.yml @@ -30,7 +30,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - bash .github/unittest/install_dependencies.sh + bash .github/unittest/install_dependencies_nightly.sh - name: Install pettingzoo run: | bash .github/unittest/install_pettingzoo.sh diff --git a/.github/workflows/smacv2_tests.yml b/.github/workflows/smacv2_tests.yml index 7fed4f0a..20761a69 100644 --- a/.github/workflows/smacv2_tests.yml +++ b/.github/workflows/smacv2_tests.yml @@ -31,7 +31,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - bash .github/unittest/install_dependencies.sh + bash .github/unittest/install_dependencies_nightly.sh - name: Install smacv2 run: | bash .github/unittest/install_smacv2.sh diff --git a/.github/workflows/torchrl_stable_tests.yml b/.github/workflows/torchrl_stable_tests.yml new file mode 100644 index 00000000..3604b031 --- /dev/null +++ b/.github/workflows/torchrl_stable_tests.yml @@ -0,0 +1,50 @@ +# 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: torchrl_stable_tests + +on: + push: + branches: [ $default-branch , "main" ] + pull_request: + branches: [ $default-branch , "main" ] + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["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: Install pettingzoo + run: | + bash .github/unittest/install_pettingzoo.sh + - if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'smacv2') }} + name: Install smacv2 + run: | + bash .github/unittest/install_smacv2.sh + + - name: Unit tests + run: | + root_dir="$(git rev-parse --show-toplevel)" + export SC2PATH="${root_dir}/StarCraftII" + echo 'SC2PATH is set to ' "$SC2PATH" + + xvfb-run -s "-screen 0 1024x768x24" pytest test/ --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 017842b0..a1736419 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -30,7 +30,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - bash .github/unittest/install_dependencies.sh + bash .github/unittest/install_dependencies_nightly.sh - name: Test with pytest run: | diff --git a/.github/workflows/vmas_tests.yml b/.github/workflows/vmas_tests.yml index 9772acae..c42e8bd7 100644 --- a/.github/workflows/vmas_tests.yml +++ b/.github/workflows/vmas_tests.yml @@ -30,7 +30,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - bash .github/unittest/install_dependencies.sh + bash .github/unittest/install_dependencies_nightly.sh - name: Install vmas run: | bash .github/unittest/install_vmas.sh