Skip to content

Conversation

@aman0311x
Copy link

@aman0311x aman0311x commented Dec 22, 2025

Fixes # .

Description

This pull request fixes incorrect formatting and clarifies the documentation
for the network_type argument in PerceptualLoss.

The docstring now correctly reflects the supported network options
and matches the actual implementation.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

No functional behavior is changed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 22, 2025

📝 Walkthrough

Walkthrough

Docstring-only edits in monai/losses/perceptual.py: network_type documentation reformatted to a bullet list of allowed values; pretrained description corrected from "LIPIS" to "LPIPS"; channel_wise description indentation fixed. No runtime, behavioral, or public-signature changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed Title directly summarizes the main change: fixing network_type docstring formatting in PerceptualLoss, matching the core objective.
Description check ✅ Passed Description covers required sections with clear explanation of changes, types of changes selected, and notes no functional behavior changed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 5df176e and d66f4b8.

📒 Files selected for processing (1)
  • monai/losses/perceptual.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • monai/losses/perceptual.py

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
monai/losses/perceptual.py (1)

75-75: Update type annotation to match accepted types.

Type annotation specifies str but should be str | PercetualNetworkType to match the docstring and actual usage.

🔎 Proposed fix
-        network_type: str = PercetualNetworkType.alex,
+        network_type: str | PercetualNetworkType = PercetualNetworkType.alex,
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 15fd428 and 7ce29a1.

📒 Files selected for processing (1)
  • monai/losses/perceptual.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

Review the Python code for quality and correctness. Ensure variable names adhere to PEP8 style guides, are sensible and informative in regards to their function, though permitting simple names for loop and comprehension variables. Ensure routine names are meaningful in regards to their function and use verbs, adjectives, and nouns in a semantically appropriate way. Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings. Examine code for logical error or inconsistencies, and suggest what may be changed to addressed these. Suggest any enhancements for code improving efficiency, maintainability, comprehensibility, and correctness. Ensure new or modified definitions will be covered by existing or new unit tests.

Files:

  • monai/losses/perceptual.py
🔇 Additional comments (2)
monai/losses/perceptual.py (2)

52-56: Docstring update is accurate but type annotation doesn't match.

The docstring correctly documents that network_type accepts both str and PercetualNetworkType, but the type annotation on line 75 only specifies str.


98-102: No issues found. StrEnum members inherit from str, so .lower() works on enum inputs and comparison against list(PercetualNetworkType) succeeds for both string and enum inputs. Logic is correct as written.

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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 7ce29a1 and e2d0a02.

📒 Files selected for processing (1)
  • monai/losses/perceptual.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

Review the Python code for quality and correctness. Ensure variable names adhere to PEP8 style guides, are sensible and informative in regards to their function, though permitting simple names for loop and comprehension variables. Ensure routine names are meaningful in regards to their function and use verbs, adjectives, and nouns in a semantically appropriate way. Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings. Examine code for logical error or inconsistencies, and suggest what may be changed to addressed these. Suggest any enhancements for code improving efficiency, maintainability, comprehensibility, and correctness. Ensure new or modified definitions will be covered by existing or new unit tests.

Files:

  • monai/losses/perceptual.py
🧬 Code graph analysis (1)
monai/losses/perceptual.py (1)
monai/utils/enums.py (1)
  • StrEnum (68-90)
🔇 Additional comments (1)
monai/losses/perceptual.py (1)

52-60: LGTM: Improved docstring clarity.

The reformatted list of valid network_type values is clearer than the previous inline notation.

@aman0311x
Copy link
Author

Hi @virginiafdez,

The spelling/enum issue in PerceptualLoss has been fixed (PercetualNetworkType → PerceptualNetworkType), and all references/docstrings have been updated accordingly.

Additionally, all missing DCO sign-offs have been added via remediation commits. Everything should now be in order for review.

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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 3e92d74 and 8be3faa.

📒 Files selected for processing (1)
  • e --abort

Copy link
Contributor

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

LGTM

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: 3

🧹 Nitpick comments (1)
monai/data/image_writer.py (1)

119-128: Move dictionary to module level.

The dictionary is recreated on every call. Define it as a module-level constant.

🔎 Proposed refactor

