Release/0.9 (#141)
* add flake8 and prettier to pre-commit-config * add setup.cfg * add workers=True to seed_everything() * update lightning badge logo * bump package versions * update README.md * add __init__.py files * add more logger configs parameters * add default Dockerfile * change .env.template to .env.example * move inference example to readme * remove img_dataset.py * simplify names of wandb callbacks * remove wandb test marker * format files with prettier
This commit is contained in:
1 parent
023d4bdecc
commit
70ab061f75
49 files changed
+473
-415
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,106 @@
|
||||
import pytest
|
||||
|
||||
from tests.helpers.run_command import run_command
|
||||
from tests.helpers.runif import RunIf
|
||||
|
||||
|
||||
def test_fast_dev_run():
|
||||
"""Run 1 train, val, test batch."""
|
||||
command = ["run.py", "trainer=default", "trainer.fast_dev_run=true"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_default_cpu():
|
||||
"""Test default configuration on CPU."""
|
||||
command = ["run.py", "trainer.max_epochs=1", "trainer.gpus=0"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@RunIf(min_gpus=1)
|
||||
def test_default_gpu():
|
||||
"""Test default configuration on GPU."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer.max_epochs=1",
|
||||
"trainer.gpus=1",
|
||||
"datamodule.pin_memory=True",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_experiments():
|
||||
"""Train 1 epoch with all experiment configs."""
|
||||
command = ["run.py", "-m", "experiment=glob(*)", "trainer.max_epochs=1"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_limit_batches():
|
||||
"""Train 1 epoch on 25% of data."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.max_epochs=1",
|
||||
"trainer.limit_train_batches=0.25",
|
||||
"trainer.limit_val_batches=0.25",
|
||||
"trainer.limit_test_batches=0.25",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_gradient_accumulation():
|
||||
"""Train 1 epoch with gradient accumulation."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.max_epochs=1",
|
||||
"trainer.accumulate_grad_batches=10",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_double_validation_loop():
|
||||
"""Train 1 epoch with validation loop twice per epoch."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.max_epochs=1",
|
||||
"trainer.val_check_interval=0.5",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_csv_logger():
|
||||
"""Train 5 epochs with 5 batches with CSVLogger."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.max_epochs=5",
|
||||
"trainer.limit_train_batches=5",
|
||||
"logger=csv",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_tensorboard_logger():
|
||||
"""Train 5 epochs with 5 batches with TensorboardLogger."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.max_epochs=5",
|
||||
"trainer.limit_train_batches=5",
|
||||
"logger=tensorboard",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_overfit_batches():
|
||||
"""Overfit to 10 batches over 10 epochs."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.min_epochs=10",
|
||||
"trainer.max_epochs=10",
|
||||
"trainer.overfit_batches=10",
|
||||
]
|
||||
run_command(command)
|
||||
@@ -0,0 +1,47 @@
|
||||
from tests.helpers.run_command import run_command
|
||||
from tests.helpers.runif import RunIf
|
||||
|
||||
|
||||
@RunIf(amp_apex=True)
|
||||
def test_apex_01():
|
||||
"""Test mixed-precision level 01."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.max_epochs=1",
|
||||
"trainer.gpus=1",
|
||||
"trainer.amp_backend=apex",
|
||||
"trainer.amp_level=O1",
|
||||
"trainer.precision=16",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@RunIf(amp_apex=True)
|
||||
def test_apex_02():
|
||||
"""Test mixed-precision level 02."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.max_epochs=1",
|
||||
"trainer.gpus=1",
|
||||
"trainer.amp_backend=apex",
|
||||
"trainer.amp_level=O2",
|
||||
"trainer.precision=16",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@RunIf(amp_apex=True)
|
||||
def test_apex_03():
|
||||
"""Test mixed-precision level 03."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"trainer.max_epochs=1",
|
||||
"trainer.gpus=1",
|
||||
"trainer.amp_backend=apex",
|
||||
"trainer.amp_level=O3",
|
||||
"trainer.precision=16",
|
||||
]
|
||||
run_command(command)
|
||||
@@ -0,0 +1,43 @@
|
||||
import pytest
|
||||
|
||||
from tests.helpers.run_command import run_command
|
||||
|
||||
"""
|
||||
Use the following command to skip slow tests:
|
||||
pytest -k "not slow"
|
||||
"""
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_default_sweep():
|
||||
"""Test default Hydra sweeper."""
|
||||
command = [
|
||||
"run.py",
|
||||
"-m",
|
||||
"datamodule.batch_size=64,128",
|
||||
"model.lr=0.01,0.02",
|
||||
"trainer=default",
|
||||
"trainer.fast_dev_run=true",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_optuna_sweep():
|
||||
"""Test Optuna sweeper."""
|
||||
command = [
|
||||
"run.py",
|
||||
"-m",
|
||||
"hparams_search=mnist_optuna",
|
||||
"trainer=default",
|
||||
"trainer.fast_dev_run=true",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="TODO: Add Ax sweep config.")
|
||||
@pytest.mark.slow
|
||||
def test_ax_sweep():
|
||||
"""Test Ax sweeper."""
|
||||
command = ["run.py", "-m", "hparams_search=mnist_ax", "trainer.fast_dev_run=true"]
|
||||
run_command(command)
|
||||
@@ -0,0 +1,40 @@
|
||||
import pytest
|
||||
|
||||
from tests.helpers.run_command import run_command
|
||||
|
||||
"""
|
||||
Use the following command to skip slow tests:
|
||||
pytest -k "not slow"
|
||||
"""
|
||||
|
||||
|
||||
# @pytest.mark.slow
|
||||
# def test_wandb_optuna_sweep():
|
||||
# """Test wandb logging with Optuna sweep."""
|
||||
# command = [
|
||||
# "run.py",
|
||||
# "-m",
|
||||
# "hparams_search=mnist_optuna",
|
||||
# "trainer=default",
|
||||
# "trainer.max_epochs=10",
|
||||
# "trainer.limit_train_batches=20",
|
||||
# "logger=wandb",
|
||||
# "logger.wandb.project=template-tests",
|
||||
# "logger.wandb.group=Optuna_SimpleDenseNet_MNIST",
|
||||
# "hydra.sweeper.n_trials=5",
|
||||
# ]
|
||||
# run_command(command)
|
||||
|
||||
|
||||
# @pytest.mark.slow
|
||||
# def test_wandb_callbacks():
|
||||
# """Test wandb callbacks."""
|
||||
# command = [
|
||||
# "run.py",
|
||||
# "trainer=default",
|
||||
# "trainer.max_epochs=3",
|
||||
# "logger=wandb",
|
||||
# "logger.wandb.project=template-tests",
|
||||
# "callbacks=wandb",
|
||||
# ]
|
||||
# run_command(command)
|
||||
Reference in new issue
Block a user