Skip to content

Conversation

yusufjimoh
Copy link
Contributor

@yusufjimoh yusufjimoh commented Oct 17, 2024

Description of work

  • extracted business logic from the pairing table view to the presenter.
  • cleaned up some code in the view and presenter.
  • updated unit tests to reflect changes in the view and presenter

Fixes #38105

To test:

  • testing instructions are included in the associated issue
  • code should pass unit tests

This does not require release notes because it involves code restructuring, no new functionality has been added

@yusufjimoh yusufjimoh linked an issue Oct 17, 2024 that may be closed by this pull request
@yusufjimoh yusufjimoh added ISIS: Spectroscopy Issue and pull requests relating to Muons, Indirect and Inelastic at ISIS Muon Issues and pull requests related to muons Maintenance Unassigned issues to be addressed in the next maintenance period. labels Oct 17, 2024
@yusufjimoh yusufjimoh added this to the Release 6.12 milestone Oct 17, 2024
@yusufjimoh yusufjimoh marked this pull request as ready for review October 18, 2024 08:48
@adriazalvarez adriazalvarez self-assigned this Oct 18, 2024
- Updated Failing Tests
- Created Getters for Properties in PairingTableView so the properties are accesed through the getters in the PairingTablePresenter
Copy link
Contributor

@adriazalvarez adriazalvarez left a comment

Choose a reason for hiding this comment

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

Thanks for the effort on moving the logic out of the view class. I know this view is not easy to refactor ! Generally the view seems more neat and decluttered, although I have found some moved functions that maybe belong in the view, and we could subscribe the presenter to the view to avoid connecting signals/slots on the presenter and use notifiers instead to call the relevant functions on the presenter.

Also, when testing I have found this error when i click on Load current run :

image

@yusufjimoh yusufjimoh force-pushed the 38105-logic-in-the-pairingtableview branch from dfab969 to 9974af2 Compare October 24, 2024 11:16
Copy link
Contributor

@adriazalvarez adriazalvarez left a comment

Choose a reason for hiding this comment

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

Except for a typo that is creating a runtime error, I have followed the manual testing instructions without any functional issue on the pair table widget. Thanks for the good work on this refactoring.
I have added some additional comments on small things that I've noticed during review.

…nd Presenter

- created a getter for model._context so the property can be accessed using the getter
- remove pairing table constants
@yusufjimoh
Copy link
Contributor Author

Code has been updated to fix an issue on the pairing table pointed out by @adriazalvarez, Thanks.

Copy link
Contributor

@adriazalvarez adriazalvarez left a comment

Choose a reason for hiding this comment

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

Thanks for the latest changes Yusuf.
I have been testing the pairing table again, everything works as expected.

adriazalvarez
adriazalvarez previously approved these changes Nov 5, 2024
Copy link
Contributor

@adriazalvarez adriazalvarez left a comment

Choose a reason for hiding this comment

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

I forgot to approve before!

@cailafinn cailafinn self-assigned this Nov 6, 2024
Copy link
Contributor

@cailafinn cailafinn left a comment

Choose a reason for hiding this comment

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

Just noticed a couple more improvements that could be made while we're editing these files.

Copy link
Contributor

@cailafinn cailafinn left a comment

Choose a reason for hiding this comment

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

Apologies for the late review, I didn't see the notification that the changes had been made.

This implementation of the context manager won't work, unfortunately. Where the with blocks are isn't where the updates need to be stopped. Instead, they should be used in places like add_pair_to_view

    def add_pair_to_view(self, pair, to_analyse=False, color=row_colors[RowValid.valid_for_all_runs], tool_tip=row_tooltips[RowValid.valid_for_all_runs]):
        with self.disable_updates_context():
            self.update_group_selections()
            assert isinstance(pair, MuonPair)
            entry = [str(pair.name), to_analyse, str(pair.forward_group), str(pair.backward_group), str(pair.alpha)]
            self.add_entry_to_table(entry, color, tool_tip)

Which would disable the updates to the view during the time the execution is inside the with block. update_view_from_model would be the other place you'd want to use the context manager. Let me know if you have any questions.

renamed enable updates method to disable updates method and vice versa
@yusufjimoh yusufjimoh requested a review from cailafinn December 10, 2024 10:33
Copy link
Contributor

@cailafinn cailafinn left a comment

Choose a reason for hiding this comment

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

Double-checked functionality and seems to be working well, nice work.

@cailafinn cailafinn merged commit 6a0b022 into main Dec 17, 2024
10 checks passed
@cailafinn cailafinn deleted the 38105-logic-in-the-pairingtableview branch December 17, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS: Spectroscopy Issue and pull requests relating to Muons, Indirect and Inelastic at ISIS Maintenance Unassigned issues to be addressed in the next maintenance period. Muon Issues and pull requests related to muons
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

Logic in the PairingTableView
3 participants