Move the dictionary definition outside the function, near the top of the file after line 64:

SUPPORTED_WRITERS: dict = {}

_RECOMMENDED_PACKAGES = {
    "png": "Pillow",
    "jpg": "Pillow",
    "jpeg": "Pillow",
    "nii": "nibabel or SimpleITK",
    "niigz": "nibabel or SimpleITK",
    "nrrd": "pynrrd",
    "tif": "Pillow or tifffile",
    "tiff": "Pillow or tifffile",
}

Then reference it in the function at line 131:

-        RECOMMENDED_PACKAGES = {
-            "png": "Pillow",
-            "jpg": "Pillow",
-            "jpeg": "Pillow",
-            "nii": "nibabel or SimpleITK",
-            "nii.gz": "nibabel or SimpleITK",
-            "nrrd": "pynrrd",
-            "tif": "Pillow or tifffile",
-            "tiff": "Pillow or tifffile",
-        }
-
         fmt_clean = fmt.replace(".", "").lower()
-        package_hint = RECOMMENDED_PACKAGES.get(fmt_clean, "")
+        package_hint = _RECOMMENDED_PACKAGES.get(fmt_clean, "")

Note: Also see the critical bug in line 130 regarding "nii.gz" handling.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 8be3faa and 7ad4d87.

📒 Files selected for processing (2)
  • monai/data/image_writer.py
  • monai/losses/perceptual.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • monai/losses/perceptual.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

Review the Python code for quality and correctness. Ensure variable names adhere to PEP8 style guides, are sensible and informative in regards to their function, though permitting simple names for loop and comprehension variables. Ensure routine names are meaningful in regards to their function and use verbs, adjectives, and nouns in a semantically appropriate way. Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings. Examine code for logical error or inconsistencies, and suggest what may be changed to addressed these. Suggest any enhancements for code improving efficiency, maintainability, comprehensibility, and correctness. Ensure new or modified definitions will be covered by existing or new unit tests.

Files:

  • monai/data/image_writer.py
🧬 Code graph analysis (1)
monai/data/image_writer.py (1)
monai/utils/module.py (1)
  • OptionalImportError (309-312)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: min-dep-py3 (3.12)
  • GitHub Check: min-dep-py3 (3.10)
  • GitHub Check: min-dep-pytorch (2.7.1)
  • GitHub Check: min-dep-pytorch (2.5.1)
  • GitHub Check: min-dep-py3 (3.9)
  • GitHub Check: min-dep-pytorch (2.6.0)
  • GitHub Check: min-dep-py3 (3.11)
  • GitHub Check: min-dep-os (windows-latest)
  • GitHub Check: min-dep-pytorch (2.8.0)
  • GitHub Check: min-dep-os (ubuntu-latest)
  • GitHub Check: min-dep-os (macOS-latest)
  • GitHub Check: quick-py3 (windows-latest)
  • GitHub Check: quick-py3 (ubuntu-latest)
  • GitHub Check: flake8-py3 (pytype)
  • GitHub Check: flake8-py3 (codeformat)
  • GitHub Check: quick-py3 (macOS-latest)
  • GitHub Check: flake8-py3 (mypy)
  • GitHub Check: packaging

@aman0311x aman0311x force-pushed the dev branch 3 times, most recently from 7d763b1 to 3d3b0cc Compare December 29, 2025 18:03
@aman0311x
Copy link
Author

The CI is consistently failing at the dependency installation step with:
"OSError: [Errno 28] No space left on device".

All other jobs have completed successfully.

Copy link
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

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

Hi @aman0311x thanks for this contribution. I had a very minor comment but otherwise I think it's good to go. Please update when you can and hopefully we'll have the CICD issues sorted.

@aman0311x
Copy link
Author

All CI/CD checks have passed successfully . Ready for merge! @ericspod

@KumoLiu
Copy link
Contributor

KumoLiu commented Jan 8, 2026

Hi @aman0311x, could you please help resolve the confict, then I will trigger the blossom to merge the pr, thanks!

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

