Skip to content

Commit

Permalink
Conditionally skip tests when installed with mosaicml[dev] (mosaicml#185
Browse files Browse the repository at this point in the history
)

* The wandb test should be skipped as wandb is installed with mosaicml[logging]
* The run directory uploader test should be skipped as libcloud is installed with mosaicml[logging]
  • Loading branch information
ravi-mosaicml authored and coryMosaicML committed Feb 23, 2022
1 parent 23707b3 commit 65f35be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/callbacks/test_run_directory_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
@pytest.mark.parametrize("use_procs", [False, True])
@pytest.mark.timeout(15)
def test_run_directory_uploader(tmpdir: pathlib.Path, use_procs: bool, dummy_state: State, dummy_logger: Logger):
try:
import libcloud
del libcloud
except ImportError:
pytest.skip("Run directory uploader test won't work without libcloud")
dummy_state.epoch = 0
dummy_state.step = 0
remote_dir = str(tmpdir / "run_directory_copy")
Expand Down
7 changes: 6 additions & 1 deletion tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ def get_mock_tqdm(position: int, *args, **kwargs):
pytest.param(2, marks=pytest.mark.world_size(2)),
])
@pytest.mark.timeout(10)
def test_wandb_logger(mosaic_trainer_hparams: TrainerHparams, world_size: int, monkeypatch: MonkeyPatch):
def test_wandb_logger(mosaic_trainer_hparams: TrainerHparams, world_size: int):
try:
import wandb
del wandb
except ImportError:
pytest.skip("wandb is not installed")
del world_size # unused. Set via launcher script
mosaic_trainer_hparams.loggers = [WandBLoggerBackendHparams(log_artifacts=True, log_artifacts_every_n_batches=1)]
trainer = mosaic_trainer_hparams.initialize_object()
Expand Down

0 comments on commit 65f35be

Please sign in to comment.