Skip to content

Conversation

@ytl0623
Copy link
Contributor

@ytl0623 ytl0623 commented Nov 24, 2025

…est.skipUnless decorator to the test_onnx method.

Fixes #8533 .

Description

Added an optional_import check for onnxruntime and applied the @unittest.skipUnless decorator to the test_onnx method. This ensures the ONNX tests are automatically skipped if the onnxruntime dependency is missing, preventing the test suite from hanging.

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.

…est.skipUnless decorator to the test_onnx method.

Signed-off-by: ytl0623 <david89062388@gmail.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 24, 2025

Walkthrough

This change adds an optional import check for the onnxruntime package in the RetinaNet test module. A module-level variable detects whether onnxruntime is installed, then conditionally skips the test_onnx test method when the dependency is unavailable. This prevents test hangs that occur when attempting ONNX export operations without the required runtime.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

This is a straightforward pattern: single file modified, standard optional dependency check, and a skip decorator applied to one test method. No complex logic or structural changes involved.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive Title partially describes the main change (adding optional import check and skip decorator) but is truncated and incomplete. Complete the title to clearly state the full change: 'Add optional_import check for onnxruntime and @unittest.skipUnless decorator to test_onnx'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed Description is complete with linked issue reference, clear problem statement, solution, and proper template compliance.
Linked Issues check ✅ Passed PR directly addresses issue #8533 by adding optional_import check and skip decorator to prevent test hangs when onnxruntime is missing.
Out of Scope Changes check ✅ Passed Changes are confined to test_retinanet.py with guard logic for optional dependency, fully scoped to issue #8533 requirements.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 9a45627 and 324b370.

📒 Files selected for processing (1)
  • tests/apps/detection/networks/test_retinanet.py (2 hunks)
🧰 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:

  • tests/apps/detection/networks/test_retinanet.py
🧬 Code graph analysis (1)
tests/apps/detection/networks/test_retinanet.py (1)
monai/utils/module.py (1)
  • optional_import (315-445)
⏰ 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: min-dep-pytorch (2.5.1)
  • GitHub Check: min-dep-os (ubuntu-latest)
  • GitHub Check: min-dep-pytorch (2.8.0)
  • GitHub Check: min-dep-os (macOS-latest)
  • GitHub Check: min-dep-py3 (3.10)
  • GitHub Check: min-dep-pytorch (2.6.0)
  • GitHub Check: min-dep-pytorch (2.7.1)
  • GitHub Check: min-dep-py3 (3.11)
  • GitHub Check: min-dep-py3 (3.12)
  • GitHub Check: min-dep-os (windows-latest)
  • GitHub Check: min-dep-py3 (3.9)
  • GitHub Check: quick-py3 (windows-latest)
  • GitHub Check: flake8-py3 (codeformat)
  • GitHub Check: quick-py3 (ubuntu-latest)
  • GitHub Check: flake8-py3 (pytype)
  • GitHub Check: build-docs
  • GitHub Check: quick-py3 (macOS-latest)
  • GitHub Check: flake8-py3 (mypy)
  • GitHub Check: packaging
🔇 Additional comments (2)
tests/apps/detection/networks/test_retinanet.py (2)

26-26: LGTM—consistent pattern for optional dependency.

Follows the same pattern as the torchvision check above.


173-173: Decorator correctly guards ONNX test.

test_onnx_save confirms onnxruntime dependency at line 782 (optional_import("onnxruntime")). Skipping when unavailable prevents the hang (issue #8533).


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
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 @ytl0623 thanks for this fix, I don't think this conflicts with anything else we're working on so I can approve now.

@KumoLiu KumoLiu enabled auto-merge (squash) November 26, 2025 08:25
@KumoLiu
Copy link
Contributor

KumoLiu commented Nov 26, 2025

/build

2 similar comments
@KumoLiu
Copy link
Contributor

KumoLiu commented Nov 26, 2025

/build

@KumoLiu
Copy link
Contributor

KumoLiu commented Nov 26, 2025

/build

@ytl0623
Copy link
Contributor Author

ytl0623 commented Nov 27, 2025

Hi @KumoLiu and @ericspod, I noticed that the blossom-ci check seems to be stuck in the 'Waiting for status' state for a while.

Is there a known issue with the CI server, or does it require manual approval to run?

Thanks in advance!

@KumoLiu
Copy link
Contributor

KumoLiu commented Nov 27, 2025

/build

@KumoLiu
Copy link
Contributor

KumoLiu commented Nov 27, 2025

Hi @ytl0623, the gitlab server down yesterday, and the team are trying to resolve the issue.
I'm trigger the ci to see if it works now. Thanks.

@KumoLiu KumoLiu merged commit e267705 into Project-MONAI:dev Nov 27, 2025
27 checks passed
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.

ONNX Runtime Needed for RetinaNet Tests

3 participants