Skip to content

Commit 9378243

Browse files
[CodeQuality] Pre-commit formatting (#87)
* pre commit * amend * test * test
1 parent 8a193b5 commit 9378243

80 files changed

Lines changed: 1463 additions & 980 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
notebooks/* linguist-documentation
2-
mpe_comparison/* linguist-documentation
2+
mpe_comparison/* linguist-documentation

.github/workflows/python-app.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ jobs:
4646
pip install pytest
4747
pip install pytest-cov
4848
pip install tqdm
49-
pytest tests/ --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
49+
pytest tests/ --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
50+
- if: matrix.python-version == '3.10'
51+
name: Upload coverage to Codecov
52+
uses: codecov/codecov-action@v3
53+
with:
54+
fail_ci_if_error: false

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.0.1
4+
hooks:
5+
- id: check-docstring-first
6+
- id: check-toml
7+
- id: check-yaml
8+
exclude: packaging/.*
9+
- id: mixed-line-ending
10+
args: [--fix=lf]
11+
- id: end-of-file-fixer
12+
13+
- repo: https://github.com/omnilib/ufmt
14+
rev: v2.0.0b2
15+
hooks:
16+
- id: ufmt
17+
additional_dependencies:
18+
- black == 22.3.0
19+
- usort == 1.0.3
20+
- libcst == 0.4.7
21+
22+
- repo: https://github.com/pycqa/flake8
23+
rev: 4.0.1
24+
hooks:
25+
- id: flake8
26+
args: [--config=setup.cfg]
27+
additional_dependencies:
28+
- flake8-bugbear==22.10.27
29+
- flake8-comprehensions==3.10.1

CONTRIBUTING.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Contributing to VMAS
2+
We want to make contributing to this project as easy and transparent as
3+
possible.
4+
5+
## Installing the library
6+
7+
To contribute, it is suggested to install the library (or your fork of it) from source:
8+
9+
```bash
10+
git clone https://github.com/proroklab/VectorizedMultiAgentSimulator.git
11+
cd VectorizedMultiAgentSimulator
12+
python setup.py develop
13+
```
14+
15+
## Formatting your code
16+
17+
Before your PR is ready, you'll probably want your code to be checked. This can be done easily by installing
18+
```
19+
pip install pre-commit
20+
```
21+
and running
22+
```
23+
pre-commit run --all-files
24+
```
25+
from within the vmas cloned directory.
26+
27+
You can also install [pre-commit hooks](https://pre-commit.com/) (using `pre-commit install`
28+
). You can disable the check by appending `-n` to your commit command: `git commit -m <commit message> -n`
29+
30+
## Pull Requests
31+
We actively welcome your pull requests.
32+
33+
1. Fork the repo and create your branch from `main`.
34+
2. If you've added code that should be tested, add tests.
35+
3. If you've changed APIs, update the documentation.
36+
4. Ensure the test suite and the documentation pass.
37+
5. Make sure your code lints.
38+
39+
When submitting a PR, we encourage you to link it to the related issue (if any) and add some tags to it.
40+
41+
42+
## License
43+
By contributing to vmas, you agree that your contributions will be licensed
44+
under the license of the project

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include vmas/simulator/secrcode.ttf
1+
include vmas/simulator/secrcode.ttf

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,4 @@ To create a fake screen you need to have `Xvfb` installed.
431431
- [X] simple_speaker_listener
432432
- [X] simple_spread
433433
- [X] simple_tag
434-
- [X] simple_world_comm
434+
- [X] simple_world_comm

mpe_comparison/mpe_performance_comparison.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022.
1+
# Copyright (c) 2022-2024.
22
# ProrokLab (https://www.proroklab.org/)
33
# All rights reserved.
44

@@ -14,14 +14,14 @@
1414
import numpy as np
1515
import tikzplotlib
1616
import torch
17-
from matplotlib import pyplot as plt
1817

1918
import vmas
19+
from matplotlib import pyplot as plt
2020

2121

2222
def mpe_make_env(scenario_name):
23-
from mpe.multiagent.environment import MultiAgentEnv
2423
import mpe.multiagent.scenarios as scenarios
24+
from mpe.multiagent.environment import MultiAgentEnv
2525

2626
# load scenario from script
2727
scenario = scenarios.load(scenario_name + ".py").Scenario()
@@ -44,10 +44,10 @@ def run_mpe_simple_spread(n_envs: int, n_steps: int):
4444
[env.reset() for env in envs]
4545
init_time = time.time()
4646

47-
for step in range(n_steps):
47+
for _ in range(n_steps):
4848
for env_idx in range(n_envs):
4949
actions = []
50-
for i in range(n_agents):
50+
for _ in range(n_agents):
5151
actions.append(simple_shared_action)
5252
envs[env_idx].step(actions)
5353

@@ -72,9 +72,9 @@ def run_vmas_simple_spread(n_envs: int, n_steps: int, device: str):
7272
env.reset()
7373
init_time = time.time()
7474

75-
for step in range(n_steps):
75+
for _ in range(n_steps):
7676
actions = []
77-
for i in range(n_agents):
77+
for _ in range(n_agents):
7878
actions.append(
7979
torch.tensor(
8080
simple_shared_action,
@@ -101,11 +101,11 @@ def get_device_name(torch_device: str):
101101
if "model name" in line:
102102
return re.sub(".*model name.*:", "", line, 1)
103103
else:
104-
assert False
104+
raise AssertionError()
105105
elif torch_device == "cuda":
106106
return torch.cuda.get_device_name()
107107
else:
108-
assert False
108+
raise AssertionError()
109109

110110

111111
def store_pickled_evaluation(name: str, evaluation: list):

0 commit comments

Comments
 (0)