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 child class for single callable #46

Closed
wants to merge 2 commits into from

Conversation

garrettmflynn
Copy link
Collaborator

Changed in alignment with NeurodataWithoutBorders/nwb-guide#676 (comment).

Publishing initially in Draft Mode for further review and discussion about our approach.

@garrettmflynn garrettmflynn self-assigned this Mar 18, 2024
Comment on lines +4 to +14
class TQDMProgressSubscriber(TQDMPublisher):
def __init__(self, iterable, *, announcer: "?", request_id: str, message: dict, **tqdm_kwargs):
super().__init__(iterable, **tqdm_kwargs)

def on_progress_update(format_dict) -> None:
"""
Describe what this announcer is all about...
"""
announcer.announce(dict(request_id=request_id, **message))

self.subscribe(callback=on_progress_update)
Copy link
Member

Choose a reason for hiding this comment

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

Oops, I meant to splinter this to a different PR/branch, my bad

What would you think about this structure?

Copy link
Member

Choose a reason for hiding this comment

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

Main question is, what is the announcer class (is it something from Flask?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the announcer is from the GUIDE server—so that has to be used within a user-provided callable to the TQDMProgressSubscriber.

Unless you want to bring assumptions about the server-side event system implemented in the GUIDE (in contrast to the WebSockets used in our demos) to tqdm_publisher.

  1. MessageAnnouncer class declaration: https://github.com/NeurodataWithoutBorders/nwb-guide/blob/main/pyflask/sse.py
  2. Flask SSE handler: https://github.com/NeurodataWithoutBorders/nwb-guide/blob/4ab4e1f682d9bd9e1b4b3d79f9c0e2e593bddea9/pyflask/manageNeuroconv/manage_neuroconv.py#L688

Copy link
Member

Choose a reason for hiding this comment

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

A fair amount of that listener logic seems quite general, so could very well be included along with this child class

What is the specific point at which it interacts with the GUIDE client?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At the two locations defined above. The SSE handler waits for new messages to be generated by calling MessageAnnouncer.announce in other endpoints.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Response in NeurodataWithoutBorders/nwb-guide#695 and #49.

These introduce a tqdm_publisher global import, though, since the listen_to_neuroconv_events endpoint needs to have a reference to a single MessageAnnouncer instance used across progress updates when the user requests that they'd like to receive updates from that endpoint.

If we can't tolerate that, then this line of inquiry is infeasible since whatever queue we use has to be available in several endpoints and the simplest way to use this queue (i.e. with the least assumptions, most flexibility) would be in a callback as the initial commit for this PR was already doing.

@CodyCBakerPhD CodyCBakerPhD changed the base branch from main to restore_branch March 18, 2024 19:29
@CodyCBakerPhD
Copy link
Member

@garrettmflynn Can this be closed now I assume?

@CodyCBakerPhD CodyCBakerPhD deleted the add_single_callable_subscriber branch April 6, 2024 22:14
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