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

Markers stay when adding new data #1838

Merged
merged 9 commits into from
Nov 14, 2022

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Nov 11, 2022

Description

This pull request makes waaaay more small changes than I'd like so that markers can stay in place when adding new data to Imviz. The expected behavior when changing linking type is not clear so is deferred until a refactor - for now a new confirmation overlay is added to the links control plugin to clear markers. When interacting from the API, markers will need to be cleared manually first (as stated in the error message if failing to do so). This also fixes a bug where the markers data_collection entry was not showing as loaded in the data menu.

Note: using the plugin API to change the link type will still result in the overlay (and no error). Calling the astrowidgets API will raise an error (if applicable) and suggest calling viewer.remove_markers(). We could consider other API alternatives for the plugin if this is a concern.

Out of scope but possible follow-up efforts:

  • layer icon for marker entry
  • plot options support for markers

image

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added the imviz label Nov 11, 2022
@kecnry kecnry added this to the 3.2 milestone Nov 11, 2022
@kecnry kecnry force-pushed the markers-stay-when-add-data branch 2 times, most recently from 7606068 to 4affeec Compare November 11, 2022 20:44
Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

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

When linking is touched, it always make me nervous. Did you notice any performance degradation when you add a lot of markers on a large image that is linked to another image, and then toggle this and that? Maybe that Imviz example notebook is already a good enough case to test this against?

@kecnry
Copy link
Member Author

kecnry commented Nov 14, 2022

When linking is touched, it always make me nervous. Did you notice any performance degradation when you add a lot of markers on a large image that is linked to another image, and then toggle this and that? Maybe that Imviz example notebook is already a good enough case to test this against?

If anything this should improve performance as additional images are loaded (outside of batch loading) as the links are appended instead of rebuilt from scratch. But please do check the changes I made to linking logic carefully once this is ready for review and let me know if you find any performance issues.

@codecov
Copy link

codecov bot commented Nov 14, 2022

Codecov Report

Base: 88.23% // Head: 88.27% // Increases project coverage by +0.04% 🎉

Coverage data is based on head (f80d0be) compared to base (f0796f2).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1838      +/-   ##
==========================================
+ Coverage   88.23%   88.27%   +0.04%     
==========================================
  Files          95       95              
  Lines       10343    10382      +39     
==========================================
+ Hits         9126     9165      +39     
  Misses       1217     1217              
Impacted Files Coverage Δ
jdaviz/configs/imviz/helper.py 96.17% <100.00%> (-0.20%) ⬇️
...nfigs/imviz/plugins/links_control/links_control.py 100.00% <100.00%> (ø)
jdaviz/core/astrowidgets_api.py 98.76% <100.00%> (+0.02%) ⬆️
jdaviz/core/events.py 94.23% <100.00%> (+0.20%) ⬆️
...imviz/plugins/aper_phot_simple/aper_phot_simple.py 92.11% <0.00%> (+0.28%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kecnry kecnry force-pushed the markers-stay-when-add-data branch from a4bc43e to c15f041 Compare November 14, 2022 15:03
@kecnry kecnry marked this pull request as ready for review November 14, 2022 15:30
@kecnry kecnry force-pushed the markers-stay-when-add-data branch from 0d236f4 to bc43ee5 Compare November 14, 2022 17:53
@@ -304,3 +305,14 @@ class ExitBatchLoadMessage(Message):
'''Message generated when exiting the outermost batch_load context manager'''
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


class MarkersChangedMessage(Message):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this less confusing? Because when someone call remove_markers and the last set of markers are removed (i.e., no more left after that), technically markers still changed but you expect a False to be attached to the message.

Suggested change
class MarkersChangedMessage(Message):
class MarkersExistMessage(Message):

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, I guess that depends on whether you expect the class to be named after the contents of the message or the circumstances that trigger it (I think of it as the latter, in which case Exist would be confusing to me). Luckily this is all internal (not public API), so we can always consider extending the messages capabilities or renaming down the road (we might either want it to fire if the data in the markers change or we may want a separate message for that, for example).

Copy link
Contributor

@javerbukh javerbukh left a comment

Choose a reason for hiding this comment

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

Works well and code looks code! I would agree that performance seems to improve in this PR, although that could also be the work of previous sprints. Not sure if I have an opinion on the thing @pllim brought up so I will go ahead and approve now. Nice work!

@pllim
Copy link
Contributor

pllim commented Nov 14, 2022

I also like the functionality but I would like to know if we should also document this in https://jdaviz.readthedocs.io/en/latest/imviz/plugins.html#link-control before I approve. Thanks!

@kecnry
Copy link
Member Author

kecnry commented Nov 14, 2022

but I would like to know if we should also document

What would you propose to put there? To me it feels like a tangent to the narrative there and is quite self-explanatory when seeing the overlay in the plugin. Alternatively, we could add something to the add_markers API docs stating that markers would need to be reset and manually re-added if changing linking? Or perhaps something in the links control plugin API docs?

* if link settings don't change, just add the necessary new links rather than rebuilding all.  This should be faster AND allows keeping markers
* raise an error in linking if changing the linking type with markers present.  Eventually we may want to refactor to include logic for how the relinking is handled (if only x,y are provided, are those preserved or are the markers attached to the reference or top-layer data?)
* markers being added/removed through the API send a message which the plugin consumes, so now the overlay requesting clearing can show before attempting to change the linking type (and can therefore raise an error when changing from the API)
@kecnry kecnry force-pushed the markers-stay-when-add-data branch from bc43ee5 to 9c02ba1 Compare November 14, 2022 18:48
@pllim
Copy link
Contributor

pllim commented Nov 14, 2022

Yeah, maybe the links control API doc?

@kecnry
Copy link
Member Author

kecnry commented Nov 14, 2022

Ok, I added a brief note in add_markers and a more verbose note in the plugin API docs. I think from the UI perspective, the UI explains the situation on its own sufficiently. Let me know what you think (🤞 that docs build - but I'll keep an eye and fix any syntax/crossref errors if they come up)!

@kecnry kecnry force-pushed the markers-stay-when-add-data branch from 92c3e58 to c3fa4ef Compare November 14, 2022 19:10
@pllim
Copy link
Contributor

pllim commented Nov 14, 2022

@kecnry kecnry force-pushed the markers-stay-when-add-data branch from c3fa4ef to f80d0be Compare November 14, 2022 20:09
@kecnry
Copy link
Member Author

kecnry commented Nov 14, 2022

Updated that warning to a note stating that markers will need to be removed manually if changing linking type. Thanks for the reminder about that one!

Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

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

LGTM. I think this is a great UX improvement until we can figure out how to deal with markers in a better way. Thanks!

@kecnry kecnry merged commit b391423 into spacetelescope:main Nov 14, 2022
@kecnry kecnry deleted the markers-stay-when-add-data branch November 14, 2022 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants