Fix cache path and add null-safety to sequence data rendering#67
Conversation
The Sequence View / Internal Fragment Map components crashed with
`TypeError: 'NoneType' object is not subscriptable` whenever a user
submitted a proteoform sequence and opened the FLASHDeconv viewer.
FLASHDeconvSequenceInput writes the sequence to `workspace/cache`,
and FLASHDeconvViewer reads it from the same path (so the layout
gains `sequence_view`). But `src/render/update.py:get_sequence` and
`FLASHDeconvLayoutManager` were looking at `workspace/flashdeconv/cache`,
so they never found the cached sequence and returned `None`. The
caller then subscripted `None[0]` and crashed.
Point both readers at `workspace/cache` to match the writer, and add
a defensive `if sequence is None: data['sequence_data'] = {}` branch
in `update_data` (matching the existing pattern used in the flashtnt
branch of `filter_data`) so a missing cache renders empty instead of
crashing.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR consolidates FileManager cache directory paths from nested ChangesCache consolidation and sequence data refactoring
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR fixes the cache directory path structure and adds null-safety checks to the sequence data rendering logic in the update module. The changes ensure the application gracefully handles cases where sequence data is unavailable.
Key Changes
Cache path simplification: Changed cache path from
'flashdeconv/cache'to'cache'in bothsrc/render/update.pyandcontent/FLASHDeconv/FLASHDeconvLayoutManager.py. This aligns the cache directory structure with the workspace organization.Null-safety for sequence data: Refactored
update_data()function to handle cases whereget_sequence()returnsNone:get_sequence()once and stores the result to avoid redundant callssequence_dataandinternal_fragment_datawhen sequence is unavailableCode cleanup: Fixed trailing whitespace and improved code formatting for consistency
Implementation Details
The sequence data rendering now follows a defensive programming pattern:
Nonebefore attempting to renderThis prevents potential
TypeErrorexceptions when trying to accesssequence[0]on aNonevalue.https://claude.ai/code/session_01J1rbXX85Rs3K7gENQPUYmB
Summary by CodeRabbit