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

Add function to unregister a previously registered hook. #12100

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

rtibbles
Copy link
Member

Summary

  • Adds a function to unregister a previously registered hook

References

This was vendored into KDP in https://github.com/learningequality/kolibri-data-portal/pull/682

Reviewer guidance

Use it to unregister an otherwise previously registered hook.
Check that it is no longer a registered hook on its parent hook.


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: small labels Apr 22, 2024
Copy link
Member

@bjester bjester 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 to me, but before official approval, a question:

Are there any tests for the existing code? Just thinking it would be good to maintain same level of coverage on this module if there are

and issubclass(parent, KolibriHook)
and parent is not KolibriHook
and hasattr(parent, "_registered_hooks")
):
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker: some of this logic seems like it's getting a bit repetitive. There are subtle differences, but bulk of it seems like it could be consolidated. Every time I look at this area of the codebase, it takes me a while to carefully understand all of the conditions. Some consolidation can tuck that a way into a well commented chunk of code, so each usage can focus on its goal and what's different

and base.abstract
and issubclass(base, KolibriHook)
for base in subclass.__bases__
):
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here regarding consolidation. Seems this validation logic is pretty much the same as register_hook

Copy link
Member

@jredrejo jredrejo 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 for me, code is the same applied in https://github.com/learningequality/kolibri-data-portal/pull/682/ and it's already demostrating its utility in KDP in production.

As @bjester mentioned, tests would be a good to have, as usual, but I'm not going to be the one complaining for lack of testing. I'll love the day AI can create real and useful tests for us.

@rtibbles
Copy link
Member Author

As I (re)-discovered when looking at this, there are no existing tests for this part of the code base - at least part of that is on me, as I didn't write any when I refactored this about 4 or 5 years ago. I am also happy to hold off merging to add some, I'll think on it.

@bjester
Copy link
Member

bjester commented Apr 24, 2024

If there is no existing test coverage, then no worries, we can merge and add tests later.

@rtibbles rtibbles merged commit 0684fb2 into learningequality:release-v0.16.x Apr 24, 2024
34 checks passed
@rtibbles rtibbles deleted the unregister_hook branch April 24, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... SIZE: small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants