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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ New Features
in Jy [#1564]

- User-friendly API access to plugins, with exposed functionality for: line analysis, gaussian
smooth, moment maps, compass, and collapse. [#1401, #1642, #1643, #1636, #1641]
smooth, moment maps, compass, collapse, and metadata. [#1401, #1642, #1643, #1636, #1641, #1634]

Cubeviz
^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@

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")
@tray_registry('g-metadata-viewer', label="Metadata")
class MetadataViewer(PluginTemplateMixin, DatasetSelectMixin):
"""
See the :ref:`Metadata Viewer Plugin Documentation <imviz_metadata-viewer>` for more details.

Only the following attributes and methods are available through the
:ref:`public plugin API <plugin-apis>`:

* :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.

Dataset to expose the metadata.
* :attr:`show_primary`:
Whether to show MEF primary header metadata instead.
* :attr:`metadata`:
Read-only metadata. If the data is loaded from a multi-extension FITS file,
this can be the extension header or the primary header, depending on
``show_primary`` setting.

"""
template_file = __file__, "metadata_viewer.vue"
has_metadata = Bool(False).tag(sync=True)
has_primary = Bool(False).tag(sync=True)
Expand All @@ -21,6 +40,10 @@ def __init__(self, *args, **kwargs):
# override the default filters on dataset entries to require metadata in entries
self.dataset.add_filter('not_from_plugin')

@property
def user_api(self):
return PluginUserApi(self, expose=('dataset', 'show_primary'), readonly=('metadata',))

def reset(self):
self.has_metadata = False
self.has_primary = False
Expand Down