Skip to content
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

fix: pattern resolver update #116

Merged
merged 14 commits into from
Jan 30, 2025
Merged

Conversation

strixy16
Copy link
Collaborator

@strixy16 strixy16 commented Jan 30, 2025

PatternResolver in med-imagetools updated the input argument from pattern_parser to pattern_matcher, updated this to match here.

Summary by CodeRabbit

  • Chores
    • Updated parameter naming in the PatternResolver class for improved clarity and consistency.
    • Modified the roiNames parameter format in segmentation loading tests for better structure and clarity.
    • Adjusted expected output labels in segmentation tests to reflect new naming conventions.
    • Reorganized import statements to source functions from a new module, maintaining accessibility.

@strixy16 strixy16 requested a review from jjjermiah January 30, 2025 20:05
Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Warning

Rate limit exceeded

@strixy16 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 6377f26 and e5517ce.

📒 Files selected for processing (1)
  • src/readii/io/utils/pattern_resolver.py (2 hunks)

Walkthrough

The pull request includes updates to parameter names and data structures in various test files and the PatternResolver class. Specifically, the pattern_parser parameter has been renamed to pattern_matcher in the PatternResolver class. Additionally, the roiNames parameter in several test files has been modified from a string format to a dictionary format, reflecting a more structured approach to specifying regions of interest. These changes do not affect the overall functionality but enhance clarity and consistency in the code.

Changes

File Change Summary
src/readii/io/utils/pattern_resolver.py Renamed pattern_parser parameter to pattern_matcher in PatternResolver.__init__() method
tests/test_feature_extraction.py, tests/test_image_processing.py Updated roiNames parameter from string format 'Tumor_c.*' to dictionary format {'GTV':'Tumor_c.*'}; modified expected return values accordingly
tests/test_loaders.py Updated test_loadSegmentationRTSTRUCT to use @pytest.mark.parametrize, changing roiNames from string to parameterized input; adjusted expected outputs dynamically based on input
src/readii/process/__init__.py Removed imports from .select module and added them to .subset module; updated __all__ list accordingly

Possibly related PRs

  • feat: add io/loaders module  #83: The changes in the main PR involve renaming a parameter in the PatternResolver class, while the retrieved PR introduces a new module for loading functionalities, which may include similar classes or functions related to loading patterns or configurations.

Poem

🐰 A Rabbit's Renaming Rhyme 🔤

In code where patterns softly gleam,
A parameter shifts, part of our scheme.
From 'parser' to 'matcher' we gently glide,
Clarity dancing, with linguistic pride!

Hop, hop, rename! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jjjermiah
Copy link
Contributor

oops sorry about that, forgot it was used here

updated loadSegmentationRTSTRUCT to use a dictionary input for roiNames since med-imagetools updated the functionality and lists and strings don't work as expected anymore
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (1)
tests/test_feature_extraction.py (1)

Line range hint 134-139: Update roiNames parameter in test_4DLung_radiomicFeatureExtraction_output.

This test still uses the old string format for roiNames while other tests have been updated to use the dictionary format.

Apply this diff to maintain consistency:

    actual = radiomicFeatureExtraction(lung4DMetadataPath,
                                      imageDirPath = "tests/",
-                                      roiNames = "Tumor_c40",
+                                      roiNames = {"GTV": "Tumor_c.*"},
                                      outputDirPath = "tests/4D-Lung/results/")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78b071d and abaac85.

⛔ Files ignored due to path filters (1)
  • pixi.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • tests/test_feature_extraction.py (1 hunks)
  • tests/test_image_processing.py (1 hunks)
  • tests/test_loaders.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Unit-Tests (windows-latest, py312)
  • GitHub Check: Unit-Tests (windows-latest, py311)
  • GitHub Check: Unit-Tests (windows-latest, py310)
🔇 Additional comments (3)
tests/test_image_processing.py (1)

21-22: LGTM! The changes align with the standardization of ROI naming.

The update from string pattern to dictionary format provides better structure and clarity for ROI specification.

Let's verify that this change is consistent across all test files:

✅ Verification successful

The ROI naming standardization is consistent with the test suite

