Skip to content

Implement ability to hide warnings in VO table parsing#8715

Merged
pllim merged 25 commits intoastropy:masterfrom
astrofrog:votable-pedantic
May 23, 2019
Merged

Implement ability to hide warnings in VO table parsing#8715
pllim merged 25 commits intoastropy:masterfrom
astrofrog:votable-pedantic

Conversation

@astrofrog
Copy link
Member

@astrofrog astrofrog commented May 16, 2019

This PR makes it possible to hide warnings when parsing VO tables, by replacing the boolean pedantic flag with a verify flag that can be ignore, warn, or exception (or should it be error?)

In addition, as discussed in #8028, this makes ignore the default. I think in general we should move to a model where we don't give 25 warnings when reading in a table where these are fixed anyway and beyond the user's control (basically the Robustness Principle of being liberal in what you accept)

I've tagged various people I think might be interested. If we go ahead with this I think in another PR we should also change the default for FITS to not show fixable warnings on input.

EDIT: Fix #8028

@astrofrog astrofrog added this to the v4.0 milestone May 16, 2019
@astrofrog astrofrog force-pushed the votable-pedantic branch 2 times, most recently from b5d26a7 to 3a3eb49 Compare May 16, 2019 10:33
@astrofrog astrofrog marked this pull request as ready for review May 16, 2019 19:02
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Overall I think is the right approach. My comments below are minor ones.

Also I would think that adding a 'fix' option for the same kwarg would be very nice, that would also nicely mirror the behaviour/options of the fits .verify()

@pllim
Copy link
Member

pllim commented May 17, 2019

or should it be error?

Naw, it is also exception on io.fits (http://docs.astropy.org/en/stable/io/fits/usage/verification.html), so in the spirit of consistency, we can use that.

@codecov
Copy link

codecov bot commented May 17, 2019

Codecov Report

Merging #8715 into master will increase coverage by 0.01%.
The diff coverage is 94.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8715      +/-   ##
==========================================
+ Coverage   86.95%   86.97%   +0.01%     
==========================================
  Files         399      399              
  Lines       59355    59373      +18     
  Branches     1100     1100              
==========================================
+ Hits        51613    51637      +24     
+ Misses       7101     7095       -6     
  Partials      641      641
Impacted Files Coverage Δ
astropy/io/votable/validator/result.py 13.94% <0%> (ø) ⬆️
astropy/io/votable/converters.py 93.85% <100%> (ø) ⬆️
astropy/io/votable/exceptions.py 93.6% <100%> (+0.34%) ⬆️
astropy/io/votable/tree.py 85.98% <100%> (+0.28%) ⬆️
astropy/io/votable/__init__.py 100% <100%> (ø) ⬆️
astropy/io/votable/connect.py 77.41% <100%> (ø) ⬆️
astropy/io/votable/table.py 86.46% <94.11%> (+0.63%) ⬆️
astropy/config/configuration.py 83.78% <0%> (+0.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2b0717...94826f0. Read the comment docs.

@astrofrog
Copy link
Member Author

@bsipocz:

Also I would think that adding a 'fix' option for the same kwarg would be very nice, that would also nicely mirror the behaviour/options of the fits .verify()

This would require a lot more work since at the moment there is no control over whether things are fixed or not. They are always fixed, and it could be that the VO table can't be interpreted if not fixed (a little different to FITS headers which can be sub-optimal but still work). I'd be tempted to keep just these three options for now, and then consider adding more in future if people really want?

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

My preliminary review from eyeballing the code. When this is more stable, I would like to take it for a spin before merge. Thanks! I think this will be one of the more popular PRs for 4.0... 😹

'When True, treat fixable violations of the VOTable spec as exceptions.',
aliases=['astropy.io.votable.table.pedantic'])
verify = _config.ConfigItem(
'ignore',
Copy link
Member

Choose a reason for hiding this comment

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

Now that I look at this, I am actually not sure if alias would work if the config type has changed. When cfgtype is not provided, as in the case here, it is inferred from the default value. So with this change, its type is now string, where it used to be boolean. That is going to choke the validator when someone has an older astropy.cfg with, say, pedantic = True set. A possible solution is to explicitly state the cfgtype as 'option' and provide all the 5 possible options (3 new ones and 2 boolean values).

References:

Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason it still doesn't work right if I specify option with mixed types, and it always gets converted to a string. But that's ok, we can still be backward compatible by just checking for False and True as strings when using conf.verify. I've added handling of this as well as an extensive test of setting the configuration items (both verify and pedantic).

@bsipocz
Copy link
Member

bsipocz commented May 17, 2019

@astrofrog

Also I would think that adding a 'fix' option for the same kwarg would be very nice, that would also nicely mirror the behaviour/options of the fits .verify()

out of band discussion showed me why this is not a good idea, so please ignore it, it shouldn't actually fix anything.

@astrofrog
Copy link
Member Author

astrofrog commented May 17, 2019

@bsipocz @pllim - I've implemented all your comments. Feel free to take this for a spin!

@astrofrog astrofrog force-pushed the votable-pedantic branch 3 times, most recently from c197aa5 to 997307c Compare May 17, 2019 13:55
Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Thanks for the extensive tests! This is getting close.

@bsipocz bsipocz dismissed their stale review May 17, 2019 17:30

review has been addressed

@astrofrog
Copy link
Member Author

@pllim - I had to change some of the code in parse back to being able to handle booleans, because we need to catch the case where the user calls the function with pedantic=True for instance. Otherwise I think I've accepted/implemented all your suggestions!

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Sorry, I keep finding stuff to comment on... 😬

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

I think 🐴 is 💀 . Thanks for your patience with my reviews!

@pllim pllim added the zzz 💤 merge-when-ci-passes Do not use: We have auto-merge option now. label May 22, 2019
@pllim
Copy link
Member

pllim commented May 22, 2019

p.s. I am excited to see how many warnings disappear in #7928 once this is merged and I rebase that one on top of this one!

@astrofrog
Copy link
Member Author

(rebased to get rid of the docs build error)

@pllim pllim merged commit 2d99bed into astropy:master May 23, 2019
@pllim
Copy link
Member

pllim commented May 23, 2019

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

io.votable zzz 💤 merge-when-ci-passes Do not use: We have auto-merge option now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Silence warnings by default when reading in VO Tables

4 participants