🤖 Fix all issues with AI agents
In @monai/losses/perceptual.py:
- Around line 52-60: Update the docstring for the network_type parameter to use
the corrected enum name PerceptualNetworkType (replace the misspelled
PercetualNetworkType) and convert the current type+list block into a
Google-style parameter description: remove the inline type signature and instead
document network_type: PerceptualNetworkType — one of "alex", "vgg", "squeeze",
"radimagenet_resnet50", "medicalnet_resnet10_23datasets",
"medicalnet_resnet50_23datasets", or "resnet50". Also ensure the default is
noted (PerceptualNetworkType.alex) and the docstring matches the function or
class that defines network_type (search for network_type and
PerceptualNetworkType in perceptual.py).
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 33e12ac and ad454d3.

📒 Files selected for processing (1)
  • monai/losses/perceptual.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

Review the Python code for quality and correctness. Ensure variable names adhere to PEP8 style guides, are sensible and informative in regards to their function, though permitting simple names for loop and comprehension variables. Ensure routine names are meaningful in regards to their function and use verbs, adjectives, and nouns in a semantically appropriate way. Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings. Examine code for logical error or inconsistencies, and suggest what may be changed to addressed these. Suggest any enhancements for code improving efficiency, maintainability, comprehensibility, and correctness. Ensure new or modified definitions will be covered by existing or new unit tests.

Files:

  • monai/losses/perceptual.py
🧬 Code graph analysis (1)
monai/losses/perceptual.py (1)
monai/utils/enums.py (1)
  • StrEnum (68-90)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: quick-py3 (ubuntu-latest)
  • GitHub Check: flake8-py3 (mypy)
  • GitHub Check: flake8-py3 (codeformat)
  • GitHub Check: flake8-py3 (pytype)
  • GitHub Check: quick-py3 (windows-latest)
  • GitHub Check: quick-py3 (macOS-latest)
  • GitHub Check: packaging
  • GitHub Check: build-docs
  • GitHub Check: min-dep-os (macOS-latest)
  • GitHub Check: min-dep-py3 (3.12)
  • GitHub Check: min-dep-py3 (3.10)
  • GitHub Check: min-dep-os (ubuntu-latest)
  • GitHub Check: min-dep-py3 (3.9)
  • GitHub Check: min-dep-pytorch (2.6.0)
  • GitHub Check: min-dep-py3 (3.11)
  • GitHub Check: min-dep-pytorch (2.7.1)
  • GitHub Check: min-dep-pytorch (2.5.1)
  • GitHub Check: min-dep-pytorch (2.8.0)
  • GitHub Check: min-dep-os (windows-latest)
🔇 Additional comments (3)
monai/losses/perceptual.py (3)

26-34: LGTM!

Spelling correction from PercetualNetworkType to PerceptualNetworkType is correct.


79-79: LGTM!

Default parameter correctly uses the renamed PerceptualNetworkType enum.


102-105: LGTM!

Validation and error message correctly reference the renamed PerceptualNetworkType enum.

@aman0311x
Copy link
Author

Hi @KumoLiu, Conflicts are resolved and pushed. Ready for blossom trigger. Thanks!

@KumoLiu
Copy link
Contributor

KumoLiu commented Jan 12, 2026

/build

@github-actions
Copy link

👎 Promotion blocked, new vulnerability found

Vulnerability report

Component Vulnerability Description Severity
monai CVE-2026-21851 MONAI (Medical Open Network for AI) is an AI toolkit for health care imaging. In versions up to and including 1.5.1, a Path Traversal (Zip Slip) vulnerability exists in MONAI's _download_from_ngc_private() function. The function uses zipfile.ZipFile.extractall() without path validation, while other similar download functions in the same codebase properly use the existing safe_extract_member() function. Commit 4014c84 fixes this issue. MEDIUM
Project-MONAI/MONAI CVE-2026-21851 MONAI (Medical Open Network for AI) is an AI toolkit for health care imaging. In versions up to and including 1.5.1, a Path Traversal (Zip Slip) vulnerability exists in MONAI's _download_from_ngc_private() function. The function uses zipfile.ZipFile.extractall() without path validation, while other similar download functions in the same codebase properly use the existing safe_extract_member() function. Commit 4014c84 fixes this issue. MEDIUM

Signed-off-by: Mohammad Amanour Rahman <[email protected]>
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.

4 participants