Skip to content
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

Fix test_with_attrfile bug and re-enable test #194

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

e10harvey
Copy link
Collaborator

@e10harvey e10harvey commented Dec 12, 2024

Purpose

Fixes #3

Summary of changes

Broke subclass parser search in get_parser out into separate function that returns a list of all subclass parsers found

Implementation notes

An unordered set the type of the global variable _registered_parser_classes. What causes the bug is the unordered nature of processing this set. Each implementation of the abstract AttributeParser registers itself when opencsp fires up. When SpotAnalysisAttributeParser is encoutered first during AttributeManager/get_parser, the unordered structure of _registered_parser_classes can result in the fall-through path to search and returning a subclass parser. This in-turn results in some members of the parser, date_collected in this instance, not getting initialized. Removing the fall back path of searching for subclass parsers in get_parser fixes this spurious failure.

Submission checklist

  • Target branch is develop, not main
  • Existing tests are updated or new tests were added
  • opencsp/test/test_DocStringsExist.py are verified to include this change or have been updated accordingly
  • .rst file(s) under doc/ are verified to include this change or have been updated accordingly

Additional information

It's not clear to me what the original intended functionality of get_parser was. Reviewers should check the doc strings and any potential breakage via removal of subclass parser searching.

@e10harvey e10harvey changed the base branch from main to develop December 12, 2024 16:54
@@ -62,6 +62,33 @@ def parsers(self):
def _register_parser_class(cls, parser_class: type[aap.AbstractAttributeParser]):
_registered_parser_classes.add(parser_class)

def get_subclass_parser_classes(self, parser_class: type[aap.AbstractAttributeParser]):
Copy link
Collaborator Author

@e10harvey e10harvey Dec 12, 2024

Choose a reason for hiding this comment

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

This method is not used nor required for our test suite to pass, remove it or add a unit test for it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

braden6521
braden6521 previously approved these changes Dec 13, 2024
Copy link
Collaborator

@braden6521 braden6521 left a comment

Choose a reason for hiding this comment

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

Looks good @e10harvey. I'm not too familiar with AttributeManager.py, so I'm not really sure of the implications of removing get_subclass_parser_classes. But I'm a fan of removing things that aren't used/tested; so that's my vote.

@e10harvey e10harvey added the bug Something isn't working label Jan 8, 2025
@e10harvey e10harvey merged commit ade2669 into sandialabs:develop Jan 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spurious failure in test_with_attrfile
2 participants