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

Comet #215

Merged
merged 12 commits into from
Jan 21, 2021
Merged

Comet #215

merged 12 commits into from
Jan 21, 2021

Conversation

RyanNavillus
Copy link
Collaborator

@RyanNavillus RyanNavillus commented Jan 18, 2021

Added comet writer and made necessary changes to use it with run_experiment().

#214

jkterry1
jkterry1 previously approved these changes Jan 19, 2021
Copy link
Collaborator

@jkterry1 jkterry1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the linting error please

Copy link
Owner

@cpnota cpnota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's for the PR! I requested a few inline changes. A few additional comments:

  1. In the setup.py file, you should add an optional dependency for comet and also modify extras["all"] and extras["dev"]. Let me know if you have any questions about this.
  2. In the scripts folder there are four files which run experiments. Could you add writer as an additional argument?
  3. Normally I would insist on unit tests, but the tensorboard writer is also lacking them due to the need to mock the underlying objects. Will have to revisit this at some point.

@@ -2,6 +2,7 @@
import numpy as np
from scipy import stats
from .writer import ExperimentWriter
from .writer import CometWriter
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use one line to import both of these, i.e. from .writer import ExperimentWriter, CometWriter

def _make_writer(self, logdir, agent_name, env_name, write_loss, writer):
if writer == "comet":
return CometWriter(self, agent_name, env_name, loss=write_loss, logdir=logdir)
else:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is preferred not to have this else because the if block contains a return.

def _make_writer(self, logdir, agent_name, env_name, write_loss, writer):
if writer == "comet":
return CometWriter(self, agent_name, env_name, loss=write_loss, logdir=logdir)
else:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@@ -5,11 +5,18 @@
from datetime import datetime
from tensorboardX import SummaryWriter
from all.logging import Writer
from comet_ml import Experiment
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import fails if comet isn't installed. That appears to by why the tests are failing.

try:
from comet_ml import Experiment
except ImportError:
COMET_AVAILABLE = False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be better to include this block inside the constructor for CometWriter.

self.add_evaluation(name + "/std", std, step)

def add_scalar(self, name, value, step="frame"):
pass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ideal to have this silently fail.

# @abstractmethod
# def set_phase(self, name, mean, std, step="frame"):
# # TODO: Fill
# pass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove dead code.

# pass

@abstractmethod
def close(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This abstract method was added, but not used anywhere. Should run_experiment call this somehow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually called in the Experiment save method. The comet writer doesn't know when to stop an experiment in its dashboard unless you run close or the script ends. This is an issue in jupyter notebooks running interactively because comet won't close the experiment until you start a new one or shut down jupyter. Let me know if you think this is an issue or have any better ways of handling it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be in save because you might want to resume the experiment after. Perhaps the right fix is to add an experiment.close() method.

@cpnota
Copy link
Owner

cpnota commented Jan 19, 2021

Unrelated the code itself: If in the PR you enter the issue number (i.e. #214 ) the project page will magically advance the note.

Copy link
Owner

@cpnota cpnota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright nice, we're close! Just a couple of minor remaining issues.


self._comet.set_name(agent_name)
self.log_dir = logdir
# super().__init__(log_dir=self.log_dir)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

@cpnota cpnota merged commit a37ed4f into develop Jan 21, 2021
@cpnota cpnota mentioned this pull request Jan 24, 2021
@cpnota cpnota deleted the comet branch March 23, 2021 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants