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(datagraph): iteration through edge_types wasnt updated for seg #131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jjjermiah
Copy link
Contributor

@jjjermiah jjjermiah commented Oct 24, 2024

update edge_types to 8

handle new edge type for SEG->CT/MR mapping in final dataframe processing in parser

Summary by CodeRabbit

  • New Features

    • Enhanced the DataGraph functionality to support an additional edge type, improving the representation of connections between different modalities.
    • Updated logic for edge handling and merging to accommodate the new edge type involving SEG and CT/MR.
  • Bug Fixes

    • Corrected edge type handling in query processing to ensure accurate relationships in the resulting data.
  • Chores

    • Updated package version to 1.5.7 and adjusted the dependency for attrs to allow broader version compatibility.

…EG->CT/MR mapping in final dataframe processing
Copy link

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes involve modifications to the DataGraph class in src/imgtools/modules/datagraph.py, specifically enhancing the handling of edge types. The number of edge types has increased from 7 to 8, requiring updates to the _form_edges and _form_edge_study methods to accommodate this new edge type. Logic adjustments include new conditions for merging dataframes and handling queries related to the additional edge type, particularly involving the SEG modality. Additionally, the pyproject.toml file has been updated to reflect a new package version and a broader dependency constraint for attrs.

Changes

File Path Change Summary
src/imgtools/modules/datagraph.py Updated edge_types in _form_edges and _form_edge_study from np.arange(7) to np.arange(8). Enhanced logic for handling the new edge type, including new merge operations and query processing for SEG.
pyproject.toml Updated package version to "1.5.7" and changed attrs dependency from ^23.2.0 to >=23.2.0.

Poem

In the land of data, where edges entwine,
A new type has blossomed, oh how it does shine!
With SEG now in play, connections expand,
Merging modalities, a grand data strand.
Hopping through queries, with joy we will sing,
For the DataGraph dances, oh what joy it brings! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6956dcc and bb519d3.

📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
🔇 Additional comments (2)
pyproject.toml (2)

Line range hint 4-4: LGTM: Version bump to 1.5.7

The version increment is appropriate for a bug fix release addressing the edge_types iteration issue.


25-25: Verify compatibility with unrestricted attrs versions

The dependency constraint for attrs has been relaxed from ^23.2.0 to >=23.2.0, removing the upper version bound. While attrs has a good track record for backward compatibility, it's recommended to verify that the DataGraph functionality works correctly with the latest attrs version.

Let's check if there are any direct usages of attrs in the codebase that might be sensitive to version changes:

✅ Verification successful

Relaxing attrs version constraint is safe

Based on the codebase analysis, the usage of attrs is minimal and only involves basic Python attribute operations (hasattr, getattr) and HDF5 attributes (attrs). There are no direct uses of the attrs package decorators, classes, or functions that would be sensitive to version changes. The dependency is likely a transitive requirement, and the relaxed version constraint should not impact the functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for attrs usage patterns in the codebase
# Expected: Find direct usage of attrs decorators or functions that might be version-sensitive

# Look for common attrs usage patterns
echo "Searching for attrs usage patterns..."
rg -l "import attr" || rg -l "from attr" || rg -l "@attr" || rg -l "import attrs" || rg -l "from attrs" || rg -l "@attrs"

Length of output: 199


Script:

#!/bin/bash
# Let's try a more comprehensive search for attrs usage
# Search for any Python files that might use attrs
echo "Searching for Python files..."
fd -e py -x cat {} | grep -i "attr" || true

# Also check if there are any test files that might be using attrs
echo -e "\nSearching specifically in test files..."
fd -e py "test_" -x cat {} | grep -i "attr" || true

# Look for any configuration or setup files that might reference attrs
echo -e "\nSearching in setup files..."
fd "setup.py|setup.cfg|pyproject.toml" -x cat {} | grep -i "attr" || true

Length of output: 2990


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 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.

Copy link

@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 and nitpick comments (1)
src/imgtools/modules/datagraph.py (1)

317-333: Consider improving error messages for unsupported modality combinations.

When an unsupported modality combination is provided, the error message "Please enter the correct query" could be more helpful by listing the supported combinations, especially for the newly added SEG modality.

- raise ValueError("Please enter the correct query")
+ raise ValueError(
+     "Unsupported modality combination. Supported combinations:\n"
+     "- Single modality: CT, MR, RTSTRUCT, RTDOSE, PT, SEG\n"
+     "- Two modalities: CT/MR,SEG, CT/MR,RTSTRUCT, etc.\n"
+     "- Three or more: CT/MR,RTSTRUCT,RTDOSE, etc."
+ )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c9a10bb and 6956dcc.

📒 Files selected for processing (1)
  • src/imgtools/modules/datagraph.py (2 hunks)
🔇 Additional comments (2)
src/imgtools/modules/datagraph.py (2)

317-333: LGTM: SEG modality handling is correctly implemented.

The implementation for handling SEG->CT/MR connections is consistent and properly renames the columns for the destination and origin nodes.


Line range hint 1-1: Verify SEG modality implementation consistency.

Let's verify that all SEG-related changes are consistent throughout the codebase.

✅ Verification successful

Based on the shell script results, I can now provide a final response regarding the SEG modality implementation consistency:

SEG modality implementation is properly integrated and consistent.

The codebase shows proper SEG modality support with consistent implementation:

  • SEG modality is correctly handled in the loader system (src/imgtools/io/loaders.py) with a dedicated read_dicom_seg() function
  • SEG reference handling is properly implemented in the crawler (src/imgtools/utils/crawl.py) with specific logic for SEG metadata extraction
  • The implementation follows the same pattern as other modalities (CT, MR, RTSTRUCT, etc.)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify SEG modality implementation consistency

# Test 1: Check for SEG modality references
echo "Checking SEG modality references..."
rg -l "SEG" --type py

# Test 2: Check for edge type 7 references
echo "Checking edge type 7 references..."
rg "edge.*7" --type py

# Test 3: Check for SEG in modality lists
echo "Checking SEG in modality lists..."
rg "supp_mods.*=.*\[.*\]" --type py

Length of output: 376


Script:

#!/bin/bash
# Let's get more context about SEG implementation

# Check SEG references with context
echo "SEG references with context:"
rg "SEG" --type py -B 2 -A 2

# Check modality-related configurations or lists
echo "Modality configurations:"
rg "modalities|MODALITIES|supported_mod" --type py -B 1 -A 1

# Check edge type definitions and handling
echo "Edge type handling:"
rg "edge_type|EDGE_TYPE" --type py -B 1 -A 1

# Check specific file content where SEG was found
echo "Content of files with SEG:"
cat src/imgtools/utils/crawl.py
echo "---"
cat src/imgtools/io/loaders.py

Length of output: 41039

src/imgtools/modules/datagraph.py Show resolved Hide resolved
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 45.73%. Comparing base (7abd175) to head (bb519d3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/imgtools/modules/datagraph.py 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #131      +/-   ##
==========================================
+ Coverage   45.69%   45.73%   +0.04%     
==========================================
  Files          30       30              
  Lines        2867     2871       +4     
==========================================
+ Hits         1310     1313       +3     
- Misses       1557     1558       +1     

☔ 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
None yet
Development

Successfully merging this pull request may close these issues.

1 participant