You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#9365 introduced the ability to update ERFA leap seconds. A few updates would still be nice
Document it in a bit more detail, in particular to tell how to avoid downloading with iers.conf.auto_download = False (both in iers docs and in LeapSeconds docstring).
Document how it can be used to simulate having missing leap seconds (@eteq).
Make the various URLs lists that include mirrors (easier with Cache preload #9182 merged).
Hard-code system files for more various operating systems.
I think we'd want to have them in either case, since in most systems these will be up to date and hence the auto-update doesn't have to retrieve anything.
That's useful to know, but I've already seen cases where the download appears to be happening at import time, rather than when I explicitly use the LeapSeconds class. I still need to track down exactly what is happening, but maybe you know of how that might happen?
Hmm, for example, would doing from astropy.time import Time cause LeapSeconds to be instantiated, in which case there's a sort of race condition where that import has to happen afterconf.auto_download is set?
Yes, it is the very first time a Time is initialized; I tried hard to avoid this but couldn't work out a secure way (there were rather horrible circular dependencies).
The hope, though, was that if the very first thing one does is
from astropy.utils import iers
iers.conf.auto_download = False
it should work. But am not sure if this is actually the case (if not, do let me/us know).
What should work is to set it inside .astropy/config (but I never tried that myself, I fear...)
In my tests, I am definitely setting auto_download = Falsebefore instantiating astropy.time.Time, but afterastropy.time.Time is imported. That suggests that the configuration is already loaded into astropy.time.Time before instantiation. I thought the configuration was a singleton, but maybe it's not?
@weaverba137 - yes, Time is used almost everywhere and your traceback makes clear why... I now recall that the main trouble I had was to avoid Table loading it too, since that would prevent the leap second Table from being created.
@pllim - I was wondering too, but if the file included in astropy is up to date, it will not attempt to download anything. And the file we currently have expires Dec 2020 (I seem to have updated that as part of #9908).
We need long-term version stability (for reproducibility among other things) so we change versions extremely infrequently. We are only just now starting to prepare for transitioning to Astropy 4. We can't just install the latest version of anything each time we run.
If we made significant structural changes to our pipeline, we could in principle prepare a node in advance with configuration files. However, the effort involved would be much greater than simply making configuration changes in code at runtime.
@weaverba137 - fair enough, and best would be to make it easy to support. Of course, if you use an old version, and you need times and coordinates that are correct for the present, you will have to update IERS and leap seconds regardless, so possibly we should mostly be focussing on how to do that most easily. I can definitely see, though, that adjusting the configuration inside the python code that does all the work is easier than changing configuration files, so allowing to import the various conf without side effects is important regardless.
I cannot seem to get this test below to work properly when I run it with pytest. The behavior is different form when I run it line-by-line in IPython interpreter. 🤷♀
frompytest_remotedata.disable_internetimportno_internetfromastropy.tests.helperimportcatch_warningsdeftest_import_no_remote():
fromastropy.timeimportTimefromastropy.utils.iers.iersimportLeapSeconds, IERS_LEAP_SECOND_FILELeapSeconds._auto_open_files[0] =''# Ignore ERFALeapSeconds._auto_open_files[1] =''# Ignore package datawithcatch_warnings() aswarns:
withno_internet():
assertTime('J2000').jd>0assertlen(warns) ==1and'An attempt was made to connect to the internet'instr(warns[0].message)
LeapSeconds._auto_open_files[0] ='erfa'LeapSeconds._auto_open_files[1] =IERS_LEAP_SECOND_FILE
None of the pieces have really been addressed, so in that sense, yes, still relevant. On the other hand, no one seems to have minded enough to address them, so maybe it is fine to just close it... I think the discussion here has certainly been separate enough not to be of much help, so let me just close...
Activity
[-]Post-leap-second update to do[/-][+]Post-leap-second update to do list[/+]pllim commentedon Oct 28, 2019
Re: Hard-code system files for more operating systems. -- This is no longer necessary if you choose to remove the test for system file?
mhvk commentedon Oct 28, 2019
I think we'd want to have them in either case, since in most systems these will be up to date and hence the auto-update doesn't have to retrieve anything.
weaverba137 commentedon Apr 6, 2020
How can I inhibit downloading the leap second file similar to how the download of the IERS file can be inhibited?
mhvk commentedon Apr 7, 2020
@weaverba137 -
iers.conf.auto_download = Falsewill also stop downloading leap-second files:astropy/astropy/utils/iers/iers.py
Lines 993 to 994 in 8267d16
Looking at the linked documentation, it clearly needs to discuss this is more detail. For now, I've just added an action item to the list...
weaverba137 commentedon Apr 7, 2020
That's useful to know, but I've already seen cases where the download appears to be happening at import time, rather than when I explicitly use the LeapSeconds class. I still need to track down exactly what is happening, but maybe you know of how that might happen?
weaverba137 commentedon Apr 7, 2020
Hmm, for example, would doing
from astropy.time import Timecause LeapSeconds to be instantiated, in which case there's a sort of race condition where that import has to happen afterconf.auto_downloadis set?weaverba137 commentedon Apr 7, 2020
Yes, in fact, it's in
astropy.time.core.Time.__new__().mhvk commentedon Apr 7, 2020
Yes, it is the very first time a
Timeis initialized; I tried hard to avoid this but couldn't work out a secure way (there were rather horrible circular dependencies).The hope, though, was that if the very first thing one does is
it should work. But am not sure if this is actually the case (if not, do let me/us know).
What should work is to set it inside
.astropy/config(but I never tried that myself, I fear...)mhvk commentedon Apr 7, 2020
p.s. Of course, the good solution is to have an up-to-date system file - which is possible for all linux/MacOS, but needs some auto-configuration.
weaverba137 commentedon Apr 7, 2020
Thanx, I'll run some tests soon.
weaverba137 commentedon Apr 7, 2020
In my tests, I am definitely setting
auto_download = Falsebefore instantiatingastropy.time.Time, but afterastropy.time.Timeis imported. That suggests that the configuration is already loaded intoastropy.time.Timebefore instantiation. I thought the configuration was a singleton, but maybe it's not?18 remaining items
mhvk commentedon Apr 7, 2020
@weaverba137 - yes,
Timeis used almost everywhere and your traceback makes clear why... I now recall that the main trouble I had was to avoidTableloading it too, since that would prevent the leap secondTablefrom being created.pllim commentedon Apr 8, 2020
Would #10125 fix your problem, @weaverba137 ?
weaverba137 commentedon Apr 8, 2020
That PR is a good start but:
Time()inastropy.coordinates? Inastropyas a whole?Time()in other contexts, so we still need to actively suppress downloads using other methods.In other words, #10125 fixes an unexpected call to
Time()but it doesn't fix every call toTime().weaverba137 commentedon Apr 8, 2020
#10126 fixes the specific problem with
auto_max_age = None.mhvk commentedon Apr 8, 2020
I think one really useful thing would be to have a test that checks that importing all the modules of astropy does not cause any downloads...
pllim commentedon Apr 8, 2020
I am surprised that our CI hasn't complained about it given that most of our jobs do not have remote data set. I'll investigate when I get the chance.
mhvk commentedon Apr 8, 2020
@pllim - I was wondering too, but if the file included in astropy is up to date, it will not attempt to download anything. And the file we currently have expires Dec 2020 (I seem to have updated that as part of #9908).
mhvk commentedon Apr 8, 2020
belatedly, on:
But doesn't that mean you can install an up-to-date astropy, or set up an astropy cache that includes an up-to-date leap-second file?
weaverba137 commentedon Apr 8, 2020
@mhvk, no not really.
We need long-term version stability (for reproducibility among other things) so we change versions extremely infrequently. We are only just now starting to prepare for transitioning to Astropy 4. We can't just install the latest version of anything each time we run.
If we made significant structural changes to our pipeline, we could in principle prepare a node in advance with configuration files. However, the effort involved would be much greater than simply making configuration changes in code at runtime.
mhvk commentedon Apr 8, 2020
@weaverba137 - fair enough, and best would be to make it easy to support. Of course, if you use an old version, and you need times and coordinates that are correct for the present, you will have to update IERS and leap seconds regardless, so possibly we should mostly be focussing on how to do that most easily. I can definitely see, though, that adjusting the configuration inside the python code that does all the work is easier than changing configuration files, so allowing to import the various
confwithout side effects is important regardless.pllim commentedon Apr 8, 2020
Re: #9479 (comment) on testing.
I cannot seem to get this test below to work properly when I run it with
pytest. The behavior is different form when I run it line-by-line in IPython interpreter. 🤷♀Also see astropy/pytest-remotedata#17 (comment)
pllim commentedon Jun 29, 2026
@mhvk is this issue still relevant?
mhvk commentedon Jun 30, 2026
None of the pieces have really been addressed, so in that sense, yes, still relevant. On the other hand, no one seems to have minded enough to address them, so maybe it is fine to just close it... I think the discussion here has certainly been separate enough not to be of much help, so let me just close...