File tree Expand file tree Collapse file tree 6 files changed +34
-25
lines changed
pytorch_lightning/loggers Expand file tree Collapse file tree 6 files changed +34
-25
lines changed Original file line number Diff line number Diff line change 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' )
Original file line number Diff line number Diff line change 2929from pytorch_lightning .utilities import rank_zero_only , _module_available
3030from 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
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
4749class 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`."
Original file line number Diff line number Diff line change 2626from pytorch_lightning .loggers .base import LightningLoggerBase , rank_zero_experiment
2727from 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
3538LOCAL_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__ ()
Original file line number Diff line number Diff line change 2626from pytorch_lightning .loggers .base import LightningLoggerBase , rank_zero_experiment
2727from 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
3638class 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__ ()
Original file line number Diff line number Diff line change 2424from pytorch_lightning .utilities import _module_available
2525from 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__ ()
Original file line number Diff line number Diff line change 2525from pytorch_lightning .loggers .base import LightningLoggerBase , rank_zero_experiment
2626from 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
3537class 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__ ()
You can’t perform that action at this time.
0 commit comments