-
Notifications
You must be signed in to change notification settings - Fork 2
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
logger api #50
base: main
Are you sure you want to change the base?
logger api #50
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per face to face, remaining TODOs include some tests to verify the logs are created + loading logs works and also some useful utils for callback writing. Overall, looks minimal but functional!
"""Initializes the BaseLogger with a specified log directory. | ||
|
||
Args: | ||
log_dir (str): Directory to store the logs. If None, uses default log directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add type hints in the function signatures, we can remove the redundant types in the docstring.
def log_metric(self, key, value, step=None): | ||
"""Logs a metric value. | ||
|
||
Args: | ||
key (str): The name of the metric. | ||
value (float): The value of the metric. | ||
step (int, optional): The step number at which the metric is logged. | ||
""" | ||
raise NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: do you want every child class to have log_metric
and log_params
? If so, I would make BaseLogger
abstract and decorate these abstractmethod
instead. If, however, there are some situations where child classes shouldn't necessarily implement these functions, then it's fine to leave it as-is. I don't know what vision we have for the logging API.
) | ||
|
||
# Save the log in the current directory | ||
log_dir = os.path.join(os.path.abspath(os.getcwd()), "logs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in most of this repo, we use pathlib.Path
. For consistency, it would be nice to change the os
-based code to instead use Path
. If you don't want to do it, it's also totally fine.
logger = LoggerFactory.get_logger("tensorboard", log_dir) | ||
|
||
# Define a callback to log progress | ||
times = [datetime.now()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: at time of review, I don't see a callback here. I also haven't run the code myself since this isn't ready for review yet, so I could just be misunderstanding how the logging works in this example.
Co-authored-by: alberthli <alberthli@caltech.edu>
Implementing a base logger class that support custom logger backends.