Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the Python assimilator handler by adding a file existence check before processing output files. Without this check, the script would fail when attempting to process non-existent files through the is_gzip() function (which calls os.path.getsize()) or the mv command.
Changes:
- Added file existence validation before processing each output file
- Added error message printing and graceful skip for missing files using
continue
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tools/sample_assimilate.py
Outdated
| for i in range(nfiles): | ||
| outfile_path = sys.argv[2*i+3] | ||
| if not os.path.exists(outfile_path): | ||
| print('file not found: ', outfile_path) |
There was a problem hiding this comment.
The print statement with a comma separator will add an extra space between the colon and the filepath. Consider using string formatting (e.g., f'file not found: {outfile_path}' or 'file not found: {}'.format(outfile_path)) to avoid the double space in the output.
| print('file not found: ', outfile_path) | |
| print(f'file not found: {outfile_path}') |
tools/sample_assimilate.py
Outdated
| for i in range(nfiles): | ||
| outfile_path = sys.argv[2*i+3] | ||
| if not os.path.exists(outfile_path): | ||
| print('file not found: ', outfile_path) |
There was a problem hiding this comment.
Error messages should be written to stderr for consistency. Line 65 in this same file uses sys.stderr.write() for error reporting. Using print() sends the message to stdout instead of stderr, which is inconsistent with error reporting conventions and could interfere with normal output parsing.
| print('file not found: ', outfile_path) | |
| sys.stderr.write('file not found: %s\n' % (outfile_path,)) |
check for existence of output file
Summary by cubic
Handle missing output files in the Python assimilator handler by checking existence before moving. Missing files are logged to stderr and skipped to prevent crashes.
Written for commit 0e05f01. Summary will update on new commits.