Skip to content

Mango next - #698

Merged
bsipocz merged 39 commits into
astropy:mainfrom
lmichel:mango-next
Nov 10, 2025
Merged

Mango next#698
bsipocz merged 39 commits into
astropy:mainfrom
lmichel:mango-next

Conversation

@lmichel

@lmichel lmichel commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

This MR only relates to the annotation readout.

Code cleaning:

  • Unused module XmlViewer + dependencies has been removed
  • Glossary has been cleaned up

MivotViewer:

  • Able to process TEMPLATES with multiple INSTANCES. This is necessary for those who want to use MANGO in sparse mode (see the spec)
  • Give access to global INSTANCEs as MivotInstances

This PR improves the current API. It will be extended with model specific modules once MANGO will be a REC. At that time new MANGO-specific features will be completed.

@codecov

codecov Bot commented Sep 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.16393% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.03%. Comparing base (e892b23) to head (76a9ce9).
⚠️ Report is 81 commits behind head on main.

Files with missing lines Patch % Lines
pyvo/mivot/features/sky_coord_builder.py 86.56% 9 Missing ⚠️
pyvo/mivot/viewer/mivot_viewer.py 95.45% 2 Missing ⚠️
pyvo/mivot/viewer/mivot_instance.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #698      +/-   ##
==========================================
- Coverage   84.09%   84.03%   -0.07%     
==========================================
  Files          80       79       -1     
  Lines        8556     8529      -27     
==========================================
- Hits         7195     7167      -28     
- Misses       1361     1362       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bsipocz bsipocz added this to the v1.8 milestone Sep 25, 2025
@lmichel
lmichel marked this pull request as ready for review October 8, 2025 08:51

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some minor nitpicking comments

