Skip to content

Proposed Fix for Issue #2695 - Function iter_project_parameters#2737

Merged
jmcouffin merged 4 commits intopyrevitlabs:developfrom
rayala30:dev/2695
Jul 30, 2025
Merged

Proposed Fix for Issue #2695 - Function iter_project_parameters#2737
jmcouffin merged 4 commits intopyrevitlabs:developfrom
rayala30:dev/2695

Conversation

@rayala30
Copy link
Copy Markdown
Contributor

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:

  • Added iter_project_parameters() generator function that yields project parameters individually
  • Refactored get_project_parameters() to use the iterator internally for consistency
  • Updated get_project_parameter_id() and get_project_parameter() to use the iterator
  • Fixed model_has_parameter() to properly return boolean values
  • Added comprehensive test suite in pyRevit Dev Tools for validation

Checklist

Before submitting your pull request, ensure the following requirements are met:

  • [ X ] Code follows the PEP 8 style guide.
  • [ X ] Code has been formatted with Black using the command:
    pipenv run black {source_file_or_directory}
  • [ X ] Changes are tested and verified to work as expected.

Related Issues

If applicable, link the issues resolved by this pull request:


Additional Notes

  • Parameters are yielded one at a time instead of loading all into memory
  • Iteration can be stopped early without processing remaining parameters
  • Related functions mentioned in issue continue to work
  • May be beneficial for large models with many project parameters

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.

image

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! 🎉

rayala30 added 2 commits July 26, 2025 23:52
…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
Copy link
Copy Markdown
Contributor

@devloai devloai bot left a comment

Choose a reason for hiding this comment

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

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

@jmcouffin jmcouffin requested a review from Copilot July 29, 2025 10:00
Copy link
Copy Markdown
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 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

@jmcouffin jmcouffin merged commit 3d46dde into pyrevitlabs:develop Jul 30, 2025
@jmcouffin
Copy link
Copy Markdown
Contributor

Thanks for your contribution @rayala30
and the test and the thorough explaination!

@jmcouffin jmcouffin added the Enhancement Enhancement request [class->Improved #{number}: {title}] label Jul 30, 2025
@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25211+1247-wip

@sanzoghenzo
Copy link
Copy Markdown
Contributor

Thanks @rayala30

I'm late to the party (didn't receive a notification for this PR), but it would have been nice to have the tests written as unittest TestCases like it is done here...

But this is just nipticking, thanks again for the contribution!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 1, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25213+1402-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1027-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1429-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+0909-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1354-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1400-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1405-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1421-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 8, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25220+1008-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25225+0806-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25225+1628-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25230+1701-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0824-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0848-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0859-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+1126-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+1352-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 2, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25245+0639-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 2, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25245+0642-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 2, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25245+1846-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 3, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25246+0855-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25248+0948-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 8, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0758-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 8, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0805-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 8, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0824-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 9, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25252+1659-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0644-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0911-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25256+0727-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25258+1448-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25265+1047-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25266+0803-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25268+1757-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1336-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1431-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1436-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1822-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25271+1719-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2003-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2012-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2017-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2149-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 1, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25274+1734-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1425-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1427-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 6, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25279+2157-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25302+0949-wip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Enhancement request [class->Improved #{number}: {title}]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add a iter_project_parameters to make the related functions more efficient

4 participants