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

Ignore XML namespaces in xsi:type #323

Merged
merged 5 commits into from
Jun 1, 2022
Merged

Ignore XML namespaces in xsi:type #323

merged 5 commits into from
Jun 1, 2022

Conversation

msdemlei
Copy link
Contributor

@msdemlei msdemlei commented May 6, 2022

This PR addresses bug #257 in the lamest possible way: It just ignores namespace prefixes on xsi:type-s.

Rationale: It turns out that astropy.utils.xml completely discards all namespace information. That you can parse Registry/capability documents with it in the first place is just because we only have local elements with elementFormDefault=unqualified. Ah well.

Given that, we can either do XML processing ourselves, properly managing namespaces. Or we ignore namespaces and namespace prefixes, too. Since I can't think of anywhere that would be trouble in the current VO, this commit opts for the second option.

I suppose I'd scupper astropy.utils.xml for registry documents and have our own XML parser (which isn't a big deal in this context) unless I'd expect that astropy.utils.xml will deal with namespaces in some way in the near future, as namespaces in VOTable will probably become relevant when VO-DML annotation enters VOTables. If that happens, we ought to revise ignoring namespaces here. If not... well, we can always employ our own namespace-aware XML parser later.

Since this is a rather ugly hack, a few words of background:

It turns out that astropy.utils.xml completely discards all namespace
information.  That you can parse Registry/capability documents with it
in the first place is just because we only have local elements with
elementFormDefault=unqualified.  Ah well.

Given that, we can either do XML processing ourselves, properly managing
namespaces (which wouldn't be a terrible amount of work).  Or we ignore
namespaces and namespace prefixes, too.  Since I can't think of anywhere
that would be trouble in the current VO, this commit opts for the second
option.
@codecov
Copy link

codecov bot commented May 6, 2022

Codecov Report

Merging #323 (772212a) into main (6a4409a) will decrease coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #323      +/-   ##
==========================================
- Coverage   75.53%   75.46%   -0.07%     
==========================================
  Files          44       44              
  Lines        5137     5123      -14     
==========================================
- Hits         3880     3866      -14     
  Misses       1257     1257              
Impacted Files Coverage Δ
pyvo/io/vosi/exceptions.py 100.00% <100.00%> (ø)
pyvo/io/vosi/vodataservice.py 87.02% <100.00%> (-0.40%) ⬇️
pyvo/io/vosi/voresource.py 79.31% <100.00%> (-3.35%) ⬇️
pyvo/utils/xml/elements.py 93.77% <100.00%> (+0.84%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@msdemlei
Copy link
Contributor Author

msdemlei commented May 9, 2022

I've looked at where the coverage machinery thinks we're losing coverage, and if I read its output right, it's a few setters and a raise that the machinery thinks we're losing. For all these, I've set a breakpoint in the correponding code of the current main branch, and it didn't fire when ran a pytest; I've also not found which test might make the machinery think it's covered in current main (but I've not looked hard).

So... until someone convinces me otherwise, I claim the loss of test coverage is not real.

Copy link
Contributor

@andamian andamian left a comment

Choose a reason for hiding this comment

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

Not an XML expert, but otherwise it looks good to me. Do not worry about the coverage when the difference is so tiny.

@msdemlei
Copy link
Contributor Author

So, umm... who'll merge this? Do we have a policy?

@andamian
Copy link
Contributor

So, umm... who'll merge this? Do we have a policy?

I can do that. We don't have a policy and I usually prefer a second pair of eyes. But if you say that this is ready, I will merge it.

@bsipocz
Copy link
Member

bsipocz commented May 16, 2022

Rationale: It turns out that astropy.utils.xml completely discards all namespace information. That you can parse Registry/capability documents with it in the first place is just because we only have local elements with elementFormDefault=unqualified. Ah well.

Maybe this should be eventually upstreamed, too? (Of course that is totally independent of this PR, as even if upstreamed there should be a pyvo solution until versions are being caught up)

@msdemlei
Copy link
Contributor Author

msdemlei commented May 17, 2022 via email

@msdemlei
Copy link
Contributor Author

msdemlei commented May 17, 2022 via email

@andamian
Copy link
Contributor

You see, I'd still like to see PR #289 merged, sooner rather than later: It is quite a mouthful, and I'd appreciate if it got a chance to two to show problems before it ends up in a release. And I'm not sure what I'd need to do to make that happen.

One could argue that the RegTAP 1.1 constraints ought to be annotated as per #309 -- do we? If so, can I do something to get #309 merged?

Is #289 ready?

For #309 you could help with a review. I did review it and have no major concerns but it will be nice if someone else could do it too.

@bsipocz
Copy link
Member

bsipocz commented May 18, 2022

For #309 you could help with a review. I did review it and have no major concerns but it will be nice if someone else could do it too.

If there are no other takers I'll try to give it a go through later this week, I need to get used to type hinted code anyway (not sure we need it here at all, but that's not my call).

@msdemlei
Copy link
Contributor Author

msdemlei commented May 18, 2022 via email

@msdemlei
Copy link
Contributor Author

Ummm... can I bump this? It'd be great if it could be merged before it grows conflicts...

@tomdonaldson tomdonaldson added this to the v1.4 milestone Jun 1, 2022
@tomdonaldson tomdonaldson merged commit 5830167 into main Jun 1, 2022
@bsipocz bsipocz deleted the improve-vosi-ns branch September 7, 2022 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants