Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix IERS_Auto logic now that IERS-A is bundled - #16187

Merged
mhvk merged 4 commits into
astropy:mainfrom
ayshih:iers_a
Jul 9, 2024
Merged

mhvk merged 4 commits into
astropy:mainfrom
ayshih:iers_a

Conversation

@ayshih

@ayshih ayshih commented Mar 12, 2024

Copy link
Copy Markdown
Contributor

Description

#14819 moved the IERS files to a separate package (astropy-iers-data), and now IERS-A is essentially bundled with astropy. However, there persist some remnants of the old logic, where IERS-A is available only if the download were triggered. This results in the peculiar behavior that if automatic downloading of IERS-A files is disabled (iers.conf.auto_download = False) or fails, the bundled IERS-A file is ignored even though it is present (see #13227 (comment)).

This PR fixes the logic so that the bundled IERS-A file is used if iers.conf.auto_download = False, with corresponding fixes in documentation and tests.

This PR does not attempt to fix the logic so that a previously downloaded IERS-A file is used if iers.conf.auto_download is subsequently set to False. I didn't want to wrap my head around whether the downloaded file should have priority over the bundled file, given that astropy-iers-data could also be upgraded.

Fixes #13227: With astropy 6.0, the response to the report would be to upgrade astropy-iers-data to obtain a recent IERS-A table. This PR then fixes the residual bug where setting iers.conf.auto_download = False would ignore that bundled IERS-A table.

Fixes #16128: Because the bundled IERS-A is now no longer ignored by the default IERS_Auto when downloading is blocked, it's now typically impossible to trigger the "degraded accuracy" error/warning unless the user expressly forces the use of the IERS-B data alone (e.g., through the earth_orientation_table ScienceState).

Other related issues:

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@ayshih
ayshih force-pushed the iers_a branch 2 times, most recently from 7c17771 to 7ea06a4 Compare March 12, 2024 03:23
@ayshih
ayshih marked this pull request as ready for review March 12, 2024 04:31
@neutrinoceros

Copy link
Copy Markdown
Contributor

Just a heads-up that this patch seems to touch some of the same lines than #16070, so merge conflicts might ensue. That said, my own PR is currently stuck so I don't have a problem with this one going in first, mind you. I'm also happy to serve as a reviewer if needed !

@ayshih

ayshih commented Mar 12, 2024

Copy link
Copy Markdown
Contributor Author

I think #16070 will be sufficiently orthogonal – improving how IERS-A and IERS-B are combined versus merely ensuring that the combination even happens – that any merge conflicts should be trivial to resolve.

@pllim pllim added this to the v6.1.0 milestone Mar 12, 2024
@pllim pllim added Bug API change PRs and issues that change an existing API, possibly requiring a deprecation period labels Mar 12, 2024

@pllim pllim 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.

Thanks! Does the content of https://docs.astropy.org/en/stable/utils/data.html also need updating?

@pllim
pllim requested review from astrofrog, mhvk and taldcroft March 12, 2024 15:25
@ayshih

ayshih commented Mar 12, 2024

Copy link
Copy Markdown
Contributor Author

Ah, indeed, that page should be edited too

@mhvk mhvk 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 so much! I have one question on the implementation, whether it might not be even simpler to just preserve whatever has been downloaded (which in itself would seem more logical). What do you think? I am happy to go with what you have as well, as it resolves the biggest issues.

Beyond that, only a nitpick on the changelog entry...

Comment thread docs/changes/utils/16187.api.rst Outdated
@@ -0,0 +1 @@
The return type of ``IERS_Auto.open()`` is no longer ``IERS_B`` when automatic updating of the IERS-A file is disabled or the downloading of the new file fails.

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.

I think we should add what it is now! Maybe

IERS_Auto.open() now defaults to the combination of IERS_A and B data bundled
in the astropy-iers-data dependency rather than to IERS_B only when automatic ...

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.

Overhauled text

@@ -786,7 +790,7 @@ def open(cls):

