Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pytorch_lightning/loggers/comet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@
except ImportError: # pragma: no-cover
# For more information, see: https://www.comet.ml/docs/python-sdk/releases/#release-300
from comet_ml.papi import API # pragma: no-cover

_COMET_AVAILABLE = True
except ImportError: # pragma: no-cover
raise ImportError('You want to use `comet_ml` logger which is not installed yet,' # pragma: no-cover
' install it with `pip install comet-ml`.')
CometExperiment = None
CometExistingExperiment = None
CometOfflineExperiment = None
CometBaseExperiment = None
API = None
_COMET_AVAILABLE = False


import torch
from torch import is_tensor
Expand Down Expand Up @@ -93,6 +100,9 @@ def __init__(self,
experiment_key: Optional[str] = None,
**kwargs):

if not _COMET_AVAILABLE:
raise ImportError('You want to use `comet_ml` logger which is not installed yet,'
' install it with `pip install comet-ml`.')
super().__init__()
self._experiment = None

Expand Down
11 changes: 9 additions & 2 deletions pytorch_lightning/loggers/mlflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
try:
import mlflow
from mlflow.tracking import MlflowClient
_MLFLOW_AVAILABLE = True
except ImportError: # pragma: no-cover
raise ImportError('You want to use `mlflow` logger which is not installed yet,' # pragma: no-cover
' install it with `pip install mlflow`.')
mlflow = None
MlflowClient = None
_MLFLOW_AVAILABLE = False

from pytorch_lightning import _logger as log
from pytorch_lightning.loggers.base import LightningLoggerBase
Expand Down Expand Up @@ -54,11 +56,16 @@ class MLFlowLogger(LightningLoggerBase):
tags: A dictionary tags for the experiment.

"""

def __init__(self,
experiment_name: str = 'default',
tracking_uri: Optional[str] = None,
tags: Optional[Dict[str, Any]] = None,
save_dir: Optional[str] = None):

if not _MLFLOW_AVAILABLE:
raise ImportError('You want to use `mlflow` logger which is not installed yet,'
' install it with `pip install mlflow`.')
super().__init__()
if not tracking_uri and save_dir:
tracking_uri = f'file:{os.sep * 2}{save_dir}'
Expand Down
9 changes: 7 additions & 2 deletions pytorch_lightning/loggers/neptune.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
try:
import neptune
from neptune.experiments import Experiment
_NEPTUNE_AVAILABLE = True
except ImportError: # pragma: no-cover
raise ImportError('You want to use `neptune` logger which is not installed yet,' # pragma: no-cover
' install it with `pip install neptune-client`.')
neptune = None
Experiment = None
_NEPTUNE_AVAILABLE = False

import torch
from torch import is_tensor
Expand Down Expand Up @@ -179,6 +181,9 @@ def __init__(self,
properties: Optional[Dict[str, Any]] = None,
tags: Optional[List[str]] = None,
**kwargs):
if not _NEPTUNE_AVAILABLE:
raise ImportError('You want to use `neptune` logger which is not installed yet,'
' install it with `pip install neptune-client`.')
super().__init__()
self.api_key = api_key
self.project_name = project_name
Expand Down
9 changes: 7 additions & 2 deletions pytorch_lightning/loggers/test_tube.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

try:
from test_tube import Experiment
_TEST_TUBE_AVAILABLE = True
except ImportError: # pragma: no-cover
raise ImportError('You want to use `test_tube` logger which is not installed yet,' # pragma: no-cover
' install it with `pip install test-tube`.')
Experiment = None
_TEST_TUBE_AVAILABLE = False

from pytorch_lightning.loggers.base import LightningLoggerBase
from pytorch_lightning.utilities.distributed import rank_zero_only
Expand Down Expand Up @@ -62,6 +63,10 @@ def __init__(self,
debug: bool = False,
version: Optional[int] = None,
create_git_tag: bool = False):

if not _TEST_TUBE_AVAILABLE:
raise ImportError('You want to use `test_tube` logger which is not installed yet,'
' install it with `pip install test-tube`.')
super().__init__()
self.save_dir = save_dir
self._name = name
Expand Down
7 changes: 7 additions & 0 deletions pytorch_lightning/loggers/trains.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
try:
import trains
from trains import Task
_TRAINS_AVAILABLE = True
except ImportError: # pragma: no-cover
trains = None
Task = None
_TRAINS_AVAILABLE = False
raise ImportError('You want to use `TRAINS` logger which is not installed yet,' # pragma: no-cover
' install it with `pip install trains`.')

Expand Down Expand Up @@ -91,6 +95,9 @@ def __init__(
auto_connect_frameworks: bool = True,
auto_resource_monitoring: bool = True
) -> None:
if not _TRAINS_AVAILABLE:
raise ImportError('You want to use `test_tube` logger which is not installed yet,'
' install it with `pip install test-tube`.')
super().__init__()
if self.bypass_mode():
self._trains = None
Expand Down
9 changes: 7 additions & 2 deletions pytorch_lightning/loggers/wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
try:
import wandb
from wandb.wandb_run import Run
_WANDB_AVAILABLE = True
except ImportError: # pragma: no-cover
raise ImportError('You want to use `wandb` logger which is not installed yet,' # pragma: no-cover
' install it with `pip install wandb`.')
wandb = None
Run = None
_WANDB_AVAILABLE = False

from pytorch_lightning.loggers.base import LightningLoggerBase
from pytorch_lightning.utilities import rank_zero_only
Expand Down Expand Up @@ -67,6 +69,9 @@ def __init__(self,
experiment=None,
entity=None,
group: Optional[str] = None):
if not _WANDB_AVAILABLE:
raise ImportError('You want to use `wandb` logger which is not installed yet,' # pragma: no-cover
' install it with `pip install wandb`.')
super().__init__()
self._name = name
self._save_dir = save_dir
Expand Down