Skip to content

Commit b8ad06c

Browse files
committed
mocks
1 parent 6c55ae5 commit b8ad06c

File tree

6 files changed

+34
-25
lines changed

6 files changed

+34
-25
lines changed

pytorch_lightning/loggers/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@
2424
'CSVLogger',
2525
]
2626

27-
from pytorch_lightning.loggers.comet import COMET_AVAILABLE, CometLogger
28-
from pytorch_lightning.loggers.mlflow import MLFLOW_AVAILABLE, MLFlowLogger
29-
from pytorch_lightning.loggers.neptune import NEPTUNE_AVAILABLE, NeptuneLogger
30-
from pytorch_lightning.loggers.test_tube import TESTTUBE_AVAILABLE, TestTubeLogger
31-
from pytorch_lightning.loggers.wandb import WANDB_AVAILABLE, WandbLogger
27+
from pytorch_lightning.loggers.comet import _COMET_AVAILABLE, CometLogger
28+
from pytorch_lightning.loggers.mlflow import _MLFLOW_AVAILABLE, MLFlowLogger
29+
from pytorch_lightning.loggers.neptune import _NEPTUNE_AVAILABLE, NeptuneLogger
30+
from pytorch_lightning.loggers.test_tube import _TESTTUBE_AVAILABLE, TestTubeLogger
31+
from pytorch_lightning.loggers.wandb import _WANDB_AVAILABLE, WandbLogger
3232

33-
if COMET_AVAILABLE:
33+
if _COMET_AVAILABLE:
3434
__all__.append('CometLogger')
3535
# needed to prevent ImportError and duplicated logs.
3636
environ["COMET_DISABLE_AUTO_LOGGING"] = "1"
3737

38-
if MLFLOW_AVAILABLE:
38+
if _MLFLOW_AVAILABLE:
3939
__all__.append('MLFlowLogger')
4040

41-
if NEPTUNE_AVAILABLE:
41+
if _NEPTUNE_AVAILABLE:
4242
__all__.append('NeptuneLogger')
4343

44-
if TESTTUBE_AVAILABLE:
44+
if _TESTTUBE_AVAILABLE:
4545
__all__.append('TestTubeLogger')
4646

47-
if WANDB_AVAILABLE:
47+
if _WANDB_AVAILABLE:
4848
__all__.append('WandbLogger')

pytorch_lightning/loggers/comet.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
from pytorch_lightning.utilities import rank_zero_only, _module_available
3030
from pytorch_lightning.utilities.exceptions import MisconfigurationException
3131

32-
COMET_AVAILABLE = _module_available("comet_ml")
32+
_COMET_AVAILABLE = _module_available("comet_ml")
3333

34-
if COMET_AVAILABLE:
34+
if _COMET_AVAILABLE:
3535
import comet_ml
3636
from comet_ml import ExistingExperiment as CometExistingExperiment
3737
from comet_ml import Experiment as CometExperiment
@@ -42,6 +42,8 @@
4242
except ImportError: # pragma: no-cover
4343
# For more information, see: https://www.comet.ml/docs/python-sdk/releases/#release-300
4444
from comet_ml.papi import API # pragma: no-cover
45+
else:
46+
comet_ml = None # needed for test mocks, these tests shall be updated
4547

4648

