-
Notifications
You must be signed in to change notification settings - Fork 2
Add speed comparison tests for BSB-LAN API calls #1311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1311 +/- ##
=======================================
Coverage 99.88% 99.88%
=======================================
Files 6 6
Lines 886 890 +4
Branches 121 123 +2
=======================================
+ Hits 885 889 +4
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 pull request adds parameter filtering support to BSB-LAN API section validation, enabling selective validation and fetching of specific parameters within sections. This improves efficiency by allowing API calls to request only needed parameters instead of all section parameters. A comprehensive benchmark script is also added to measure and compare different API call strategies.
Changes:
- Added optional
includeparameter to validation methods (_ensure_section_validated,_validate_api_section,validate_section) allowing selective parameter validation within sections - Updated test suite to verify the new filtering functionality with comprehensive test cases and properly updated mock signatures
- Added
examples/speed_test.pybenchmark script to measure and compare performance of different API call strategies including parameter filtering
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/bsblan/bsblan.py | Added include parameter to _ensure_section_validated and _validate_api_section methods; filters section data to only requested parameters before validation |
| src/bsblan/utility.py | Added include parameter to validate_section method; skips validation of parameters not in include list while preserving them in config |
| tests/test_include_parameter.py | Added two new tests verifying parameter filtering during validation and that non-filtered params remain in configuration |
| tests/test_api_validation.py | Updated mock function signatures to accept the new include parameter in four test functions |
| examples/speed_test.py | New benchmark script with 11 tests comparing various API call strategies, parameter filtering, and parallelization approaches |
|



This pull request introduces support for filtering API section validation by specific parameter names, improving efficiency and flexibility when interacting with the BSB-LAN API. It updates both the core implementation and the test suite to allow for selective validation of parameters, rather than always validating all parameters in a section. This is especially useful for performance-sensitive scenarios or when only a subset of parameters is needed.
API section validation filtering:
_ensure_section_validated,_validate_api_section, andvalidate_sectionmethods inbsblan.pyandutility.pynow accept an optionalincludeparameter, allowing validation of only the specified parameter names within a section. [1] [2] [3] [4] [5] [6] [7]_fetch_section_datamethod now passes theincludefilter to section validation, ensuring only relevant parameters are validated and fetched.Testing and validation:
includeparameter in validation-related methods, ensuring correctness and maintaining test coverage. [1] [2] [3] [4]test_include_parameter.pyto confirm that parameter filtering works as expected during section validation and that unfiltered parameters are not inadvertently removed.Benchmarking and examples:
examples/speed_test.pyscript is added to benchmark different API call strategies, including the new parameter filtering capability, to compare performance between various approaches.