From fbfd1c685271dbd855cdf145ba943b37f64e8a65 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 7 Sep 2022 08:47:17 -0400 Subject: [PATCH 1/4] user API for metadata viewer plugin --- .../metadata_viewer/metadata_viewer.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py b/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py index f5c21d6785..122a3cfe3b 100644 --- a/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py +++ b/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py @@ -2,6 +2,7 @@ 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'] @@ -9,6 +10,20 @@ @tray_registry('g-metadata-viewer', label="Metadata Viewer") class MetadataViewer(PluginTemplateMixin, DatasetSelectMixin): + """ + See the :ref:`Metadata Viewer Plugin Documentation ` for more details. + + Only the following attributes and methods are available through the + :ref:`public plugin API `: + + * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show` + * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray` + * ``dataset`` (:class:`~jdaviz.core.template_mixin.DatasetSelect`): + Dataset to expose the metadata. + * :attr:`show_primary`: + Whether to show MEF primary header metadata instead. + * :attr:`metadata` + """ template_file = __file__, "metadata_viewer.vue" has_metadata = Bool(False).tag(sync=True) has_primary = Bool(False).tag(sync=True) @@ -21,6 +36,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 From f2ad2b4b73b72a8207ae1c8b9593b9713b4491a3 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 15 Sep 2022 09:11:55 -0400 Subject: [PATCH 2/4] rename user-label from "Metadata Viewer" to "Metadata" --- .../configs/default/plugins/metadata_viewer/metadata_viewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py b/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py index 122a3cfe3b..06c2c243a1 100644 --- a/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py +++ b/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py @@ -8,7 +8,7 @@ __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 ` for more details. From 393fe6ca99e30e5b2e98f6e4bc5ddda77deefc3b Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 15 Sep 2022 09:12:49 -0400 Subject: [PATCH 3/4] update changelog entry --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 4fd8b96187..ad8c812541 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 ^^^^^^^ From b4bcbdd7ca8eb10d846f28df3c6ea96bdd9f8148 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 15 Sep 2022 09:13:34 -0400 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> --- .../default/plugins/metadata_viewer/metadata_viewer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py b/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py index 06c2c243a1..602f2b982c 100644 --- a/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py +++ b/jdaviz/configs/default/plugins/metadata_viewer/metadata_viewer.py @@ -22,7 +22,11 @@ class MetadataViewer(PluginTemplateMixin, DatasetSelectMixin): Dataset to expose the metadata. * :attr:`show_primary`: Whether to show MEF primary header metadata instead. - * :attr:`metadata` + * :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)