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

logger api #50

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

logger api #50

wants to merge 3 commits into from

Conversation

kli58
Copy link
Collaborator

@kli58 kli58 commented Dec 15, 2023

Implementing a base logger class that support custom logger backends.

@kli58 kli58 changed the title logger apu logger api Dec 15, 2023
Copy link
Contributor

@alberthli alberthli left a 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.
Copy link
Contributor

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.

Comment on lines +21 to +29
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
Copy link
Contributor

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")
Copy link
Contributor

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()]
Copy link
Contributor

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>
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.

2 participants