Skip to content

Commit

Permalink
Fix pickling NeptuneLogger in offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pitercl committed May 7, 2020
1 parent 8d0236f commit a3d1fd4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pytorch_lightning/loggers/neptune.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ def __init__(self,

def __getstate__(self):
state = self.__dict__.copy()
# cannot be pickled

# Experiment cannot be pickled, and additionally its ID cannot be pickled in offline mode
state['_experiment'] = None
if self.offline_mode:
state['_experiment_id'] = None

return state

@property
Expand Down Expand Up @@ -358,7 +362,8 @@ def _create_or_get_experiment(self):
if self.offline_mode:
project = neptune.Session(backend=neptune.OfflineBackend()).get_project('dry-run/project')
else:
project = neptune.Session.with_default_backend(api_token=self.api_key).get_project(self.project_name)
session = neptune.Session.with_default_backend(api_token=self.api_key)
project = session.get_project(self.project_name)

if self._experiment_id is None:
exp = project.create_experiment(
Expand Down

0 comments on commit a3d1fd4

Please sign in to comment.