Skip to content

Conversation

strixy16
Copy link
Collaborator

@strixy16 strixy16 commented May 23, 2025

Summary by CodeRabbit

  • New Features
    • Added a utility to generate a combined dataset name from configuration details.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 23, 2025

Walkthrough

A new utility function, get_full_data_name, has been added to the dataset configuration utilities. This function is now imported and explicitly exported in the utils package, allowing external modules to access it directly. The function constructs a combined dataset name string from configuration data, handling both dictionary and Path inputs.

Changes

File(s) Change Summary
src/readii/utils/dataset_config.py Added get_full_data_name utility function for constructing dataset names from config inputs.
src/readii/utils/init.py Imported and exported get_full_data_name in the utils package's public API.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant utils.dataset_config
    participant utils.__init__

    Caller->>utils.__init__: get_full_data_name(config)
    utils.__init__->>utils.dataset_config: get_full_data_name(config)
    utils.dataset_config->>utils.dataset_config: (If config is Path) loadImageDatasetConfig(config)
    utils.dataset_config->>utils.dataset_config: (If config is dict) use directly
    utils.dataset_config->>utils.dataset_config: (Else) log and raise TypeError
    utils.dataset_config-->>utils.__init__: Return "DATA_SOURCE_DATASET_NAME"
    utils.__init__-->>Caller: Return result
Loading

Poem

In the warren of code, a new name appears,
Combining data sources with dataset frontiers.
Now utils can share this string with delight,
Whether config is a path or a dict, it’s just right!
Hopping through imports, our function takes flight—
A carrot for clarity, in the soft morning light. 🥕

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need 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)

  • @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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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
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: 2

🧹 Nitpick comments (2)
src/readii/utils/dataset_config.py (2)

7-7: Improve type annotation and add return type.

The type annotation can be simplified and the return type should be specified for better code clarity.

-def get_full_data_name(config: Union[Dict | Path]):
+def get_full_data_name(config: Dict | Path) -> str:

8-8: Enhance function documentation.

The docstring is too brief and doesn't specify parameters, return value, or potential exceptions.

-    """Combine DATA_SOURCE and DATASET_NAME config variables into a single string."""
+    """Combine DATA_SOURCE and DATASET_NAME config variables into a single string.
+    
+    Parameters
+    ----------
+    config : Dict | Path
+        Either a dictionary containing dataset configuration with 'DATA_SOURCE' 
+        and 'DATASET_NAME' keys, or a Path to a dataset configuration file.
+        
+    Returns
+    -------
+    str
+        Combined data name in format: "{DATA_SOURCE}_{DATASET_NAME}"
+        
+    Raises
+    ------
+    TypeError
+        If config is neither a Dict nor a Path.
+    ValueError
+        If required keys are missing from the configuration.
+    """
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 941d63b and ae789bf.

📒 Files selected for processing (2)
  • src/readii/utils/__init__.py (1 hunks)
  • src/readii/utils/dataset_config.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/readii/utils/dataset_config.py (1)
src/readii/io/loaders/general.py (1)
  • loadImageDatasetConfig (19-61)
src/readii/utils/__init__.py (1)
src/readii/utils/dataset_config.py (1)
  • get_full_data_name (7-20)
🔇 Additional comments (1)
src/readii/utils/__init__.py (1)

2-2: LGTM! Proper integration of new function.

The import and export of the new get_full_data_name function is correctly implemented, following Python package conventions by adding it to the __all__ list.

Also applies to: 6-6

strixy16 and others added 2 commits May 23, 2025 17:33
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

🧹 Nitpick comments (2)
src/readii/utils/dataset_config.py (2)

7-7: Simplify the type hint syntax.

The Union[Dict | Path] syntax is redundant. In Python 3.10+, you can use the simpler Dict | Path syntax directly.

-def get_full_data_name(config: Union[Dict | Path]):
+def get_full_data_name(config: Dict | Path):

Additionally, consider being more specific about the Dict type:

-def get_full_data_name(config: Dict | Path):
+def get_full_data_name(config: Dict[str, str] | Path):

8-8: Enhance the docstring with parameter and return information.

The current docstring is too brief. Consider adding parameter descriptions, return type, and usage examples for better documentation.

-    """Combine DATA_SOURCE and DATASET_NAME config variables into a single string."""
+    """Combine DATA_SOURCE and DATASET_NAME config variables into a single string.
+    
+    Parameters
+    ----------
+    config : Dict[str, str] | Path
+        Either a dictionary containing dataset configuration with 'DATA_SOURCE' and 
+        'DATASET_NAME' keys, or a Path to a YAML configuration file.
+        
+    Returns
+    -------
+    str
+        Combined data name in the format "{DATA_SOURCE}_{DATASET_NAME}".
+        
+    Raises
+    ------
+    TypeError
+        If config is neither a Dict nor a Path.
+    ValueError
+        If required keys 'DATA_SOURCE' or 'DATASET_NAME' are missing from config.
+    """
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ae789bf and e3b9f0c.

