phurwicz / hover

:speedboat: Label data at scale. Fun and precision included.
https://phurwicz.github.io/hover
MIT License
321 stars 19 forks source link

bulk labeling selection should automatically update "view selection" #42

Closed FarisHijazi closed 2 years ago

FarisHijazi commented 2 years ago

Hi, I'm running the quickstart0 code.

Current behavior: after every selection (using lasso tool or poly tool) I have to press the button "View selected" so I can update the table Desired (new) behavior: I would like this button to not exist and it should automatically update every time the selection is updated (be it lasso or poly tool)

I'll be happy to dig in the code, if you direct me to a general direction of where to look, I'm not sure how easy it is to write a hook for the bokeh plot

phurwicz commented 2 years ago

Hi, I have an idea how to do this and will try to implement it next week. Writing it down so that you can dig too. Please do consider making it optional to auto-refresh. Probably a toggle-able checkbox will be nice.


Let's look at "hook A", which calls self._store_selection() ("callback A") whenever a new selection is made: https://github.com/phurwicz/hover/blob/602ba8a244266894ef821025dc0e618170b380b0/hover/core/explorer/base.py#L408-L411

Also "callback B", which refreshes the table when you click "View Selected" ("hook B"): https://github.com/phurwicz/hover/blob/602ba8a244266894ef821025dc0e618170b380b0/hover/core/dataset.py#L452-L460

https://github.com/phurwicz/hover/blob/602ba8a244266894ef821025dc0e618170b380b0/hover/core/dataset.py#L488

Basically you are looking for "hook A to trigger callback B". This is feasible.

Caveat 1: as you can tell from the file names, hook A and callback B are with different classes of objects. The way these two classes (SupervisableDataset and BokehBaseExplorer, to be specific) interact should probably go to this method https://github.com/phurwicz/hover/blob/602ba8a244266894ef821025dc0e618170b380b0/hover/core/dataset.py#L438 with something like this:

explorer.figure.on_event(SelectionGeometry, callback_view) 

Caveat 2: "hook A" is already tied to a few callbacks, and any new callback needs to interact with them correctly. You might have noticed filters and how they can trigger automatically after making a selection. We want the table to update after all the filters, or any callbacks with "hook A" that alter the selection. So it takes a bit of finesse to place the explorer.figure.on_event(...) line at the right place in the "queue of callbacks".

FarisHijazi commented 2 years ago

I'll see if I have time after work to get on it

haochuanwei commented 2 years ago

It turned out a bit more complicated than I first thought. Every mechanism that changes the selection (which is more than “hook A”) needs to trigger “callback B”. Took me a while to get the ordering figured out, will write tests and push to a nightly branch. Main branch would need to wait for more tests — would you mind installing from nightly before that?

Best regards, Haochuan


From: Faris Hijazi @.> Sent: Thursday, July 28, 2022 3:38:07 PM To: phurwicz/hover @.> Cc: Subscribed @.***> Subject: Re: [phurwicz/hover] bulk labeling selection should automatically update "view selection" (Issue #42)

I'll see if I have time after work to get on it

— Reply to this email directly, view it on GitHubhttps://github.com/phurwicz/hover/issues/42#issuecomment-1197778654, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEZTDWR4RKDY4RHHJ7XMFZDVWI2F7ANCNFSM54PN4G2Q. You are receiving this because you are subscribed to this thread.Message ID: @.***>

FarisHijazi commented 2 years ago

Yes I don't mind installing the nightly branches, just let me know when it's out

On Thu, 28 Jul 2022, 10:45 am Harry Wei, @.***> wrote:

It turned out a bit more complicated than I first thought. Every mechanism that changes the selection (which is more than “hook A”) needs to trigger “callback B”. Took me a while to get the ordering figured out, will write tests and push to a nightly branch. Main branch would need to wait for more tests — would you mind installing from nightly before that?

Best regards, Haochuan


From: Faris Hijazi @.> Sent: Thursday, July 28, 2022 3:38:07 PM To: phurwicz/hover @.> Cc: Subscribed @.***> Subject: Re: [phurwicz/hover] bulk labeling selection should automatically update "view selection" (Issue #42)

I'll see if I have time after work to get on it

— Reply to this email directly, view it on GitHub< https://github.com/phurwicz/hover/issues/42#issuecomment-1197778654>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/AEZTDWR4RKDY4RHHJ7XMFZDVWI2F7ANCNFSM54PN4G2Q

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/phurwicz/hover/issues/42#issuecomment-1197786441, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALIUSZBLAXAMXLZNPJJTZTDVWI3DJANCNFSM54PN4G2Q . You are receiving this because you authored the thread.Message ID: @.***>

phurwicz commented 2 years ago

Hi @FarisHijazi , c3db709d1a42faf1120d3fd8dcfb1e12bc96fd77 has the latest update (pip install git+https://github.com/phurwicz/hover.git@nightly). Below the "View Selected" you will see a toggle like this:

Screen Shot 2022-07-28 at 5 44 44 AM

Turn it on and you will have auto-refresh. Note that any edits you made in the selection table without hitting "Update Row Values" will be lost.

We've tested it in the annotation interface. Will add some automated tests later on. Hope it helps!

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 years ago

This issue was closed because it has been inactive for 14 days since being marked as stale.