-
Notifications
You must be signed in to change notification settings - Fork 633
--show-failed-logs creates excessive output #2101
Description
Snakemake version
snakemake v7.21.0 (python v3.11.0)
Describe the bug
When passing the --show-failed-logs flag to snakemake, it outputs the job logfile to the terminal.
The problem is that it surrounds the output with ='s of the same length as the longest line in the logfile, meaning that if there's one very long line it'll also generate an excessive amount of these ='s.
Code block responsible for formatting the output:
snakemake/snakemake/logging.py
Lines 470 to 487 in 8f79f22
| def show_logs(logs): | |
| for f in logs: | |
| try: | |
| content = open(f, "r").read() | |
| except FileNotFoundError: | |
| yield f"Logfile {f} not found." | |
| return | |
| lines = content.splitlines() | |
| logfile_header = f"Logfile {f}:" | |
| if not lines: | |
| logfile_header += " empty file" | |
| yield logfile_header | |
| return | |
| yield logfile_header | |
| max_len = max(max(len(l) for l in lines), len(logfile_header)) | |
| yield "=" * max_len | |
| yield from lines | |
| yield "=" * max_len |
Line that determines the number of ='s:
snakemake/snakemake/logging.py
Line 484 in 8f79f22
| max_len = max(max(len(l) for l in lines), len(logfile_header)) |
My recommendation is to limit the maximum to a sensible amount, e.g.:
- max_len = max(max(len(l) for l in lines), len(logfile_header))
+ max_len = min(max(max(len(l) for l in lines), len(logfile_header)), 80)Logs
Example output:
Logfile xxx.log:
=============================================== .... x20,000 (not a joke)
Traceback (most recent call last):
...
raise ValueError('Feature IDs found in the table are missing from the '
ValueError: Feature IDs found in the table are missing from the taxonomy: {'9ebc0b1c8dcfd254536036e859d618e8', '8cb8a9a7de5b414f27b96dd6edd57f40', 'd294e6a09f8f7396578d587e102623ab', 'abb551a9eca02618824e611157f85bb0', ....'1c6e92aad743c0e3b0531a87b47e7daf', '116a46a73c4fd21c5b6a08ad5f561485'}
See above for debug info.
=============================================== .... x20,000 (not a joke)Minimal example
snakemake --show-failed-logs with a failing rule that writes a very long line to the logfile.
Additional context