-
Notifications
You must be signed in to change notification settings - Fork 17
Write an additional log file in PROCESS working directory #4035
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
Write an additional log file in PROCESS working directory #4035
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4035 +/- ##
==========================================
- Coverage 46.30% 43.93% -2.37%
==========================================
Files 123 123
Lines 28961 30881 +1920
==========================================
+ Hits 13411 13569 +158
- Misses 15550 17312 +1762 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
After thinking about what I said yesterday I agree with this change.
I think it would also be good to change the default file handler to append mode so you don't overwrite the log file.
change L727 to:
logging_file_handler = logging.FileHandler("process.log", mode="a")
alternatively you could rotate the logs somehow but that is more complex and possibly overkill (You could do a symlink process.log to a timed and dated filename)
process/main.py
Outdated
| # Store namespace object of the args | ||
|
|
||
| wkdir_path_length = len(self.args.input.lower().replace("in.dat", "")) | ||
| setup_loggers(Path(self.args.input[:wkdir_path_length])) |
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.
Will moving setup_loggers here not lead to logging not being properly initialised if someone runs process not using the CLI or this class but by direct call of SingleRun or VaryRun?
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.
I think this has always been the case but you are correct
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.
I have added a fix for this to this PR
| # These are the list of handlers to add only if a root logger has not already been created. | ||
| handlers = [logging_stream_handler, logging_file_handler] | ||
|
|
||
| if working_directory_log_path is not None: |
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.
With this new layout do you get multiple single file file handlers eg if you run two single runs on the same prompt? There are other permutations of that we might need to guard against
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.
possibly this is not the case if basicConfig overwrites previous state?
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.
eg if you run two single runs on the same prompt
As in you have a script that does something like this?:
run1 = SingleRun(...)
run1.run()
run2 = SingleRun(...)
run2.run()|
I have fixed this problem by simplifying the I have added in a way (not very nice) of disabling these loggers--expect for the model logger because this is required for PROCESS' error handing system--during tests so that running |
Writes an additional logfile in the PROCESS working directory (where the input file is) that follows the name of the input file:
my.IN.DATproduces amy.process.logmy_IN.DATproduces amy_process.logThis does not remove the old
process.logfile which is created in the terminal working directory.