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

Feature/100 separate log files #143

Merged
merged 10 commits into from
Nov 15, 2023
Merged

Conversation

trebacz626
Copy link
Collaborator

No description provided.

kordc
kordc previously approved these changes Nov 6, 2023
Copy link
Collaborator

@kordc kordc left a comment

Choose a reason for hiding this comment

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

lgtm, but we may wait for Seba to also review it

@SebChw
Copy link
Owner

SebChw commented Nov 7, 2023

At the first glance this looks much more complicated than it should be. Please motivate why it was neccesarry

from loguru import logger
from pathlib import Path
from art.paths import LOG_PATH
logger.remove()
Copy link
Owner

Choose a reason for hiding this comment

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

This just makes sure that default loguru handler is removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

from pathlib import Path
from art.paths import LOG_PATH
logger.remove()
logger.add(sys.stdout, format="{message}", level="DEBUG", filter= lambda record: ('halt_exception' not in record['extra']) or (not record['extra']['halt_exception']))
Copy link
Owner

Choose a reason for hiding this comment

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

This filter looks nice (It could even solve our lighnitng issue) but isn't it a big overhead to check in for everything that goes into it? Why this is necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

got rid of it


art_logger = logger

if __name__ == "__main__":
Copy link
Owner

Choose a reason for hiding this comment

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

If this is just for debugging purposes remove it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

yield
return
already_contextualized_logers.add(str(folder_path))
global logger_level
Copy link
Owner

Choose a reason for hiding this comment

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

shouldn't this be more number_of_loggers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

try:
with logger.contextualize(file=str(folder_path)):
try:
yield
Copy link
Owner

Choose a reason for hiding this comment

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

how one can obtain exception here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

art/paths.py Outdated

CHECKPOINTS_PATH = Path("checkpoints")
LOG_PATH = Path("logs")
EXPERIMENT_LOG_PATH = CHECKPOINTS_PATH/"experiment"/"logs"
Copy link
Owner

Choose a reason for hiding this comment

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

The structure is okay but root folder should be user defined. What if I want to run 2 or more experiments in one folder. All will be in the same place?

I mean we have this exp1 defined in our first tutorial

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

than it will be run in another folder so it will by in exp2

art/paths.py Outdated


def get_checkpoint_step_dir_path(step_id: str, step_name: str) -> Path:
"""
Copy link
Owner

Choose a reason for hiding this comment

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

I like this is taken out from jsonsavers

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

@@ -54,11 +56,12 @@ def __call__(
datamodule (L.LightningDataModule): Data module to be used.
Copy link
Owner

Choose a reason for hiding this comment

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

I just wonder why can't we create custom logger here (we will have it's id), after everything is runned we can just remove it by id. We could generate random log name from tempfile library and link it to the results so log path will be available from json. With this we also have logs for every run stored

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done with uuid

@SebChw
Copy link
Owner

SebChw commented Nov 7, 2023

Moreover it is very important for me to create new log file for every run of experiment

Copy link
Owner

@SebChw SebChw left a comment

Choose a reason for hiding this comment

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

Just one change for me and it will be nice. Create UUID just once and all logs from one experiment run has the same name. Maybe some read only singleton?

Then we can easily reconstruct the entire experiment graph

art/paths.py Outdated

CHECKPOINTS_PATH = Path("checkpoints")
LOG_PATH = Path("logs")
EXPERIMENT_LOG_PATH = CHECKPOINTS_PATH/"experiment"/"logs"/"logs.log"
Copy link
Owner

Choose a reason for hiding this comment

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

Why this logs.log?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

corrected

@SebChw SebChw merged commit b6eb63e into develop Nov 15, 2023
@SebChw SebChw deleted the feature/100-separate-log-files branch November 15, 2023 19:04
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.

4 participants