4749
class CometLogger(LightningLoggerBase):
@@ -126,7 +128,7 @@ def __init__(
126128
prefix: str = '',
127129
**kwargs
128130
):
129-
if not COMET_AVAILABLE:
131+
if not comet_ml:
130132
raise ImportError(
131133
"You want to use `comet_ml` logger which is not installed yet,"
132134
" install it with `pip install comet-ml`."

pytorch_lightning/loggers/mlflow.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
from pytorch_lightning.loggers.base import LightningLoggerBase, rank_zero_experiment
2727
from pytorch_lightning.utilities import rank_zero_only, rank_zero_warn, _module_available
2828

29-
MLFLOW_AVAILABLE = _module_available("mlflow")
29+
_MLFLOW_AVAILABLE = _module_available("mlflow")
3030

31-
if MLFLOW_AVAILABLE:
31+
if _MLFLOW_AVAILABLE:
32+
import mlflow
3233
from mlflow.tracking import MlflowClient
34+
else:
35+
mlflow = None
3336

3437

3538
LOCAL_FILE_URI_PREFIX = "file:"
@@ -90,7 +93,7 @@ def __init__(
9093
save_dir: Optional[str] = './mlruns',
9194
prefix: str = '',
9295
):
93-
if not MLFLOW_AVAILABLE:
96+
if not mlflow:
9497
raise ImportError('You want to use `mlflow` logger which is not installed yet,'
9598
' install it with `pip install mlflow`.')
9699
super().__init__()

pytorch_lightning/loggers/neptune.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
from pytorch_lightning.loggers.base import LightningLoggerBase, rank_zero_experiment
2727
from pytorch_lightning.utilities import rank_zero_only, _module_available
2828

29-
NEPTUNE_AVAILABLE = _module_available("neptune")
29+
_NEPTUNE_AVAILABLE = _module_available("neptune")
3030

31-
if NEPTUNE_AVAILABLE:
31+
if _NEPTUNE_AVAILABLE:
3232
import neptune
3333
from neptune.experiments import Experiment as NeptuneExperiment
34+
else:
35+
neptune = None # needed for test mocks, these tests shall be updated
3436

3537

3638
class NeptuneLogger(LightningLoggerBase):
@@ -184,7 +186,7 @@ def __init__(
184186
prefix: str = '',
185187
**kwargs
186188
):
187-
if not NEPTUNE_AVAILABLE:
189+
if not neptune:
188190
raise ImportError('You want to use `neptune` logger which is not installed yet,'
189191
' install it with `pip install neptune-client`.')
190192
super().__init__()

pytorch_lightning/loggers/test_tube.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
from pytorch_lightning.utilities import _module_available
2525
from pytorch_lightning.utilities.distributed import rank_zero_only, rank_zero_warn
2626

27-
TESTTUBE_AVAILABLE = _module_available("test_tube")
27+
_TESTTUBE_AVAILABLE = _module_available("test_tube")
2828

29-
if TESTTUBE_AVAILABLE:
29+
if _TESTTUBE_AVAILABLE:
3030
from test_tube import Experiment as TTExperiment
3131

3232

@@ -89,7 +89,7 @@ def __init__(
8989
log_graph: bool = False,
9090
prefix: str = '',
9191
):
92-
if not TESTTUBE_AVAILABLE:
92+
if not _TESTTUBE_AVAILABLE:
9393
raise ImportError('You want to use `test_tube` logger which is not installed yet,'
9494
' install it with `pip install test-tube`.')
9595
super().__init__()

pytorch_lightning/loggers/wandb.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
from pytorch_lightning.loggers.base import LightningLoggerBase, rank_zero_experiment
2626
from pytorch_lightning.utilities import rank_zero_only, _module_available
2727

28-
WANDB_AVAILABLE = _module_available("wandb")
28+
_WANDB_AVAILABLE = _module_available("wandb")
2929

30-
if WANDB_AVAILABLE:
30+
if _WANDB_AVAILABLE:
3131
import wandb
3232
from wandb.wandb_run import Run as WBRun
33+
else:
34+
wandb = None # needed for test mocks, these tests shall be updated
3335

3436

3537
class WandbLogger(LightningLoggerBase):
@@ -88,7 +90,7 @@ def __init__(
8890
prefix: str = '',
8991
**kwargs
9092
):
91-
if not WANDB_AVAILABLE:
93+
if not wandb:
9294
raise ImportError('You want to use `wandb` logger which is not installed yet,' # pragma: no-cover
9395
' install it with `pip install wandb`.')
9496
super().__init__()

0 commit comments

Comments
 (0)