Comment thread pyvo/mivot/tests/data/reference/TRASH.templates_models.json Outdated
sparse: boolean, optional (default to False)
If True, all properties are added in a independent way to the the TEMPLATES.
They are packed in a MangoObject otherwise.
schema_check: boolean, optional (default to True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to run a docs format checker (to be done separately from this PR), this is just a reminder mostly to myself to do it (these white spaces affect the actual API docs rendering)

Suggested change
schema_check: boolean, optional (default to True)
schema_check : boolean, optional (default to True)

@lmichel lmichel Oct 9, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, but I found out tens of occurrences of this pattern (/[a-z]: /) in many files. I prefer to have your green light before to increase the number of modified files. Could this be done in a specific PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, let's not mix those changes into this PR but do it separately, and I'll also try to remember to pick a tool that does that linting for us.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll open a dedicated PR once this one will be merged.



@prototype_feature('MIVOT')
class XMLViewer:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was a prototype, so I suppose changing the API without any prior notice is fine and thus this can be removed without deprecation. But this class was mentioned in the narrative docs, so it's just something to be aware of.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

made it more explicit in the change log

Comment thread pyvo/mivot/viewer/mivot_viewer.py Outdated
Comment on lines +306 to +309
raise MivotError(
"Can't find " + Ele.INSTANCE
+ " in " + Ele.TEMPLATES
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

absolute nitpicking, but I feel this could all fit in one line; we're quite liberal with line lengths and allow them to be up to 110 characters

Comment thread pyvo/mivot/viewer/mivot_viewer.py

@tomdonaldson tomdonaldson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks very much for this @lmichel! It's very exciting to see this working so cleanly with real services. Other than the minor comments I left, I'm very comfortable merging this to make it available for people to try out.

I left a number of minor comments, mostly coming from minor issues I encountered while working through viewer.rst and example.rst. Please have a look and address the ones that make sense to you. If any of the comments make sense but are difficult to resolve, then they can be left for later, because it will be good to have this functionality merged.

Comment thread pyvo/mivot/features/sky_coord_builder.py Outdated
Comment thread pyvo/mivot/glossary.py Outdated
Comment thread docs/mivot/viewer.rst Outdated
Comment thread docs/mivot/viewer.rst Outdated
Comment thread docs/mivot/viewer.rst Outdated
Comment thread docs/mivot/viewer.rst
Comment thread docs/mivot/viewer.rst Outdated
Comment thread docs/mivot/example.rst Outdated
Comment thread docs/mivot/example.rst Outdated
Comment thread docs/mivot/example.rst

@tomdonaldson tomdonaldson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the updates @lmichel. This looks great to me. I'll let @bsipocz take a last look before merging.

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see some of Tom's comments haven't got addressed (they are kind of hidden under a "hidden conversation" button. I assume you haven't seen them and they got just accidentally left out. I'm happy to work them in, as I plan to rebase before merge anyway due to a duplicated commit in the history.
Let me know if my read of the situation is correct, so I'll go ahead with the minor fixes and merge this.

Comment thread docs/mivot/viewer.rst Outdated
Comment on lines +266 to +278
print(mivot_instance.__dict__.keys())
dict_keys(['dmtype', 'longitude', 'latitude', 'pmLongitude', 'pmLatitude', 'epoch', 'Coordinate_coordSys'])
# dict_keys(['dmtype', 'longitude', 'latitude', 'pmLongitude', 'pmLatitude', 'epoch', 'Coordinate_coordSys'])

print(mivot_instance.Coordinate_coordSys.__dict__.keys())
dict_keys(['dmtype', 'dmid', 'dmrole', 'spaceRefFrame'])
# dict_keys(['dmtype', 'dmid', 'dmrole', 'spaceRefFrame'])

print(mivot_instance.Coordinate_coordSys.spaceRefFrame.__dict__.keys())
dict_keys(['dmtype', 'value', 'unit', 'ref'])
# dict_keys(['dmtype', 'value', 'unit', 'ref'])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are these commented out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tom suggested this to allows users to cut/paste working code snippet

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we add these as code examples for doctest, then the copybutton sphinx extension (>>> arrows on the top right corner of the box) takes care of ripping out the print results.
Try this one: https://pyvo.readthedocs.io/en/latest/mivot/viewer.html

So, overall I would rather suggest to have these formatted with the >>>s included

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I replaced all .. code-block with .. doctest-skip::

@tomdonaldson

Copy link
Copy Markdown
Contributor

I ran through the doc code again and am quite happy with it. I did just push one minor fix where dm_global_instances was being accessed as a function (with parentheses) instead of as a property.

Comment thread docs/mivot/viewer.rst Outdated
Comment thread docs/mivot/viewer.rst Outdated
for globals_instance in m_viewer.dm_globals_instances:
print(globals_instance)

.. code-block:: json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why json and not Python dictionary? json should be a serialization method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The json flag was here to tell Sphinx how to highlight the syntax.
I replaced all code-block with .. doctest-skip:: as suggested bu @bsipocz anyway

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, it's not about docs it's about the format that print(globals_instance) produces. I expected to be something more concise so that the user would be able to do log.debug("Process globals_instance: " + globals_instance) or similar and have it show up in a single row.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see.
I put a single line string representation (<MivotInstance: dmtype="mango:EpochPosition">) for MivotInsance.
The whole representation (dictionary) is now only used by repr()

Comment thread docs/mivot/viewer.rst Outdated
Python object generated from the MIVOT block as either a Pyhon object or a dict
'''
self._mivot_instance_dict = mivot_instance_dict
if isinstance(mivot_instance, dict):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again, no point for 2 alternative types for model representation. End users are interested in actual MANGO or other astronomy related objects (SkyCoords) not the model representation. Just my opinion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is mostly driven by the will of simplifying unit tests

@lmichel lmichel Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This feature has been removed

Comment thread docs/mivot/example.rst
>>>
>>> # Print out the json serialization of the Python object
>>> print(mango_property)
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My suggestion is to not expose the model representation to the user. I don't recall but it must be a way to either specifically request MANGO model classes or to discover the ones that are available. The "discovery" mechanism can be either an explicit "get all the types" or simply trying, e.g. check wether getSkyCoord(row) which looks for the dm_instance.dm_type=mango:EpochPosition and returns the corresponding sky coordinates or null otherwise. But the mangoProperty is just a serialization representation.

self._mivot_instance_dict = mango_property
return self._build_sky_coord_from_mango()
raise NoMatchingDMTypeError(
"No INSTANCE with dmtype='mango:EpochPosition' has been found:"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or simply return None. I'm not sure which one is better as a discovery mechanism.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

honestly, I've no preference. I can change this if you wish.
Using exception:

  • PRO: Give a clear view on the reason of the failure
  • CON: Break the current execution thread

<VODML xmlns="http://www.ivoa.net/xml/mivot">
<REPORT status="OK"/>
<MODEL name="ivoa" url="https://www.ivoa.net/xml/VODML/IVOA-v1.vo-dml.xml"/>
<MODEL name="coords" url="https://ivoa.net/xml/VODML/Coords-v1.vo-dml.xml"/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

scb = SkyCoordBuilder(mivot_instance)
scoo = scb.build_sky_coord()

assert (str(scoo).replace("\n", "").replace(" ", "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is fragile subject to astropy changing their representation format. It should check the values instead.

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some more minor comments, they are not blockers or really actionable here, but we may nevertheless sort them out in a follow-up -- e.g. about the skipped tests.

Also, there is a failure on the devtest job, I'll have a look at that before merging this (aiming by this evening (CET time) and cutting a release (aiming tomorrow evening or on Wednesday the latest)).

(and will rebase to clean up the duplicated commits -- again, no action items for you there).

Comment thread docs/mivot/viewer.rst Outdated

.. doctest-skip::

>>> import pytest

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we should have any pytest machinery for skipping in the narrative docs examples, it could be said at the top that one needs a x.y astropy to run these examples (and as they are skipped anyway it won't be an issue for out actual testing (or also we can use doctest requires at the top of the files.)

Comment thread docs/mivot/example.rst
Comment thread docs/mivot/example.rst
>>> from pyvo.dal.scs import SCSService
>>> from pyvo.utils import activate_features
>>> from pyvo.mivot.viewer.mivot_viewer import MivotViewer
>>> from pyvo.mivot.features.sky_coord_builder import SkyCoordBuilder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not an issue at all, but I would think that in narrative documentation there is a benefit of doing the imports at piecemeal -- only in the cells where they are (first) used, where the classes/functions are being first described as opposed to doing everything at the top.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agree, to be fixed later

Comment thread docs/mivot/example.rst
@bsipocz
bsipocz merged commit 9ecff0c into astropy:main Nov 10, 2025
14 checks passed
@bsipocz

bsipocz commented Nov 10, 2025

Copy link
Copy Markdown
Member

Thank you @lmichel!

@lmichel

lmichel commented Nov 10, 2025

Copy link
Copy Markdown
Contributor Author

A big thank you to the reviewer team

@McSinyx McSinyx mentioned this pull request Feb 2, 2026
@lmichel
lmichel deleted the mango-next branch April 17, 2026 16:14
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.

4 participants