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

[Small PR] Logging dir and buffer outputs: fix issue and improvements #322

Merged
merged 5 commits into from
Jun 11, 2024

Conversation

alexhernandezgarcia
Copy link
Owner

Note for reviewers: There are many files changed but it's mostly the same change applied to many config files.

This PR fixes an issue introduced in a recent PR and makes various changes to hopefully improve the handling of the logging directory and the buffer output files:

  • Now Hydra does not change to the output directory by default, so I had to add a couple of lines in main.py to make the actual logging directory be Hydra's output directory. Let's call this directory /log/dir/, which will be stored in config.logger.logdir.path
  • The Logger now creates a data directory in /log/dir/data/ (as well as a /log/dir/ckpts/`) meant to store the replay buffer, the train data and the test data.
  • The Buffer will thus not create files anymore in the source code directory.
  • I have removed the need to specify env.buffer.train.output_csv and env.buffer.train.output_pkl (and the test counterparts) in order to make use of the buffer. This simplifies its use and the code. And the replay, train and test output files will always be stored simply as /log/dir/data/replay.pkl, /log/dir/data/train.csv, /log/dir/data/train.pkl, etc.

data_path=None,
train=None,
test=None,
logger=None,
**kwargs,
):
self.logger = logger
self.datadir = logger.datadir
Copy link
Collaborator

Choose a reason for hiding this comment

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

logger defaults to None, if this is allowed it should be handled here; otherwise make it required?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good point, done here: f8c235c

Comment on lines +74 to +77
if "path" in logdir:
self.logdir = Path(logdir.path)
else:
self.logdir = Path(logdir.root)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this needed? It seems very arbitrary.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Not sure if it's strictly needed but it's additional flexibility. Currently, logdir.path is created in main.py, but this will make it still work if the code is run from a different script that does not do that.

@alexhernandezgarcia alexhernandezgarcia merged commit d741e08 into main Jun 11, 2024
1 check passed
@alexhernandezgarcia alexhernandezgarcia deleted the logdir branch June 11, 2024 19:58
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.

None yet

2 participants