Repository navigation
Handle missing or stale IERS-A better - #13052
Conversation
|
👋 Thank you for your draft pull request! Do you know that you can use |
cb6c4c8 to
d041b0e
Compare
|
I think this is a sensible idea and would hopefully cause minimal pain for people who just want things to work and don't care about extreme precision. We can also have the exceptions point people to a docs page or note that explains how to disable the auto-download, and explains the risk and implications of doing this. I also think that this is sufficiently urgent that we should try to get something in to address this before the next release. I don't have a strong opinion on whether this should be a new configuration keyword or whether we should overload |
|
Broad brush I think this is a good idea, but I'm a bit worried about the questionable accuracy of " if the user explicitly opts out of getting the latest IERS data, then they understand what they are doing" 😉... That is, I think this is the sort of thing someone wouldn't necessarily recognize as having the stated effect because it seems like it's about downloading instead of time/coordinates accuracy. So something like either a different name than overloading Will try to give a more thorough review ASAP - I agree with @adrn this is a high priority to try to get into next release |
|
(and to clarify, I think this in particularly addresses the concern @bjweiner brought up in #12998 (comment), to tie things together a bit more ) |
d041b0e to
492b69b
Compare
|
@adrn @eteq @mhvk - I updated this PR to add a new config parameter I'm not sure the tests are written in the best way, I honestly have forgotten the details of making sure that there is no IERS data cached somewhere. |
|
One failing test right now is a doctest that is complaining because it is trying to access network resources without What I don't understand is why this was ever working. If I turn off the network on my laptop and run the doctest example, I get warnings saying that the code is trying to access the IERS site to get The only thing I can think is that in my unit test I clear the download cache and maybe it was there before? But that doesn't make sense, I thought the tests are running in a clean (no cache files) environment. Would it be OK to just add the Astropy 5.0Thoughts @pllim? |
|
Adding a new configuration item changed the example output at Lines 212 to 222 in 8211458 The failure of that test means that the cleanup code is not executed, which causes more failures: Lines 512 to 517 in 8211458 Updating the aforementioned example should be enough to ensure the doctests pass, there should be no need for any new +REMORE_DATA flags.
|
|
Awesome @eerovaher thanks! I'll revert the changes I just made. |
28b739f to
572f0b0
Compare
| 10.0, | ||
| 'Remote timeout downloading IERS file data (seconds).') | ||
| iers_degraded_accuracy = _config.ConfigItem( | ||
| ['error', 'warn', 'ignore'], |
There was a problem hiding this comment.
The io.votable.verify configuration item accepts analogous values, but instead of 'error' it uses 'exception':
astropy/astropy/io/votable/__init__.py
Lines 27 to 31 in 8f1e017
For the sake of consistency it would be better if
'exception' is used here too.
There was a problem hiding this comment.
Well there is metadata_conflicts with 'error', 'warn', and 'silent', and parse_strict with 'raise', 'warn', and 'silent'. I don't think there is any one answer that will get us to being "consistent". I came to 'error' and 'ignore' in part being consistent with Python warnings filter terminology.
Anyway, I don't feel too strongly since there is no right answer. @eerovaher - let me know if you still would like a change.
There was a problem hiding this comment.
It would be better to be consistent, but if the values used here are the same as the ones from Python warnings filtering then it looks like we should rather change the other values to match what is used here.
There was a problem hiding this comment.
OK, I'm just going to leave this.
|
It looks like the diff code coverage is not running with |
572f0b0 to
6e8b6a0
Compare
eerovaher
left a comment
There was a problem hiding this comment.
The code changes look good to me, but I have a couple of suggestions regarding the change log and what's new entries.
|
Thanks @taldcroft - I'll take a look over lunch today. (BTW: @eerovaher is a coordinates maintainer as well, so I also trust his eyes here!) |
| try: | ||
| filename = download_file(url, cache=True) | ||
| except Exception as err: | ||
| warn(f'failed to download {url}: {err}', IERSWarning) |
There was a problem hiding this comment.
| warn(f'failed to download {url}: {err}', IERSWarning) | |
| warn(f'failed to download {url}: {repr(err)}', IERSWarning) |
There was a problem hiding this comment.
@pllim - are you sure about wanting repr() here? I don't think that is common for exception messages since it turns newlines into the \n character and can otherwise make the output messy.
There was a problem hiding this comment.
Oh, I thought repr(err) was recommended in one of the PyCon talks a few years back. If you prefer not to use it, that is fine too.
There was a problem hiding this comment.
If you have a reference I'd be interested to look but for now let's leave it.
There was a problem hiding this comment.
I don't feel like watching the talk right now but I remember ejeschke/ginga#767 that points to https://www.youtube.com/watch?v=V2fGAv2R5j8 , FWIW.
There was a problem hiding this comment.
I watched it and this is an interesting question:
In [3]: try:
...: raise ValueError('blah\nblah\nblah\n')
...: except Exception as exc:
...: print(f'failed to download: {repr(exc)}')
...:
failed to download: ValueError('blah\nblah\nblah\n')
In [4]: try:
...: raise ValueError('blah\nblah\nblah\n')
...: except Exception as exc:
...: print(f'failed to download: {exc}')
...:
failed to download: blah
blah
blah
I'm not sure about this, but I am definitely sure that I am tired of this PR.. 😄
There was a problem hiding this comment.
I'd actually add !r for the repr (i.e., {exc!r}) - it is useful to know what the type of the exception was!
pllim
left a comment
There was a problem hiding this comment.
Do these pages need updating too?
- https://docs.astropy.org/en/latest/utils/iers.html
- https://docs.astropy.org/en/latest/utils/data.html
p.s. Sorry for the comment spam. I should have commented as part of a review but when I started, I didn't think I would have this many comments and then halfway through I thought it would be confusing to only have half the comments attached to the review... 😅
|
Hello @taldcroft 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style. There are no PEP8 style issues with this pull request - thanks! 🎉 Comment last updated at 2022-04-21 21:58:52 UTC |
Co-authored-by: P. L. Lim <[email protected]> Co-authored-by: Eero Vaher <[email protected]>
|
@pllim - yup, those narrative docs page need some attention too. Sigh, it's always the docs and testing that take so long! |
mhvk
left a comment
There was a problem hiding this comment.
This looks like an excellent solution! One question/one nitpick.
| try: | ||
| filename = download_file(all_urls[0], sources=all_urls, cache=True) | ||
| except Exception as err: | ||
| for url in all_urls: |
There was a problem hiding this comment.
Why the loop? I thought the idea of sources in dowload_url is exactly to give different possible sources, but still count them as "the same file" for download purposes. Or is this to guard against a mirror providing a bad file? If it is not essential to the PR, I'd recommend not changing it here.
There was a problem hiding this comment.
Probably needs an upstream fix but that was out of scope. If the first provided URL is not a valid URL then download_file raises an exception, even if one of the backup URL's can download successfully.
download_file('junk', sources=['junk', 'https://google.com'])
There was a problem hiding this comment.
That's bad and would seem a real bug in download_file. But maybe best not to try to work around it here?
There was a problem hiding this comment.
Actually the other reason (maybe more important) is that part of the point here is to not only ensure that some HTML page content got downloaded (which is all that download_file cares about), but that it is correct. That was one of the original problems with a site returning some text that was not the expected IERS table content and crashing later.
In short, we really do need a loop that tries each URL in turn, both downloading and validating the content.
There was a problem hiding this comment.
OK, let's keep this as is then!
There was a problem hiding this comment.
If you want to pursue the download_file bug, we need to ping @aarchiba on the original intent of that implementation. FYI.
adrn
left a comment
There was a problem hiding this comment.
Thanks @taldcroft for this idea and PR! I had some other minor nitpicks/suggestions but overall think this is great and should get in to the next release.
| desired or possible. Examples include an application where full accuracy is not | ||
| required, running on a cluster, or the rare instances when the IERS server and | ||
| mirror are not available. For these cases there is a new config item | ||
| `iers.conf.iers_degraded_accuracy <astropy.utils.iers.Conf.iers_degraded_accuracy>` which specifies the behavior when times are |
There was a problem hiding this comment.
| `iers.conf.iers_degraded_accuracy <astropy.utils.iers.Conf.iers_degraded_accuracy>` which specifies the behavior when times are | |
| `iers.conf.iers_degraded_accuracy <astropy.utils.iers.Conf.iers_degraded_accuracy>`__ that specifies the behavior when times are |
85d2bf0 to
e5c9d06
Compare
This comment was marked as resolved.
This comment was marked as resolved.
e5c9d06 to
405ef42
Compare
405ef42 to
b32e6aa
Compare
|
CI is passing now! |
Description
This pull request is to partially address #9227 and #12998. I'm not sure this is a perfect solution but it is an idea. In particular:
conf.iers_degraded_accuracywhich specifies the behavior when times are outside the range of IERS table, possible resulting in degraded time accuracy when converting scales.'error'(default)'warn'(issue aIERSDegradedAccuracyWarning)'ignore'(ignore the problem)Independent of the above discussion, this PR changes the logic for auto-downloads to guarantee that no matter what happens with the IERS download operations, only warnings will be issued.
Fixes #12998
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CIlabel.no-changelog-entry-neededlabel. If this is a manual backport, use theskip-changelog-checkslabel unless special changelog handling is necessary.astropy-botcheck might be missing; do not let the green checkmark fool you.backport-X.Y.xlabel(s) before merge.cc: @mhvk @bjweiner