-
Notifications
You must be signed in to change notification settings - Fork 1
fixing make sure runing everything smooth #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes update dependency management files by pinning versions and adding new packages, especially for data visualization and scientific computation. The Dockerfile is modified to skip building and installing pyOpenMS Python wheels. The main application logic for viewing results is refactored to improve file selection and spectrum annotation, introducing tolerant matching using Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App (Result_2.py)
participant FileSystem
participant AgGrid
participant Plotter
User->>App (Result_2.py): Open "View Results" tab
App->>FileSystem: List .idXML files in workspace
App->>User: Show select box for .idXML files
User->>App: Selects a file
App->>FileSystem: Load selected .idXML and associated .mzML
App->>AgGrid: Display CSM dataframe with selectable rows
User->>AgGrid: Selects a CSM row
AgGrid->>App: Return selected row data
App->>App: Annotate spectrum using cKDTree matching (if MS2 available)
App->>Plotter: Plot annotated spectrum
Plotter->>User: Display annotated spectrum
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (3)
Dockerfile (1)
1-1: Update the Dockerfile comment to reflect that pyOpenMS is no longer builtThe comment states "This Dockerfile builds OpenMS, the TOPP tools, pyOpenMS and thidparty tools" but lines 82-84 that build pyOpenMS are now commented out. Update the comment to reflect the current behavior.
Apply this diff:
-# This Dockerfile builds OpenMS, the TOPP tools, pyOpenMS and thidparty tools. +# This Dockerfile builds OpenMS, the TOPP tools, and third-party tools. +# Note: pyOpenMS is installed via pip from requirements.txt, not built from source.Also fix the typo: "thidparty" → "third-party"
content/Result_2.py (2)
1-11: Avoid star imports for better code clarityThe star imports (lines 2, 3) make it difficult to track where symbols come from and can lead to namespace pollution. This is causing the static analysis warnings about potentially undefined names.
Replace star imports with explicit imports:
-from src.common.common import * -from src.result_files import * +from src.common.common import page_setup, show_table, show_fig, v_space, save_params +from src.result_files import (load_example_result_files, list_result_example_files, + copy_local_result_files_from_directory, remove_selected_result_files, + remove_all_result_files, download_selected_result_files, + create_zip_and_get_base64_, save_uploaded_result, readAndProcessIdXML)
54-56: Improve exception handling to aid debuggingThe broad exception handler hides the actual error, making debugging difficult.
except Exception as e: + st.error(f"Error loading mzML file: {str(e)}") return None # Return None if any exception occursOr at least log the exception for debugging purposes.
🧹 Nitpick comments (3)
environment.yml (1)
1-1: Address the TODO: Use exact version specifiers for all packagesThe TODO comment correctly identifies an inconsistency issue. Some packages use exact versions (e.g.,
python==3.11,scipy==1.16.1) while others use minimum version constraints (e.g.,streamlit>=1.38.0,pyopenms_viz>=0.1.2). For reproducible builds, consider pinning all versions.Would you like me to help create a version-pinned environment file with all exact versions?
content/Result_2.py (2)
134-138: Replace hardcoded string check with a more robust approachUsing
find("Example") != -1is fragile. Consider using a more explicit check.- if (selected_file.find("Example") != -1): - file_name_wout_out = "Example" + if selected_file.startswith("Example"): + file_name_wout_out = "Example"
186-186: Consider making the m/z tolerance configurableThe hardcoded tolerance of 0.001 might not be suitable for all use cases. Consider making it a configurable parameter.
# At the top of the file or in a config MZ_TOLERANCE = 0.001 # m/z tolerance for peak matching # Then use it here: tolerance = MZ_TOLERANCE
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Dockerfile(1 hunks)content/Result_2.py(2 hunks)environment.yml(1 hunks)requirements.txt(1 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
content/Result_2.py
111-111: load_example_result_files may be undefined, or defined from star imports
(F405)
114-114: Path may be undefined, or defined from star imports
(F405)
120-120: Path may be undefined, or defined from star imports
(F405)
128-128: readAndProcessIdXML may be undefined, or defined from star imports
(F405)
139-139: os may be undefined, or defined from star imports
(F405)
139-139: Path may be undefined, or defined from star imports
(F405)
182-182: np may be undefined, or defined from star imports
(F405)
187-187: np may be undefined, or defined from star imports
(F405)
188-188: np may be undefined, or defined from star imports
(F405)
215-215: pd may be undefined, or defined from star imports
(F405)
218-218: os may be undefined, or defined from star imports
(F405)
220-220: show_fig may be undefined, or defined from star imports
(F405)
220-220: os may be undefined, or defined from star imports
(F405)
🔇 Additional comments (4)
environment.yml (1)
18-18: LGTM!The addition of scipy==1.16.1 is appropriate for the new
cKDTreefunctionality used in Result_2.py.Dockerfile (1)
82-84: pyOpenMS installation is covered by requirements.txt
- requirements.txt includes
pyopenms==3.2.0, sopip install -r requirements.txtwill install pyOpenMS.- The commented-out build steps in Dockerfile (lines 82–84) can be removed, as source-building is no longer needed.
requirements.txt (1)
13-13: SciPy 1.16.1 is a valid, current release.
No changes needed—you can keep the exact pin at line 13 in requirements.txt as is.content/Result_2.py (1)
178-205: Well-implemented tolerant matching with KDTreeThe implementation correctly uses scipy's cKDTree for efficient nearest-neighbor queries with tolerance. The fallback logic for missing MS2 data is also properly handled.
| MS2 = process_mzML_file(os.path.join(Path.cwd().parent , str(st.session_state.workspace)[3:] , "mzML-files" ,selected_mzML_file)) | ||
| if MS2 is None: | ||
| st.warning("The corresponding " + ".mzML file could not be found. Please re-upload the mzML file to visualize all peaks.") | ||
| MS2 = process_mzML_file(os.path.join(Path.cwd().parent , str(st.session_state.workspace)[3:] , "mzML-files" ,f"{file_name_wout_out}.mzML")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve path construction for robustness
The path construction using Path.cwd().parent and string slicing [3:] is fragile and could break if the directory structure changes.
- MS2 = process_mzML_file(os.path.join(Path.cwd().parent , str(st.session_state.workspace)[3:] , "mzML-files" ,f"{file_name_wout_out}.mzML"))
+ mzml_path = Path(st.session_state.workspace) / "mzML-files" / f"{file_name_wout_out}.mzML"
+ MS2 = process_mzML_file(str(mzml_path))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| MS2 = process_mzML_file(os.path.join(Path.cwd().parent , str(st.session_state.workspace)[3:] , "mzML-files" ,f"{file_name_wout_out}.mzML")) | |
| mzml_path = Path(st.session_state.workspace) / "mzML-files" / f"{file_name_wout_out}.mzML" | |
| MS2 = process_mzML_file(str(mzml_path)) |
🧰 Tools
🪛 Ruff (0.12.2)
139-139: os may be undefined, or defined from star imports
(F405)
139-139: Path may be undefined, or defined from star imports
(F405)
🤖 Prompt for AI Agents
In content/Result_2.py at line 139, the current path construction uses
Path.cwd().parent combined with string slicing [3:], which is fragile and
error-prone. Replace this with a more robust approach by using pathlib's Path
methods to join paths without manual string slicing. Construct the full path by
properly joining Path.cwd().parent with the workspace directory and other
subdirectories using Path objects and the / operator or Path.joinpath to ensure
platform-independent and reliable path handling.
Summary by CodeRabbit
New Features
Bug Fixes
Chores