"""
if not conf.auto_download:

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.

I guess the alternative path, which would preserve anything downloaded, would simply be to remove this stanza and in the else clause of the for loop warn only if conf.auto_download is set.

Am I missing something?

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.

Discussion concluded we should leave this for follow-up

@ayshih

ayshih commented Mar 13, 2024

Copy link
Copy Markdown
Contributor Author

I have one question on the implementation, whether it might not be even simpler to just preserve whatever has been downloaded (which in itself would seem more logical). What do you think?

Yes, that could be done, but the edge case that worries me is a user who does not want automatic downloading but at some point in the past happened to download IERS-A. Once that file is in the cache, that stale IERS-A file would continue to be used (by default) despite any subsequent updates of astropy-iers-data.

Of course, the natural solution would be to inspect both the IERS-A file from astropy-iers-data and any downloaded IERS-A file in the cache, and use whichever one has more recent non-predicted values, since that presumably means it is the more recent file. What do you think?

@mhvk

mhvk commented Mar 13, 2024

Copy link
Copy Markdown
Contributor

@ayshih - yes, good point. So, I guess to get this to work one would have to also change _refresh_table_as_needed and in the download failure path check whether IERS_A_FILE is more up to date then the current one: effectively, for the no download case, one could do new_table = cls.read() there and fall through to the part that updates self as needed.

p.s. We can obviously move this to a new issue/PR!

@ayshih

ayshih commented Mar 14, 2024

Copy link
Copy Markdown
Contributor Author

Let's get this PR in to solve the easy-to-encounter bug, and defer the improved handling of two IERS-A files to a future PR. I've updated the documentation more, including https://docs.astropy.org/en/stable/utils/data.html

@mhvk mhvk 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.

Looks good! (modulo the failure of course!)

Comment thread astropy/utils/iers/iers.py Outdated
Comment thread docs/utils/data.rst Outdated
therefore recommend the following guidelines:

* Do one of the following:
* Set ``astropy.utils.iers.conf.auto_download = False`` in your Astropy config

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.

I like this change to have just one recommended way!

Comment thread docs/utils/data.rst Outdated
Comment thread docs/changes/utils/16187.api.rst Outdated

@mhvk mhvk 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.

@ayshih - I have a few more nitpicky comments on docstrings, to join those of @eerovaher. Will merge once those are done.

Thanks!

Comment thread astropy/coordinates/tests/test_iau_fullstack.py Outdated
Comment thread astropy/utils/iers/iers.py Outdated
@@ -786,7 +790,7 @@ def open(cls):

"""
if not conf.auto_download:

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.

Discussion concluded we should leave this for follow-up

@neutrinoceros neutrinoceros 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.

Thank you so much for doing this. Not only is it fixing a subtle bug that has already confused several users, it's also making the underlying logic easier to reason about ! I only have a couple small suggestions and questions, but overall LGTM

Comment thread astropy/coordinates/tests/test_iau_fullstack.py Outdated
Comment thread astropy/utils/iers/iers.py Outdated
Comment thread astropy/utils/iers/iers.py Outdated
Comment thread astropy/utils/iers/tests/test_iers.py Outdated
Comment thread astropy/utils/iers/tests/test_iers.py Outdated
Comment thread docs/utils/data.rst Outdated
Comment thread astropy/utils/iers/tests/test_iers.py
@astrofrog astrofrog added this to the v7.0.0 milestone Apr 4, 2024
@ayshih

ayshih commented Jul 8, 2024

Copy link
Copy Markdown
Contributor Author

I totally forgot about this PR. I've addressed the comments from @neutrinoceros and rebased the PR.

@neutrinoceros neutrinoceros 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.

LGTM now, thanks !

@mhvk mhvk 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.

OK, let's get this in. Thanks, @ayshih!

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

Labels

API change PRs and issues that change an existing API, possibly requiring a deprecation period Bug Docs utils.iers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When iers_degraded_accuracy = error, Astropy reports a warning and not an error (in coordinates) IERSRangeError after downloading table from USNO

6 participants