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

Implement hub callback priorities #2530

Merged
merged 9 commits into from
Feb 5, 2025

Conversation

rosteen
Copy link
Contributor

@rosteen rosteen commented Jan 28, 2025

This PR allows users to set a priority for the hub callback when subscribing to a hub message, e.g.:

self.hub.subscribe(self, SubsetCreateMessage,
                           handler=lambda _: self._on_subset_created(),
                           priority=100)

I implemented this with a default priority of 10, where lower integer values are higher priority. I confirmed that this PR (and the code snippet above in Jdaviz) fixes the bug with the Layer not being populated before our data menu processes the SubsetCreateMessage.

@astrofrog @dhomeier There are two failing tests, I haven't figured out yet why those are now failing, so if you have thoughts on that or the implementation in general let me know.

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Looks promising! Just a couple of comments and then if you could look into the tests that'd be great, but if you don't have time, just let me know and I'll see if I can investigate.

@dhomeier
Copy link
Collaborator

dhomeier commented Jan 28, 2025

I only see the one failed test on Mock called twice; tried with @astrofrog's suggestion and removing the
priorities.append(priority), but there are still two calls (apparently with the correct message though).

@rosteen
Copy link
Contributor Author

rosteen commented Jan 29, 2025

I only see the one failed test on Mock called twice; tried with @astrofrog's suggestion and removing the priorities.append(priority), but there are still two calls (apparently with the correct message though).

Oh good, I was seeing two locally, the second must have been due to something else in my local setup.

@rosteen
Copy link
Contributor Author

rosteen commented Jan 29, 2025

Looks promising! Just a couple of comments and then if you could look into the tests that'd be great, but if you don't have time, just let me know and I'll see if I can investigate.

I fixed the failing test, the second loop to yield the handlers shouldn't have been inside the loop to populate the prioritized_handlers

@astrofrog
Copy link
Member

Ideally it would be good to add at least one test for this - is that something you think you would be able to look into @rosteen or should @dhomeier or I look into it?

@rosteen
Copy link
Contributor Author

rosteen commented Jan 30, 2025

Ideally it would be good to add at least one test for this - is that something you think you would be able to look into @rosteen or should @dhomeier or I look into it?

If @dhomeier has time today that would be awesome, otherwise I can try to figure something out tomorrow.

Copy link
Collaborator

@dhomeier dhomeier left a comment

Choose a reason for hiding this comment

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

Just some corrections to docstrings, otherwise looks good now, thanks!

@dhomeier dhomeier merged commit 92c9bff into glue-viz:main Feb 5, 2025
27 checks passed
@dhomeier
Copy link
Collaborator

dhomeier commented Feb 5, 2025

Excellent, thanks!

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

Successfully merging this pull request may close these issues.

3 participants