Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CometML tests #585

Merged
merged 2 commits into from
Dec 7, 2019
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
7 changes: 1 addition & 6 deletions pytorch_lightning/logging/comet.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,4 @@ def name(self, value):

@property
def version(self):
if self.project_name and self.rest_api_key:
# Determines the number of experiments in this project, and returns the next integer as the version number
num_exps = len(self.comet_api.get_experiments(self.workspace, self.project_name))
return num_exps + 1
else:
return None
return self.experiment.id
16 changes: 14 additions & 2 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ def test_mlflow_pickle(tmpdir):
trainer2.logger.log_metrics({"acc": 1.0})


def test_comet_logger(tmpdir):
def test_comet_logger(tmpdir, monkeypatch):
"""Verify that basic functionality of Comet.ml logger works."""

# prevent comet logger from trying to print at exit, since
# pytest's stdout/stderr redirection breaks it
import atexit
monkeypatch.setattr(atexit, "register", lambda _: None)

tutils.reset_seed()

try:
Expand Down Expand Up @@ -140,8 +146,14 @@ def test_comet_logger(tmpdir):
assert result == 1, "Training failed"


def test_comet_pickle(tmpdir):
def test_comet_pickle(tmpdir, monkeypatch):
"""Verify that pickling trainer with comet logger works."""

# prevent comet logger from trying to print at exit, since
# pytest's stdout/stderr redirection breaks it
import atexit
monkeypatch.setattr(atexit, "register", lambda _: None)

tutils.reset_seed()

try:
Expand Down