Skip to content

Commit

Permalink
feat: add and to the verbose output of .
Browse files Browse the repository at this point in the history
This implied joining the  table to the result of the registry search.
  • Loading branch information
ManonMarchand committed Oct 2, 2023
1 parent 7d63b20 commit 93d264d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
1.5 (unreleased)
================

- Added the ``source_value`` and ``alt_identifier`` information to the verbose
output of ``describe()`` in ``regtap``. [#492]

- Added convenience method DALResults.to_qtable() that returns an
astropy.table.QTable object. [#384]

Expand Down
23 changes: 19 additions & 4 deletions pyvo/registry/regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ class RegistryResource(dalq.Record):
(f"\n ivo_string_agg(COALESCE(intf_type, ''), '{TOKEN_SEP}')",
"intf_types"),
(f"\n ivo_string_agg(COALESCE(intf_role, ''), '{TOKEN_SEP}')",
"intf_roles"), ]
"intf_roles"),
"alt_identifier"]

def __init__(self, results, index, session=None):
dalq.Record.__init__(self, results, index, session)
Expand Down Expand Up @@ -534,6 +535,14 @@ def reference_url(self):
"""
return self.get("reference_url", decode=True)

@property
def alt_identifier(self):
"""Alternative identifier.
It is often used to provide the resource associated DOI.
"""
return self.get("alt_identifier", decode=True)

@property
def creators(self):
"""
Expand Down Expand Up @@ -789,8 +798,10 @@ def describe(self, verbose=False, width=78, file=None):
----------
verbose : bool
If false (default), only user-oriented information is
printed; if true, additional information will be printed
as well.
printed.
If true, additional information -- reference url,
reference to the related article, and alternative identifier
(often a DOI) -- will be printed if available.
width : int
Format the description with given character-width.
out : writable file-like object
Expand All @@ -806,7 +817,7 @@ def describe(self, verbose=False, width=78, file=None):
if len(self._mapping["access_urls"]) == 1:
print("Base URL: " + self.access_url, file=file)
else:
print("Multi-capabilty service -- use get_service()", file=file)
print("Multi-capability service -- use get_service()", file=file)

if self.res_description:
print(file=file)
Expand All @@ -826,6 +837,10 @@ def describe(self, verbose=False, width=78, file=None):
if verbose:
if self.reference_url:
print("More info: " + self.reference_url, file=file)
if self.alt_identifier:
print(f"Alternative identifier: {self.alt_identifier}", file=file)
if self.source_value:
print(f"Source: {self.source_value}", file=file)

def get_contact(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion pyvo/registry/rtcons.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,8 @@ def build_regtap_query(constraints):
serialized.append("(" + constraint.get_search_condition() + ")")
extra_tables |= set(constraint._extra_tables)

joined_tables = ["rr.resource", "rr.capability", "rr.interface"
joined_tables = ["rr.resource", "rr.capability", "rr.interface",
"rr.alt_identifier"
] + list(extra_tables)

# see comment in regtap.RegistryResource for the following
Expand Down
2 changes: 1 addition & 1 deletion pyvo/registry/tests/test_regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def test_describe_multi(self, flash_service):
" ssa, tap#aux, web" in output)
assert "Multi-capability service" in output
assert "Source: 1996A&A...312..539S" in output
assert "Reference url: http://dc.zah" in output
assert "More info: http://dc.zah" in output
assert "Alternative identifier: doi:10.21938/" in output

def test_no_access_url(self):
Expand Down
6 changes: 4 additions & 2 deletions pyvo/registry/tests/test_rtcons.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ def test_expected_columns(self):
"\n ivo_string_agg(COALESCE(access_url, ''), ':::py VO sep:::') AS access_urls, "
"\n ivo_string_agg(COALESCE(standard_id, ''), ':::py VO sep:::') AS standard_ids, "
"\n ivo_string_agg(COALESCE(intf_type, ''), ':::py VO sep:::') AS intf_types, "
"\n ivo_string_agg(COALESCE(intf_role, ''), ':::py VO sep:::') AS intf_roles")
"\n ivo_string_agg(COALESCE(intf_role, ''), ':::py VO sep:::') AS intf_roles, "
"alt_identifier")

def test_group_by_columns(self):
# Again, this will break as regtap.RegistryResource.expected_columns
Expand All @@ -390,4 +391,5 @@ def test_group_by_columns(self):
"source_format, "
"source_value, "
"region_of_regard, "
"waveband")
"waveband, "
"alt_identifier")

0 comments on commit 93d264d

Please sign in to comment.