⛔ Files ignored due to path filters (1)
  • pixi.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • src/readii/utils/dataset_config.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/readii/utils/dataset_config.py (1)
src/readii/io/loaders/general.py (1)
  • loadImageDatasetConfig (19-61)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Unit-Tests (windows-latest, py312)
  • GitHub Check: Unit-Tests (windows-latest, py311)
  • GitHub Check: Unit-Tests (windows-latest, py310)
  • GitHub Check: Unit-Tests (macos-14, py312)
  • GitHub Check: Unit-Tests (macos-14, py310)
  • GitHub Check: Unit-Tests (macos-latest, py312)
  • GitHub Check: Unit-Tests (macos-latest, py310)
  • GitHub Check: Unit-Tests (ubuntu-latest, py312)
🔇 Additional comments (2)
src/readii/utils/dataset_config.py (2)

1-5: LGTM! Imports are properly structured.

The imports are well-organized and include all necessary dependencies for the function implementation.


20-27: Excellent error handling implementation!

The error handling for missing dictionary keys is well-implemented with proper logging and exception chaining. This addresses the concerns from previous review comments effectively.

Comment on lines +10 to +18
match type(config):
case Path():
dataset_config = loadImageDatasetConfig(config.stem, config.parent)
case Dict():
dataset_config = config
case _:
message = "Error getting full data name: config must be of type Path or Dict."
logger.debug(message)
raise TypeError(message)
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the assumption about Path naming convention.

The implementation assumes that config.stem (filename without extension) corresponds to the dataset name expected by loadImageDatasetConfig. This assumption should be documented or validated.

Consider adding validation or documentation about the expected file naming convention:


🏁 Script executed:

#!/bin/bash
# Description: Check if there are examples of how dataset config files are named
# to verify the assumption that filename stem equals dataset name

# Search for calls to loadImageDatasetConfig to understand naming patterns
ast-grep --pattern 'loadImageDatasetConfig($_, $_)'

# Look for YAML config files to understand naming conventions
fd -e yaml -e yml | head -10

Length of output: 552


Add validation and documentation for dataset config file naming

Please ensure that when passing a Path to get_dataset_config (in src/readii/utils/dataset_config.py), the filename stem matches both the expected dataset name and its parent directory. Although tests use matching names (e.g. tests/4D-Lung/4D-Lung.yaml → stem “4D-Lung”), this assumption should be explicit and enforced.

• File: src/readii/utils/dataset_config.py
Lines: 10–18

Suggested changes:

     match type(config):
         case Path():
+            # Enforce filename stem == parent directory name == dataset name
+            if config.parent.name != config.stem:
+                raise ValueError(
+                    f"Dataset config file stem '{config.stem}' must match its parent directory name "
+                    f"'{config.parent.name}'"
+                )
             dataset_config = loadImageDatasetConfig(config.stem, config.parent)
         case Dict():
             dataset_config = config

Additionally, update the function’s docstring (or README) to state:

When providing a file path, the config YAML filename (without extension) must match the dataset name and its enclosing directory.

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

Suggested change
match type(config):
case Path():
dataset_config = loadImageDatasetConfig(config.stem, config.parent)
case Dict():
dataset_config = config
case _:
message = "Error getting full data name: config must be of type Path or Dict."
logger.debug(message)
raise TypeError(message)
match type(config):
case Path():
# Enforce filename stem == parent directory name == dataset name
if config.parent.name != config.stem:
raise ValueError(
f"Dataset config file stem '{config.stem}' must match its parent directory name "
f"'{config.parent.name}'"
)
dataset_config = loadImageDatasetConfig(config.stem, config.parent)
case Dict():
dataset_config = config
case _:
message = "Error getting full data name: config must be of type Path or Dict."
logger.debug(message)
raise TypeError(message)
🤖 Prompt for AI Agents
In src/readii/utils/dataset_config.py around lines 10 to 18, the code assumes
that when a Path is passed as config, its filename stem matches the dataset name
and parent directory for loadImageDatasetConfig. To fix this, add validation to
check that the Path's stem equals its parent directory name and raise an error
if not. Also, update the function's docstring to explicitly document that the
config YAML filename (without extension) must match the dataset name and its
enclosing directory.

@codecov
Copy link

codecov bot commented May 23, 2025

Codecov Report

Attention: Patch coverage is 26.08696% with 17 lines in your changes missing coverage. Please review.

Project coverage is 75.51%. Comparing base (2a899a7) to head (e3b9f0c).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/readii/utils/dataset_config.py 22.72% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
- Coverage   76.08%   75.51%   -0.57%     
==========================================
  Files          41       42       +1     
  Lines        2003     2026      +23     
==========================================
+ Hits         1524     1530       +6     
- Misses        479      496      +17     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@strixy16 strixy16 merged commit 71e184f into main May 23, 2025
18 of 20 checks passed
@github-project-automation github-project-automation bot moved this from Focus to Done in READII-2-ROQC Pipeline May 23, 2025
@strixy16 strixy16 deleted the katys/add-config-util branch May 23, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant