astropy: Leap second tests fail if system clock is in the future (2021-06-04)

Description

As part of my work on reproducible builds for openSUSE, I check that software still gives identical build results in the future. The usual offset is +15 years, because that is how long I expect some software will be used in some places. This showed up failing tests in our python-astropy package build. See https://reproducible-builds.org/ for why this matters.

Expected behavior

Software should be able to build anytime.

Actual behavior

tests fail with

astropy/utils/iers/iers.py:1021: in auto_open
    warn('leap-second file is expired.', IERSStaleWarning)
E   astropy.utils.iers.iers.IERSStaleWarning: leap-second file is expired.

That check already fails before 2021-06-04

and when dropping that expiry check, there is another problem with Time.now()

astropy/time/core.py:583: in now
    return cls(val=dtnow, format='datetime', scale='utc')
astropy/time/core.py:430: in __init__ 
    self._init_from_vals(val, val2, format, scale, copy,
astropy/time/core.py:485: in _init_from_vals
    self._time = self._get_time_fmt(val, val2, format, scale,
astropy/time/core.py:543: in _get_time_fmt
    return cls(val, val2, scale, precision, in_subfmt, out_subfmt)
astropy/time/formats.py:148: in __init__ 
    self.set_jds(val1, val2)
astropy/time/formats.py:831: in set_jds
    jd1, jd2 = erfa.dtf2d(self.scale.upper().encode('ascii'),
astropy/_erfa/core.py:15703: in dtf2d 
    check_errwarn(c_retval, 'dtf2d') 

Steps to Reproduce

  1. set system clock to 2035
  2. run tests: py.test-3.8

System Details

Linux-5.6.6-1-default-x86_64-with-glibc2.2.5 Python 3.8.2 (default, Mar 05 2020, 18:58:42) [GCC] Numpy 1.18.3 astropy 4.0.1.post1 Scipy 1.4.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 29 (21 by maintainers)

Most upvoted comments

Indeed, it would seem that the failures were “real” in that they would correctly warn that the code was not reliable for the “present time”. So, let’s close this. But please do not hesitate to open another issue; I very much appreciate the reproducible build efforts!!

The fail in 2034 is because of some functions reporting it as “dubious year”:

astropy.utils.exceptions.ErfaWarning: ERFA function "dtf2d" yielded 1 of "dubious year (Note 6)"

And I thought 2020 is already a dubious year 👀