Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,8 @@ jobs:
command: |

# pytest on cuda
export test1_cmd='CUDA_VISIBLE_DEVICES=0 py.test -vvv tests/ -k "on_cuda"'
docker exec -it pthd /bin/bash -c "$test1_cmd"

# pytest on cuda and distributed (one process)
export test2_cmd='export WORLD_SIZE=1 && py.test --dist=each --tx $WORLD_SIZE*popen//python=python3.7 tests -m distributed -vvv'
docker exec -it pthd /bin/bash -c "$test2_cmd"
export test_cmd='sh tests/run_gpu_tests.sh'
docker exec -it pthd /bin/bash -c "$test_cmd"

# MNIST tests

Expand Down Expand Up @@ -132,8 +128,8 @@ jobs:
- run:
name: Run 1 Node 2 GPUs Unit Tests
command: |
export test1_cmd='export WORLD_SIZE=2 && py.test --dist=each --tx $WORLD_SIZE*popen//python=python3.7 tests -m distributed -vvv'
docker exec -it pthd /bin/bash -c "$test1_cmd"
export test_cmd='sh tests/run_gpu_tests.sh 2'
docker exec -it pthd /bin/bash -c "$test_cmd"

# -------------------------------------------------------------------------------------
# Workflows
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tpu-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
export XRT_WORKERS="localservice:0;grpc://localhost:40934"

python -c "import torch_xla; print('torch xla version:', torch_xla.__version__)"
py.test --cov ignite --cov-append --cov-report term-missing tests/ -vvv -m tpu
sh tests/run_tpu_tests.sh
10 changes: 1 addition & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,7 @@ install:
- python setup.py install

script:
- CUDA_VISIBLE_DEVICES="" py.test --tx 4*popen//python=python$TRAVIS_PYTHON_VERSION --cov ignite --cov-report term-missing -vvv tests/
# Run test on cuda device
# As no GPUs on travis -> all tests will be skipped
- CUDA_VISIBLE_DEVICES=0 py.test --cov ignite --cov-append --cov-report term-missing -vvv tests/ -k "on_cuda"
# tests for distributed ops
# As no GPUs on travis -> all tests will be skipped
# 2 is the number of processes <-> number of available GPUs
- export WORLD_SIZE=2
- py.test --cov ignite --cov-append --cov-report term-missing --dist=each --tx $WORLD_SIZE*popen//python=python$TRAVIS_PYTHON_VERSION tests -m distributed -vvv
- sh tests/run_cpu_tests.sh

after_success:
- codecov
Expand Down
10 changes: 6 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ flake8 ignite/ tests/ examples/
```

#### Run tests:

To run a specific test, for example `test_terminate` from `test_engine.py`
```bash
pytest tests/ -vvv
pytest tests/ignite/engine/test_terminate -vvv -k test_terminate
```
or tests with coverage (assuming installed `pytest-cov`):
To run all tests with coverage (assuming installed `pytest-cov`):
```bash
py.test --cov ignite --cov-report term-missing
sh tests/run_cpu_tests.sh
```

#### Send a PR
If everything is OK, please send a Pull Request to https://github.com/pytorch/ignite

If everything is OK, please send a Pull Request to https://github.com/pytorch/ignite

If you are not familiar with creating a Pull Request, here are some guides:
- http://stackoverflow.com/questions/14680711/how-to-do-a-github-pull-request
Expand Down
4 changes: 3 additions & 1 deletion tests/ignite/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def distributed_context_single_node_nccl(local_rank):
"backend": "nccl",
"world_size": int(os.environ["WORLD_SIZE"]),
"rank": local_rank,
"init_method": "tcp://localhost:2222",
"init_method": "tcp://localhost:2223",
}

dist.init_process_group(**dist_info)
Expand All @@ -57,6 +57,7 @@ def distributed_context_single_node_nccl(local_rank):
def distributed_context_single_node_gloo(local_rank):

import os
from datetime import timedelta

if "WORLD_SIZE" not in os.environ:
os.environ["WORLD_SIZE"] = "1"
Expand All @@ -66,6 +67,7 @@ def distributed_context_single_node_gloo(local_rank):
"world_size": int(os.environ["WORLD_SIZE"]),
"rank": local_rank,
"init_method": "tcp://localhost:2222",
"timeout": timedelta(seconds=60),
}

dist.init_process_group(**dist_info)
Expand Down
9 changes: 9 additions & 0 deletions tests/run_cpu_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -xeu

CUDA_VISIBLE_DEVICES="" py.test --tx 4*popen//python=python$TRAVIS_PYTHON_VERSION --cov ignite --cov-report term-missing -vvv tests/

export WORLD_SIZE=2

CUDA_VISIBLE_DEVICES="" py.test --cov ignite --cov-append --cov-report term-missing --dist=each --tx $WORLD_SIZE*popen//python=python$TRAVIS_PYTHON_VERSION tests -m distributed -vvv
15 changes: 15 additions & 0 deletions tests/run_gpu_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if [ -z "$1" ]; then
ws=1
else
ws=$1
fi

set -xeu

py.test -vvv tests/ -k 'on_cuda'

export WORLD_SIZE=$ws

py.test --dist=each --tx $WORLD_SIZE*popen//python=python3.7 tests -m distributed -vvv
5 changes: 5 additions & 0 deletions tests/run_tpu_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -xeu

py.test --cov ignite --cov-append --cov-report term-missing tests/ -vvv -m tpu