The change to dictionary format {'GTV':'Tumor_c.*'} aligns with the established pattern in test_loaders.py and maintains compatibility with the loader implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all roiNames parameter usage
rg "roiNames\s*=" -A 2

Length of output: 3754


Script:

#!/bin/bash
# Check the implementation of loadSegmentation and related functions
ast-grep --pattern 'def loadSegmentation($$$)' -A 30

Length of output: 54


Script:

#!/bin/bash
# Search for segmentation loading related functions with more context
rg "def.*[Ss]egmentation|def.*RTSTRUCT" -A 30

Length of output: 34686

tests/test_loaders.py (1)

61-61: LGTM! Consistent with the ROI naming standardization.

The changes align with the updates in other test files, using the dictionary format for ROI specification and the 'GTV' key.

Also applies to: 68-68

tests/test_feature_extraction.py (1)

40-41: LGTM! Consistent with ROI naming standardization.

The changes align with the updates in other test files.

tests/test_loaders.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
tests/test_loaders.py (1)

74-75: ⚠️ Potential issue

Fix hardcoded error message in assertion.

The error message is hardcoded to "GTV" but the test handles multiple expected values ("GTV" and "Tumor_c40").

Apply this diff to make the error message dynamic:

    assert list(actual.keys()) == [expected], \
-        f"Segmentation label is wrong, should be GTV, getting {list(actual.keys())}"
+        f"Segmentation label is wrong, should be {expected}, getting {list(actual.keys())}"
🧹 Nitpick comments (1)
tests/test_loaders.py (1)

Line range hint 1-1: Consider using explicit imports instead of star imports.

While star imports are common in test files, explicit imports make the code more maintainable and help static analyzers. Consider importing the required functions explicitly:

-from readii.loaders import *
+from readii.loaders import loadDicomSITK, loadSegmentation
🧰 Tools
🪛 Ruff (0.8.2)

67-67: loadSegmentation may be undefined, or defined from star imports

(F405)


79-79: sitk may be undefined, or defined from star imports

(F405)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abaac85 and 6377f26.

⛔ Files ignored due to path filters (1)
  • pixi.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • src/readii/process/__init__.py (1 hunks)
  • tests/test_loaders.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
tests/test_loaders.py

67-67: loadSegmentation may be undefined, or defined from star imports

(F405)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Unit-Tests (macos-14, py312)
  • GitHub Check: Unit-Tests (macos-14, py311)
  • GitHub Check: Unit-Tests (macos-14, py310)
  • GitHub Check: Unit-Tests (macos-latest, py311)
  • GitHub Check: Unit-Tests (macos-latest, py310)
🔇 Additional comments (2)
src/readii/process/__init__.py (1)

16-20: Verify that the functions exist in the new .subset module.

The functions have been moved from .select to .subset. Let's verify that they exist in the new location.

✅ Verification successful

Functions successfully relocated to .subset module

All three functions are properly defined in the new location with their complete implementations, and no legacy imports from .select remain in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the functions exist in the new .subset module

# Search for function definitions in the .subset module
echo "Searching for function definitions in .subset module..."
rg -A 5 "^def (dropUpToFeature|getOnlyPyradiomicsFeatures|selectByColumnValue)" src/readii/process/subset.py

# Search for any remaining usages of these functions from .select
echo "Checking for any remaining imports from .select..."
rg "from.*\.select.*import.*(dropUpToFeature|getOnlyPyradiomicsFeatures|selectByColumnValue)"

Length of output: 1588

tests/test_loaders.py (1)

57-64: Well-structured test parametrization!

The parametrization effectively covers multiple input formats while maintaining backward compatibility. This is a good example of comprehensive test design.

@strixy16 strixy16 merged commit 39a6d6b into main Jan 30, 2025
18 checks passed
@strixy16 strixy16 deleted the katys/fix/pattern_resolver_update branch January 30, 2025 21:50
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 48.12%. Comparing base (49b38ce) to head (e5517ce).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/readii/process/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #116   +/-   ##
=======================================
  Coverage   48.12%   48.12%           
=======================================
  Files          34       34           
  Lines        1492     1492           
=======================================
  Hits          718      718           
  Misses        774      774           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants