Skip to content

Commit

Permalink
Fix assert wandb Run when mode="disabled" (#14112)
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierdag authored and lexierule committed Aug 9, 2022
1 parent 8cdc867 commit be58159
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pytorch_lightning/loggers/wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def __getstate__(self) -> Dict[str, Any]:

@property # type: ignore[misc]
@rank_zero_experiment
def experiment(self) -> Run:
def experiment(self) -> Union[Run, RunDisabled]:
r"""
Actual wandb object. To use wandb features in your
Expand Down Expand Up @@ -361,11 +361,13 @@ def experiment(self) -> Run:
self._experiment = wandb.init(**self._wandb_init)

# define default x-axis
if isinstance(self._experiment, Run) and getattr(self._experiment, "define_metric", None):
if isinstance(self._experiment, (Run, RunDisabled)) and getattr(
self._experiment, "define_metric", None
):
self._experiment.define_metric("trainer/global_step")
self._experiment.define_metric("*", step_metric="trainer/global_step", step_sync=True)

assert isinstance(self._experiment, Run)
assert isinstance(self._experiment, (Run, RunDisabled))
return self._experiment

def watch(self, model: nn.Module, log: str = "gradients", log_freq: int = 100, log_graph: bool = True) -> None:
Expand Down

0 comments on commit be58159

Please sign in to comment.