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

Factor checks out of ACAReviewTable class #203

Merged
merged 3 commits into from
Jan 5, 2024
Merged

Conversation

taldcroft
Copy link
Member

@taldcroft taldcroft commented Dec 31, 2023

Description

This is to factor out the sparkles checks from being ACAReviewTable methods to independent check functions that return a list of messages. The motivation is to decouple these catalog checks from sparkles and make it easier to run them from starcheck or elsewhere.

Key updates:

  • Move checks from being methods of the ACAReviewTable class into functions in a new checks.py module.
    • The functions take arbitrary arguments and return list[Message].
    • In the existing sparkles checks the first argument is always an ACACheckTable or subclass, but that is no longer a requirement.
    • Future checks should be written with more specific arguments where that would make sense.
  • New Message dataclass and move MessagesList into new messages.py module.
  • Factor out a new ACACheckTable class that provides the minimal functionality to perform checks. This separates out all the sparkles review functionality (making reports, roll angle optimization, etc) from the basic catalog checking functionality:
    • messages attribute to capture messages
    • Additional columns like row and col etc to facilitate checking the catalog
    • Some helper attributes.
  • Update check tests to use both ACAReviewTable and ACACheckTable.

The refactoring part is going to be difficult for code review but the tests are solid.

Requires

Interface impacts

Testing

Unit tests

  • Mac
(masters) ➜  sparkles git:(refactor-checks) git rev-parse HEAD
ee2f79e6e50c4f97c25163dbf9f132c591594db8
(masters) ➜  sparkles git:(refactor-checks) pytest            
===================================================== test session starts ======================================================
platform darwin -- Python 3.10.8, pytest-7.2.1, pluggy-1.0.0
rootdir: /Users/aldcroft/git, configfile: pytest.ini
plugins: timeout-2.1.0, anyio-3.6.2
collected 103 items                                                                                                            

sparkles/tests/test_checks.py ............................................................................               [ 73%]
sparkles/tests/test_find_er_catalog.py .....                                                                             [ 78%]
sparkles/tests/test_review.py ..................                                                                         [ 96%]
sparkles/tests/test_yoshi.py ....                                                                                        [100%]

===================================================== 103 passed in 34.39s =====================================================

Independent check of unit tests by Jean

  • Linux

Functional tests

No functional testing.

@taldcroft taldcroft changed the title WIP: Factor checks out of ACAReviewTable class Factor checks out of ACAReviewTable class Jan 2, 2024
@taldcroft taldcroft requested review from jeanconn and removed request for jeanconn January 2, 2024 19:49
@taldcroft taldcroft requested a review from jeanconn January 2, 2024 21:32
check_too_bright_guide = checks.acar_check_wrapper(checks.check_too_bright_guide)


def check_catalog(acar: ACACheckTable) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

It would make a little more sense to me to have check_catalog in checks, with an interface so that I could get the messages without writing back into the ACAReviewTable if desired. But I'm not passionate about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea was that if some other application wants to use the checks from checks.py, then that app has its own version of check_catalog that calls some or all of the checks.py checks. So the check_catalog() function in sparkles.core is specifically only for sparkles, but the checks in the checks module are somewhat public and modular.

Of course another application would be free to copy the current check_catalog with essentially no modification except the last few lines.

@taldcroft taldcroft merged commit 8cc0145 into master Jan 5, 2024
2 checks passed
@taldcroft taldcroft deleted the refactor-checks branch January 5, 2024 09:56
@javierggt javierggt mentioned this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants