Skip to content

Instantly share code, notes, and snippets.

@daniellepintz
Created March 6, 2022 17:42
Show Gist options
  • Save daniellepintz/f603473b82c1f21d8299eaae56b33001 to your computer and use it in GitHub Desktop.
Save daniellepintz/f603473b82c1f21d8299eaae56b33001 to your computer and use it in GitHub Desktop.
(pl) [daniellepintz@devgpu006.pnb1 ~/pytorch-lightning] python -m pytest -v tests/loggers/test_all.py::test_none_logger
=============================================================== test session starts ================================================================
platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /home/daniellepintz/local/miniconda3/envs/pl/bin/python3
cachedir: .pytest_cache
rootdir: /home/daniellepintz/pytorch-lightning, configfile: setup.cfg
plugins: hydra-core-1.1.1, rerunfailures-10.2, anyio-3.3.4
collected 1 item
tests/loggers/test_all.py::test_none_logger FAILED [100%]
===================================================================== FAILURES =====================================================================
_________________________________________________________________ test_none_logger _________________________________________________________________
tmpdir = local('/tmp/pytest-of-daniellepintz/pytest-9/test_none_logger0')
def test_none_logger(tmpdir):
"""Tests the case where logger=None is passed to Trainer."""
model = BoringModel()
trainer = Trainer(
logger=None,
max_steps=1,
)
> trainer.fit(model)
tests/loggers/test_all.py:375:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pytorch_lightning/trainer/trainer.py:771: in fit
self._call_and_handle_interrupt(
pytorch_lightning/trainer/trainer.py:724: in _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)
pytorch_lightning/trainer/trainer.py:812: in _fit_impl
results = self._run(model, ckpt_path=self.ckpt_path)
pytorch_lightning/trainer/trainer.py:1172: in _run
self.__setup_profiler()
pytorch_lightning/trainer/trainer.py:1777: in __setup_profiler
self.profiler.setup(stage=self.state.fn._setup_fn, local_rank=local_rank, log_dir=self.log_dir)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pytorch_lightning.trainer.trainer.Trainer object at 0x7f150e673850>
@property
def log_dir(self) -> Optional[str]:
if len(self.loggers) == 1:
if isinstance(self.logger, TensorBoardLogger):
dirpath = self.logger.log_dir
else:
> dirpath = self.logger.save_dir
E AttributeError: 'NoneType' object has no attribute 'save_dir'
pytorch_lightning/trainer/trainer.py:2152: AttributeError
--------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------
GPU available: True, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
============================================================= short test summary info ==============================================================
FAILED tests/loggers/test_all.py::test_none_logger - AttributeError: 'NoneType' object has no attribute 'save_dir'
========================================================== 1 failed, 4 warnings in 0.62s ===========================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment