⚡ Bolt: Optimize file upload memory usage#14
⚡ Bolt: Optimize file upload memory usage#14google-labs-jules[bot] wants to merge 1 commit intomainfrom
Conversation
Replaces `read().decode()` with `io.TextIOWrapper` for MGF and mzTab file uploads. This streams the decoding process, avoiding loading the entire file and its decoded string into memory simultaneously. Also added `__pycache__/` to .gitignore.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What:
Replaced
io.StringIO(file.read().decode('utf-8'))withio.TextIOWrapper(file, encoding='utf-8')for handling MGF and mzTab file uploads inapp.py.🎯 Why:
The original method read the entire binary file content into memory, decoded it into a massive string, and then wrapped it in a buffer. For large proteomics files (which can be GBs), this caused a significant memory spike (2x-3x file size).
📊 Impact:
Significantly reduces peak memory usage by streaming the text decoding instead of loading it all at once.
🔬 Measurement:
Verified with a script (
verify_optimization.py- since removed) thatpyteomicsparsers correctly handle the streamed input and produce identical results to the original method. Existingpytestsuite passed.Also fixed
.gitignoreto exclude__pycache__.PR created automatically by Jules for task 1460394650084140161 started by @erayfirat