Skip to content

Conversation

@timothy-nunn
Copy link
Collaborator

Writes an additional logfile in the PROCESS working directory (where the input file is) that follows the name of the input file:

  • my.IN.DAT produces a my.process.log
  • my_IN.DAT produces a my_process.log
image

This does not remove the old process.log file which is created in the terminal working directory.

@timothy-nunn timothy-nunn linked an issue Jan 8, 2026 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 57.89474% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.93%. Comparing base (8a4d67c) to head (2c33138).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
process/main.py 57.89% 8 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@je-cook je-cook left a 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]))
Copy link
Collaborator

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?

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

@timothy-nunn timothy-nunn requested a review from je-cook January 12, 2026 13:26
# 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:
Copy link
Collaborator

@je-cook je-cook Jan 15, 2026

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

Copy link
Collaborator

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?

Copy link
Collaborator Author

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()

@timothy-nunn
Copy link
Collaborator Author

I have fixed this problem by simplifying the setup_logger method. Instead of adding our loggers to the root logger, we only modify the process package logger. Each time we setup_logger we remove all existing handlers on that logger and add them back.

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 pytest does not write to process.log

@timothy-nunn timothy-nunn requested a review from je-cook January 15, 2026 15:31
@je-cook je-cook merged commit cc2bbca into main Jan 15, 2026
52 of 60 checks passed
@je-cook je-cook deleted the 4001-write-processlog-in-the-same-directory-as-the-input-file branch January 15, 2026 15:35
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.

Write process.log in the same directory as the input file

4 participants