test(training,common,inference): add Hypothesis property-based tests#268
Merged
Conversation
Contributor
Dependency ReviewThe following issues were found:
License Issuesuv.lock
OpenSSF Scorecard
Scanned Files
|
nguyena2
approved these changes
Mar 16, 2026
Contributor
nguyena2
left a comment
There was a problem hiding this comment.
Credit-style rating:
PR Credit Score: 832/850
Equivalent grade: Excellent (approve)
Why this score: very strong coverage improvement, minimal production risk, green CI, and clean scope; slight deduction only for increased test/dependency surface area that may add future maintenance/runtime overhead.
rezatnoMsirhC
approved these changes
Mar 16, 2026
- add hypothesis>=6.100.0 dev dependency and configuration - add property tests for config models, metrics, and robot types - add .hypothesis/ to .gitignore 🧪 - Generated by Copilot
- add hypothesis and matplotlib dev dependencies - add property-based tests for stream, plotting, metrics, context, and config models - add example-based tests for cli_args argument parsing - fix RuntimeError handling in metrics exception handler - fix test_output_dir_must_be_writable for Windows compatibility 🧪 - Generated by Copilot
- add cspell disable for CSI terminal byte characters in stream test - change 'normalised' to 'normalized' for en-US dictionary - apply ruff format to test_cli_args, test_plotting_hypothesis, test-lerobot-inference 🔧 - Generated by Copilot
9c27f1e to
b309580
Compare
- correct conftest.py _SRC base path from src/ to repo root - update inference test imports to evaluation.metrics and evaluation.sil - fix ruff I001 import sorting violations in capture tests 🔧 - Generated by Copilot
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #268 +/- ##
=====================================
Coverage 9.79% 9.79%
=====================================
Files 29 29
Lines 3881 3881
Branches 497 497
=====================================
Hits 380 380
Misses 3491 3491
Partials 10 10
*This pull request uses carry forward flags. Click here to find out more. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Added Hypothesis property-based testing across all three Python source packages (common, inference, training), covering configuration models, CLI argument handling, plotting utilities, robot types, Azure ML context, metrics extraction, and ANSI stream stripping. A shared test helper reduced duplicated module-loading boilerplate, and two targeted fixes addressed a production exception gap and a Windows test compatibility issue.
Closes #240
Type of Change
Component(s) Affected
deploy/000-prerequisites- Azure subscription setupdeploy/001-iac- Terraform infrastructuredeploy/002-setup- OSMO control plane / Helmdeploy/004-workflow- Training workflowssrc/training- Python training scriptsdocs/- DocumentationTesting Performed
planreviewed (no unexpected changes)applytested in dev environmentsmoke_test_azure.py)Documentation Impact
Bug Fix Checklist
Checklist
Changes
Property-Based Tests (7 new files)
Seven new Hypothesis test files were added following the test_<module>_hypothesis.py naming convention, keeping property-based tests separate from existing example-based suites.
TopicConfig,GpioTriggerConfig,PositionTriggerConfig,DiskThresholds,VrTriggerConfig,GapDetectionConfig, andRecordingConfigadd_rsl_rl_argsandupdate_rsl_rl_cfg— argument registration, defaults, string parsing, resume flag, logger choices, config overrides, seed randomization, and project name propagationplot_action_deltas,plot_cumulative_positions,plot_error_heatmap,plot_summary_panel, andplot_aggregate_summaryusing custom composite strategies and headless matplotlib renderingRobotObservationandJointPositionCommand— valid shape acceptance, invalid shape rejection viaflatmap,as_absoluteadditivity, and timestamp preservationazure.ai.ml,azure.identity, andmlflow— tested_optional_env,upload_file,upload_checkpoint, andupload_files_batch_extract_from_valueusingFakeTensorandNumpyArrayLiketest doubles to avoid torch/numpy dependencies, with statistical invariant assertions (min ≤ mean ≤ max)AnsiStrippingStream— plain text passthrough, ANSI code stripping, carriage return normalization, and encoding delegationProduction Fix
RuntimeErrorto the exception tuple in_extract_from_valuein src/training/utils/metrics.py, handling torch tensors that raiseRuntimeErrorduring.item()calls on multi-element tensorsTest Infrastructure
Extracted a shared module-loading helper and fixed a cross-platform compatibility issue.
load_training_modulehelper usingimportlib.utilto load training source modules without importing the full dependency treechmod(0o444)withmonkeypatch.setattr("os.access", ...)in tests/common/test_config_models.py for Windows compatibility where POSIX permission bits do not reliably restrict write accessDependencies
hypothesis>=6.100.0,numpy>=1.26.0,<3.0.0,matplotlib>=3.10.8max_examples = 50,deadline = 500ms.hypothesis/to .gitignorecontourpy,cycler,fonttools,pillow,pyparsing,sortedcontainersRelated Issues
Closes #240
Notes
All 147 tests pass (0 failures, 3 PydanticJsonSchemaWarnings). Ruff reports no lint warnings on new or modified files.