Proposed Fix for Issue #2695 - Function iter_project_parameters#2737
Proposed Fix for Issue #2695 - Function iter_project_parameters#2737jmcouffin merged 4 commits intopyrevitlabs:developfrom
Conversation
…unctions (fixes pyrevitlabs#2695) - Add iter_project_parameters() generator function to yield project parameters one at a time - Refactor get_project_parameters() to use the new iterator for improved efficiency - Add comprehensive unit test_project_parameters suite in pyRevit Dev Tools for validation with pushbutton addition - Ensure model_has_parameter() returns proper boolean values
There was a problem hiding this comment.
PR Summary:
This PR implements a memory-efficient iterator for project parameters as requested in #2695. Key changes include:
• Added iter_project_parameters() generator function that yields parameters one at a time
• Refactored existing functions to use the iterator for improved efficiency
• Fixed model_has_parameter() to return proper boolean values
• Added comprehensive test suite for validation
Review Summary:
The implementation correctly addresses the requested feature with proper iterator pattern usage. The refactoring maintains backward compatibility while providing memory efficiency benefits for large projects. I identified 2 issues related to pyRevit's IronPython coding standards: a bare except clause that should catch specific exceptions, and a missing UTF-8 encoding header required for IronPython compatibility. Please provide feedback on this review approach which I'll incorporate into future reviews.
Follow-up suggestions:
• @devloai fix the identified coding standard issues
• @devloai validate the iterator performance with memory profiling
.../pyRevitDev.tab/Debug.panel/Unit Tests.pulldown/Test Project Parameters.pushbutton/script.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
This PR implements a memory-efficient iterator for project parameters as requested in issue #2695. The implementation introduces a generator function that yields parameters one at a time instead of loading all parameters into memory at once.
- Adds
iter_project_parameters()generator function with improved error handling for shared parameters - Refactors existing functions to use the iterator internally for consistency
- Fixes
model_has_parameter()to return proper boolean values instead of truthy objects
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyrevitlib/pyrevit/revit/db/query.py | Implements the iterator function and refactors related functions to use it |
| extensions/pyRevitDevTools.extension/pyRevitDev.tab/Debug.panel/Unit Tests.pulldown/bundle.yaml | Adds test button to UI layout |
| extensions/pyRevitDevTools.extension/pyRevitDev.tab/Debug.panel/Unit Tests.pulldown/Test Project Parameters.pushbutton/script.py | Comprehensive test suite for validation |
|
Thanks for your contribution @rayala30 |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25211+1247-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25213+1402-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1027-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1429-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+0909-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1354-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1400-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1405-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1421-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25220+1008-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25225+0806-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25225+1628-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25230+1701-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0824-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0848-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0859-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25232+1126-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25232+1352-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25245+0639-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25245+0642-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25245+1846-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25246+0855-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25248+0948-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0758-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0805-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0824-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25252+1659-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0644-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0911-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25256+0727-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25258+1448-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25265+1047-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25266+0803-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25268+1757-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1336-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1431-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1436-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1822-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25271+1719-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2003-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2012-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2017-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2149-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25274+1734-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1425-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1427-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25279+2157-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25302+0949-wip |
Function: iter_project_parameters
Description
This PR implements a memory-efficient iterator for project parameters in query.py as requested in #2695. The new iter_project_parameters() function uses yield to return parameters one at a time instead of building a complete list in memory.
Changes Made:
Checklist
Before submitting your pull request, ensure the following requirements are met:
pipenv run black {source_file_or_directory}Related Issues
If applicable, link the issues resolved by this pull request:
iter_project_parametersto make the related functions more efficient #2695Additional Notes
Testing:
Added comprehensive test suite accessible via pyRevitDev Tab > Unit Tests > "Test Project Parameters" including basic functionality validation, early termination testing, boolean return verification, performance comparison, and parameter listing. All tests pass successfully in environment.
This is my first contribution to open source! I've tested the implementation to the best of my knowledge and followed the existing code patterns. Happy to address any feedback or suggestions.
Thank you for contributing to pyRevit! 🎉