Skip to content

Make sure we re-download the IERS table if the URL has changed. - #5072

Merged
astrofrog merged 2 commits into
astropy:masterfrom
astrofrog:fix-iers-caching
Jun 11, 2016
Merged

astrofrog merged 2 commits into
astropy:masterfrom
astrofrog:fix-iers-caching

Conversation

@astrofrog

@astrofrog astrofrog commented Jun 11, 2016 •

Copy link
Copy Markdown
Member

This is the solution to the issues reported in #5051 (took a few hours to figure out...). I'm surprised you didn't see the issue when running the tests (I don't see how they could pass before this PR).

The issue is that tests run before astropy.utils.iers cause the IERS file to be downloaded, which sets IERS_Auto.iers_table. When you then later change the URL to a local file in test_iers.py, it did not try and get the local file because cls.iers_table is not None and it was then using the real downloaded file instead of the local file. This also explains why the test did not fail when running just the IERS tests. With this PR, if the URL has changed, the file is retrieved again.

Another solution would be to simply not cache .iers_table and rely only on the download_file caching mechanism.

@taldcroft - can you review this and let me know what you think?

cc @pllim

@astrofrog astrofrog added time Bug Affects-dev PRs and issues that do not impact an existing Astropy release labels Jun 11, 2016
@astrofrog astrofrog added this to the v1.2.0 milestone Jun 11, 2016
@astrofrog astrofrog added the 🔥 Critical label Jun 11, 2016
@astrofrog

Copy link
Copy Markdown
Member Author

(This is not really critical but I'm marking it as such to make sure I include it in the 1.2 RC)

@astrofrog

Copy link
Copy Markdown
Member Author

I've also opened a PR for a simpler alternative: #5074

@astrofrog astrofrog added utils and removed time labels Jun 11, 2016
@taldcroft

Copy link
Copy Markdown
Member

Thanks @astrofrog. I had arrived at the same conclusion just minutes before seeing your notification. I remember when developing this that I had thought about checking the URL for a change and decided not to, but thinking now it seems like a good plan. This would have saved a lot of headache...

I like this over #5074, since it seems like that one will re-read the table every time you do an open(). I will look at this in more detail later today to make sure it should be OK.

@taldcroft

Copy link
Copy Markdown
Member

In particular I think that #5074 will re-read the cached file (slow) each time you do a UT1 transform.

@astrofrog

Copy link
Copy Markdown
Member Author

@taldcroft - ok, that sounds good. Feel free to merge this one once you are happy with it and close #5074. Once one of them is merged, I'll cut the 1.2rc1.

@taldcroft

Copy link
Copy Markdown
Member

The URL is already stored, so I think you can just test for cls.iers_table.meta.get('data_url') == conf.iers_auto_url. I haven't tried this though, have to run now.

@taldcroft

Copy link
Copy Markdown
Member

Otherwise 👍.

@astrofrog
astrofrog merged commit af013ef into astropy:master Jun 11, 2016
astrofrog added a commit that referenced this pull request Jun 11, 2016
Make sure we re-download the IERS table if the URL has changed.
@astrofrog
astrofrog deleted the fix-iers-caching branch July 5, 2016 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release Bug 🔥 Critical utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants