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

user API for metadata viewer plugin #1634

Merged
merged 4 commits into from
Sep 15, 2022

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Sep 9, 2022

Description

This pull request extends on #1401 and provides user-API access to the metdata viewer plugin.

Plugin User API docs

TODO:

  • add PR to changelog if before next release, otherwise add new entry (waiting until PR is accepted otherwise to avoid constant merge conflicts)

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 change log needed? If yes, is it added to CHANGES.rst?
  • Is a milestone set?
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added this to the 2.11 milestone Sep 9, 2022
@codecov
Copy link

codecov bot commented Sep 9, 2022

Codecov Report

Base: 86.33% // Head: 86.34% // Increases project coverage by +0.00% 🎉

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1634   +/-   ##
=======================================
  Coverage   86.33%   86.34%           
=======================================
  Files          95       95           
  Lines        9618     9622    +4     
=======================================
+ Hits         8304     8308    +4     
  Misses       1314     1314           
Impacted Files Coverage Δ
...default/plugins/metadata_viewer/metadata_viewer.py 94.73% <100.00%> (+0.23%) ⬆️

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 marked this pull request as ready for review September 9, 2022 16:49
@@ -2,13 +2,28 @@

from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import PluginTemplateMixin, DatasetSelectMixin
from jdaviz.core.user_api import PluginUserApi
from jdaviz.utils import PRIHDR_KEY, COMMENTCARD_KEY

__all__ = ['MetadataViewer']


@tray_registry('g-metadata-viewer', label="Metadata Viewer")
Copy link
Member Author

Choose a reason for hiding this comment

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

should we consider changing the label to just "Metadata"?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about just "Metadata" but I agree "Metadata Viewer" is worse. Maybe "Metadata Plugin"?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you remove "Viewer," they might get the wrong idea that they can edit the metadata with this plugin. In IRAF, you could use a task to edit FITS header, so...

Copy link
Member Author

Choose a reason for hiding this comment

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

if I switch exposing the metadata traitlet to the read-only infrastructure added in #1643, then maybe that and some docs updates would avoid that confusion? Is there any chance we'll ever extend this to allow editing metadata (either from the UI or API)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see editing metadata as a common use case and worth supporting. Implementing it on the other hand would be a...difficult task.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not open that can of worms here. Can you imagine if someone accidentally overwrites a keyword that is important for WCS transformation?

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 did change it so that plugin.metadata is read-only from the user API (otherwise they could change the traitlet and the plugin would update to show that, but it would not persist when changing the data dropdown, etc).

Copy link
Member Author

Choose a reason for hiding this comment

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

With the readonly plugin.metadata is anyone opposed to removing "Viewer"? I just think viz.plugins['Metadata'] and having "Metadata" in the plugin tray menu feels simpler and more natural, as long as we can sufficiently avoid user-confusion through the API and docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that is a good compromise. Thanks!

@pllim
Copy link
Contributor

pllim commented Sep 9, 2022

More fundamentally, does this really need any public API? This basically exposes what is already in data.meta.

@kecnry
Copy link
Member Author

kecnry commented Sep 12, 2022

does this really need any public API? This basically exposes what is already in data.meta.

Perhaps not, but the intent is to provide consistent access to all the plugins and in a way that mirrors the UI functionality so that users can more easily transition from the UI to scripting in the notebook.

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.

Worked well for me! We can take renaming "Metadata Viewer" out of this PR if you prefer.


* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* ``dataset`` (:class:`~jdaviz.core.template_mixin.DatasetSelect`):
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. Should we change this to "data_label" to be consistent with another plugin?

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 don't think so. In this case, it is a selectable dropdown, as opposed to a read-only indication of the top-layer. If anything, I'd be in favor of changing other instances of data_label to dataset and have it just show as a single choice. That then gives us flexibility to change it to a proper dropdown in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, let's leave it then.

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.

Works well. Just some questions on the naming above since these will be public from here on out, if we decide to keep the names, this PR is good to go.

@kecnry kecnry force-pushed the api-metadata-viewer branch from 6b5b5f3 to 393fe6c Compare September 15, 2022 13:13
@kecnry kecnry merged commit d351f25 into spacetelescope:main Sep 15, 2022
@kecnry kecnry deleted the api-metadata-viewer branch September 15, 2022 13:26
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