Skip to content

Conversation

@mingxin-zheng
Copy link
Contributor

@mingxin-zheng mingxin-zheng commented Mar 25, 2025

Fixes #32

Description

Add the modifier @requires_rti so that we don't need to duplicate the following snippet

try:
    RTI_AVAILABLE = bool(find_spec("rti.connextdds"))
    if RTI_AVAILABLE:
        license_path = os.getenv("RTI_LICENSE_FILE")
        RTI_AVAILABLE = bool(license_path and os.path.exists(license_path))
except ImportError:
    RTI_AVAILABLE = False

Signed-off-by: Mingxin Zheng <[email protected]>
@mingxin-zheng mingxin-zheng requested review from KumoLiu and Nic-Ma March 25, 2025 08:23
Copy link
Contributor

@Nic-Ma Nic-Ma left a comment

Choose a reason for hiding this comment

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

mingxin-zheng and others added 5 commits March 30, 2025 06:23
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
Signed-off-by: Mingxin Zheng <[email protected]>
@mingxin-zheng
Copy link
Contributor Author

mingxin-zheng commented Mar 30, 2025

pr83.log

test log after refractor

@mingxin-zheng mingxin-zheng requested a review from Copilot March 30, 2025 06:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new decorator, @requires_rti, to remove duplicated RTI availability checks from our unit tests. The changes replace the inline try/except blocks and skipUnless decorators with a single, reusable decorator imported from helpers.py.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
workflows/robotic_ultrasound/tests/test_utils/test_visualization.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_simulation/test_ultrasound.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_simulation/test_target.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_simulation/test_sim_with_dds.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_simulation/test_franka.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_simulation/test_camera.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_simulation/test_base.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_policy_runner/test_pi0.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_holoscan_apps/test_realsense_camera.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_dds/test_subscriber.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/test_dds/test_publisher.py Replaced inline RTI check with @requires_rti
workflows/robotic_ultrasound/tests/helpers.py Added the helper decorator to encapsulate RTI checks
Comments suppressed due to low confidence (1)

workflows/robotic_ultrasound/tests/helpers.py:20

  • [nitpick] Consider caching the result of os.getenv('RTI_LICENSE_FILE') in a local variable to avoid calling it twice, improving readability and potentially performance.
def requires_rti(func):

Copy link
Contributor

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, LGTM.

@mingxin-zheng mingxin-zheng merged commit d476441 into main Apr 1, 2025
3 checks passed
@mingxin-zheng mingxin-zheng deleted the mz/requires_rti branch April 1, 2025 01:01
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.

Remove the duplication in unit test functions

4 participants