Skip to content

Test failures with remote_data=True #4896

Closed

Description

@pllim

Someone should turn on remote_data and do a test before 1.2 release. I get the following failures on my machine (the last one cracks me up):

================================== FAILURES ===================================
___________________ test_database_specify[ngc 3642-db_dict0] ___________________

name = 'ngc 3642'
db_dict = {'all': '# ngc3642    #Q22523722
#=S=Simbad (via url):    1
%@ 503952
%I.0 NGC 3642
%C.0 LIN
%C.N0 15.15.01.00
%J 170....V=VizieR (local):    1
%J 170.56 +59.08 = 11:22.2     +59:05
%I.0 {NGC} 3642



#====Done (2013-Feb-12,16:37:42z)===='}

    @remote_data
    @pytest.mark.parametrize(("name", "db_dict"), [('ngc 3642', _cached_ngc3642),
                                                   ('castor', _cached_castor)])
    def test_database_specify(name, db_dict):
        # First check that at least some sesame mirror is up
        for url in sesame_url.get():
            if urllib.request.urlopen(url).getcode() == 200:
                break
        else:
            pytest.skip("All SESAME mirrors appear to be down, skipping "
                        "test_name_resolve.py:test_database_specify()...")

        for db in db_dict.keys():
            with sesame_database.set(db):
                try:
                    icrs = SkyCoord.from_name(name)
                except NameResolveError:
>                   ra, dec = db_dict[db]
E                   ValueError: too many values to unpack

.../astropy/coordinates/tests/test_name_resolve.py:160: ValueError___________________ test_database_specify[ngc 3642-db_dict0] ___________________

name = 'ngc 3642'
db_dict = {'all': '# ngc3642    #Q22523722\n#=S=Simbad (via url):    1\n%@ 503952\n%I.0 NGC 3642\n%C.0 LIN\n%C.N0 15.15.01.00\n%...eR (local):    1\n%J 170.56 +59.08 = 11:22.2     +59:05\n%I.0 {NGC} 3642\n\n\n\n#====Done (2013-Feb-12,16:37:42z)===='}

    @remote_data
    @pytest.mark.parametrize(("name", "db_dict"), [('ngc 3642', _cached_ngc3642),
                                                   ('castor', _cached_castor)])
    def test_database_specify(name, db_dict):
        # First check that at least some sesame mirror is up
        for url in sesame_url.get():
            if urllib.request.urlopen(url).getcode() == 200:
                break
        else:
            pytest.skip("All SESAME mirrors appear to be down, skipping "
                        "test_name_resolve.py:test_database_specify()...")

        for db in db_dict.keys():
            with sesame_database.set(db):
                try:
                    icrs = SkyCoord.from_name(name)
                except NameResolveError:
>                   ra, dec = db_dict[db]
E                   ValueError: too many values to unpack

.../astropy/coordinates/tests/test_name_resolve.py:160: ValueError
_____________________ test_constellations_with_nameresolve _____________________

    @remote_data
    def test_constellations_with_nameresolve():
        assert SkyCoord.from_name('And I').get_constellation(short_name=True) == 'And'

        #you'd think "And ..." should be in Andromeda.  But you'd be wrong.
        assert SkyCoord.from_name('And VI').get_constellation() == 'Pegasus'

        #maybe it's because And VI isn't really a galaxy?
        assert SkyCoord.from_name('And XXII').get_constellation() == 'Pisces'
        assert SkyCoord.from_name('And XXX').get_constellation() == 'Cassiopeia'
        #ok maybe not

        #ok, but at least some of the others do make sense...
        assert SkyCoord.from_name('Coma Cluster').get_constellation(short_name=True) == 'Com'
>       assert SkyCoord.from_name('UMa II').get_constellation() == 'Ursa Major'

.../astropy/coordinates/tests/test_sky_coord.py:1162: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../astropy/coordinates/sky_coordinate.py:1174: in from_name
    icrs_coord = get_icrs_coordinates(name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'UMa II'

    def get_icrs_coordinates(name):
        """
        Retrieve an ICRS object by using an online name resolving service to
        retrieve coordinates for the specified name. By default, this will
        search all available databases until a match is found. If you would like
        to specify the database, use the science state
        ``astropy.coordinates.name_resolve.sesame_database``. You can also
        specify a list of servers to use for querying Sesame using the science
        state ``astropy.coordinates.name_resolve.sesame_url``. This will try
        each one in order until a valid response is returned. By default, this
        list includes the main Sesame host and a mirror at vizier.  The
        configuration item `astropy.utils.data.Conf.remote_timeout` controls the
        number of seconds to wait for a response from the server before giving
        up.

        Parameters
        ----------
        name : str
            The name of the object to get coordinates for, e.g. ``'M42'``.

        Returns
        -------
        coord : `astropy.coordinates.ICRS` object
            The object's coordinates in the ICRS frame.

        """

        database = sesame_database.get()
        # The web API just takes the first letter of the database name
        db = database.upper()[0]

        # Make sure we don't have duplicates in the url list
        urls = []
        domains = []
        for url in sesame_url.get():
            domain = urllib.parse.urlparse(url).netloc

            # Check for duplicates
            if domain not in domains:
                domains.append(domain)

                # Add the query to the end of the url, add to url list
                fmt_url = os.path.join(url, "{db}?{name}")
                fmt_url = fmt_url.format(name=urllib.parse.quote(name), db=db)
                urls.append(fmt_url)

        for url in urls:
            try:
                # Retrieve ascii name resolve data from CDS
                resp = urllib.request.urlopen(url, timeout=data.conf.remote_timeout)
                resp_data = resp.read()
                break
            except urllib.error.URLError as e:
                # This catches a timeout error, see:
                #   http://stackoverflow.com/questions/2712524/handling-urllib2s-timeout-python
                if isinstance(e.reason, socket.timeout):
                    # If it was a timeout, try with the next URL
                    continue
                else:
                    raise NameResolveError(
                        "Unable to retrieve coordinates for name '{0}'; "
                        "connection timed out".format(name))
            except socket.timeout:
                # There are some cases where urllib2 does not catch socket.timeout
                # especially while receiving response data on an already previously
                # working request
                raise NameResolveError(
                    "Unable to retrieve coordinates for name '{0}'; connection "
                    "timed out".format(name))

        # All Sesame URL's timed out...
        else:
            raise NameResolveError("All Sesame queries timed out. Unable to "
                                   "retrieve coordinates.")

        ra, dec = _parse_response(resp_data)

        if ra is None and dec is None:
            if db == "A":
                err = "Unable to find coordinates for name '{0}'".format(name)
            else:
                err = "Unable to find coordinates for name '{0}' in database {1}"\
                      .format(name, database)

>           raise NameResolveError(err)
E           NameResolveError: Unable to find coordinates for name 'UMa II'

.../astropy/coordinates/name_resolve.py:173: NameResolveError
___________________ TestFileFunctions.test_open_nonexistent ____________________

self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x7f6b58687cd0>

    def test_open_nonexistent(self):
        """Test that trying to open a non-existent file results in an
            IOError (and not some other arbitrary exception).
            """

        try:
            fits.open(self.temp('foobar.fits'))
        except IOError as e:
>           assert 'No such file or directory' in str(e)
E           assert 'No such file or directory' in "[Errno 2] Datei oder Verzeichnis nicht gefunden: '/tmp/fits-test-Y2tDbp/foobar.fits'"
E            +  where "[Errno 2] Datei oder Verzeichnis nicht gefunden: '/tmp/fits-test-Y2tDbp/foobar.fits'" = str(IOError(2, 'Datei oder Verzeichnis nicht gefunden'))

.../astropy/io/fits/tests/test_core.py:598: AssertionError
======= 4 failed, 9850 passed, 73 skipped, 42 xfailed in 262.66 seconds ========
1

Activity

  1. added this to the v1.2.0 milestone on May 13, 2016
  2. bsipocz commented on May 13, 2016

    @bsipocz
    Member

    hmm, I saw the coordinates ones before (there is also an issue somewhere), and started to have a look, but didn't have time to get anywhere with the fix.

  3. astrofrog commented on May 13, 2016

    @astrofrog
    Member

    What? Why is there an error message in German? Did someone mess with the locale? 🇩🇪

  4. pllim commented on May 13, 2016

    @pllim
    MemberAuthor

    ich weiß es nicht ¯_(ツ)_/¯

  5. pllim commented on May 13, 2016

    @pllim
    MemberAuthor

    By the way, my locale is:

    > echo $LANG
    en_US.UTF-8
    
  6. eteq commented on May 16, 2016

    @eteq
    Member

    There's actually two problems in the first two name resolve errors: one is that the "real" error is hidden (see #4925), and the second is whatever the underlying error is (hard to diagnose without #4925). But I see the same.

    The last two are baffling, though. I have no idea what's up with the 🇩🇪... But the other one is especially strange because it works fine for me - just tried right now.

    I wonder if it's a network thing? I've seen hints of this before where sesame name resolve calls seem to go to different servers depending on where you are, and they aren't always synced. But that's strange given that @pllim and I should be on very similar networks, as we're in the same city... As a wild guess, @pllim, did you do this from a computer inside the STScI network? Can you try from outside the network if so (or inside the network if not)?

  7. pllim commented on May 16, 2016

    @pllim
    MemberAuthor

    @eteq , it was done on RHEL6 64-bit, Python 2, Anaconda, internal network.

    Regarding the non-German error that you didn't get (I assume you're talking about "UMa II"), did you do your test on Python 3? If so, could it be a unicode_literals thing? I recently run into troubles with that import in my other projects.

    I cannot hook this RHEL6 on external network, but I can try that on a Windows laptop...

  8. pllim commented on May 16, 2016

    @pllim
    MemberAuthor

    Update: No luck on my Windows laptop. I get "Python has stopped working" at io/fits/test_checksum.py... 🙈

  9. pllim commented on May 16, 2016

    @pllim
    MemberAuthor

    Back to my Linux machine, using #4925:

    This is what I get when running astropy.test(remote_data=True) in a Python session (not IPython) that is started outside of the source directory (3 errored tests):
    astropy_test_err.txt

    This is what I get when running python setup.py test --remote-data from the source directory (4 errored tests but the last one I think is just me not having some optional dependency package installed):
    astropy_test_err_codedir.txt

  10. MSeifert04 commented on May 16, 2016

    @MSeifert04
    Contributor

    I get "Python has stopped working" at io/fits/test_checksum.py... 🙈

    I can confirm this.

  11. pllim commented on May 16, 2016

    @pllim
    MemberAuthor

    I still don't know why my FITS test error message is not in English, because it is English when I try to open a non-existing file manually:

    Python 2.7.11 |Anaconda 2.3.0 (64-bit)| (default, Dec  6 2015, 18:08:32) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    Anaconda is brought to you by Continuum Analytics.
    Please check out: http://continuum.io/thanks and https://anaconda.org
    >>> import astropy
    >>> astropy.__version__
    u'1.2.dev15333'
    >>> from astropy.io import fits
    >>> fits.open('/tmp/nosuchfile.fits')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File ".../astropy/io/fits/hdu/hdulist.py", line 139, in fitsopen
        return HDUList.fromfile(name, mode, memmap, save_backup, cache, **kwargs)
      File ".../astropy/io/fits/hdu/hdulist.py", line 281, in fromfile
        save_backup=save_backup, cache=cache, **kwargs)
      File ".../astropy/io/fits/hdu/hdulist.py", line 802, in _readfrom
        ffo = _File(fileobj, mode=mode, memmap=memmap, cache=cache)
      File ".../astropy/io/fits/file.py", line 150, in __init__
        self._open_filename(fileobj, mode, clobber)
      File ".../astropy/io/fits/file.py", line 502, in _open_filename
        self._file = fileobj_open(self.name, PYFITS_MODES[mode])
      File ".../astropy/io/fits/util.py", line 403, in fileobj_open
        return open(filename, mode)
    IOError: [Errno 2] No such file or directory: '/tmp/nosuchfile.fits'
  12. 21 remaining items

  13. astrofrog commented on Jun 9, 2016

    @astrofrog
    Member

    @pllim - ah yes, indeed! I'll fix that directly in master and will backport to 1.2.x

  14. taldcroft commented on Jun 9, 2016

    @taldcroft
    Member

    @eteq @mhvk - argh. It did work when the PR was merged. Could the IERS-B update have had an impact? I'm investigating now.

  15. taldcroft commented on Jun 9, 2016

    @taldcroft
    Member

    Oddly I get a failure in a slightly different place:

    ============================================ FAILURES ============================================
    ___________________________________ TestIERS_Auto.test_simple ____________________________________
    
    self = <astropy.utils.iers.tests.test_iers.TestIERS_Auto instance at 0x7f864c611488>
    
        @remote_data
        def test_simple(self):
            iers_a_file_1 = os.path.join(os.path.dirname(__file__), 'finals2000A-2016-02-30-test')
            iers_a_file_2 = os.path.join(os.path.dirname(__file__), 'finals2000A-2016-04-30-test')
            iers_a_url_1 = 'file://' + os.path.abspath(iers_a_file_1)
            iers_a_url_2 = 'file://' + os.path.abspath(iers_a_file_2)
    
            iers.conf.iers_auto_url = iers_a_url_1
    
            dat = iers.IERS_Auto.open()
            assert dat['MJD'][0] == 57359.0 * u.d
            assert dat['MJD'][-1] == 57539.0 * u.d
    
            # Pretend we are accessing at a time 7 days after start of predictive data
            predictive_mjd = dat.meta['predictive_mjd']
            dat._time_now = Time(predictive_mjd, format='mjd') + 7 * u.d
    
            # Look at times before and after the test file begins.
    >       assert np.allclose(dat.ut1_utc(Time(50000, format='mjd').jd).value, 0.0262719)
    E       assert <function allclose at 0x7f8656d4a230>(0.1292905, 0.0262719)
    E        +  where <function allclose at 0x7f8656d4a230> = np.allclose
    E        +  and   0.1292905 = <Quantity 0.1292905 s>.value
    E        +    where <Quantity 0.1292905 s> = <bound method IERS_Auto.ut1_utc of <IERS_Auto length=181>\n year month  day    ...   16     7    30 57539.0           P ...        P 0.214232 0.442454         P>(2450000.5)
    E        +      where <bound method IERS_Auto.ut1_utc of <IERS_Auto length=181>\n year month  day    ...   16     7    30 57539.0           P ...        P 0.214232 0.442454         P> = <IERS_Auto length=181>\n year month  day    MJD   PolPMFlag_A ... UT1Flag    PM...\n   16     7    30 57539.0           P ...        P 0.214232 0.442454         P.ut1_utc
    E        +      and   2450000.5 = <Time object: scale='utc' format='mjd' value=50000.0>.jd
    E        +        where <Time object: scale='utc' format='mjd' value=50000.0> = Time(50000, format='mjd')
    
    astropy/utils/iers/tests/test_iers.py:172: AssertionError
    
  16. pllim commented on Jun 9, 2016

    @pllim
    MemberAuthor

    I tested it in Python 2.7 with latest master, if it makes a difference.

  17. taldcroft commented on Jun 9, 2016

    @taldcroft
    Member

    See #5051 for IERS fix.

  18. astrofrog commented on Jun 11, 2016

    @astrofrog
    Member

    @pllim - can you confirm that everything is fixed on the latest master? (see #5072 which I think fixes the last of the remote tests)

  19. pllim commented on Jun 11, 2016

    @pllim
    MemberAuthor

    I can't test till Monday. If I'm holding up the release, just forge ahead. We can figure this out later if needed. Thanks!

  20. added
    Close?Tell stale bot that this issue/PR is stale
    on Jun 12, 2016
  21. pllim commented on Jun 13, 2016

    @pllim
    MemberAuthor

    Yes, IERS tests finally pass. Thanks!

    However, one Cone Search test is failing because some services are down (beyond my control) 😅 -- Do you want me to open a PR for this marking it as xfail or something?

    _________ TestConeSearch.test_async_all ___________
    self = <astropy.vo.client.tests.test_conesearch.TestConeSearch object at 0x7fcc6c82fdd0>
    
        def test_async_all(self):
            async_search_all = conesearch.AsyncSearchAll(
                SCS_CENTER, SCS_RADIUS, pedantic=self.pedantic)
    
            all_results = async_search_all.get(timeout=(data.conf.remote_timeout * 3))
    
    >       assert async_search_all.done()
    E       assert <bound method Future.done of <Future at 0x7fcc6c4f6790 state=running>>()
    E        +  where <bound method Future.done of <Future at 0x7fcc6c4f6790 state=running>> = <astropy.vo.client.conesearch.AsyncSearchAll object at 0x7fcc6c8ce890>.done
    
    astropy/vo/client/tests/test_conesearch.py:163: AssertionError
    ======= 1 failed, 11204 passed, 88 skipped, 42 xfailed in 430.89 seconds ======
    
  22. eteq commented on Jun 13, 2016

    @eteq
    Member

    @pllim - hmm, I'm not currently getting that error, so my guess is that it's a transient one (unstable server). Might make sense to update the docstring to note that this particular test sometimes fails on the server-side... But in general we've been taking the view that it's better to have remote tests that fail sometimes for reasons outside our control than not have them get tested at all.

    So I'd say we just leave the test as-is, and only @mark.xfail or remove it if we can determine that it's definitely permanently down.

    Another option is to try to figure out how to recognize that the test failed due to a server problem, and then do an in-line pytest.xfail() (although maybe that's what you meant now that I think about it?). But I've had lots of problems reliably catching those sort of errors, so I think it's not critical unless you can easily figure out how to do it.

  23. bsipocz commented on Jun 13, 2016

    @bsipocz
    Member

    @eteq - I think it's easy to measure the execution time of the line all_results = ..., and if it's longer than the timeout xfail the test?

    Sorry for the noise, should have thought more about this before writing the comment as it's not a timeout issue...

  24. pllim commented on Jun 14, 2016

    @pllim
    MemberAuthor

    Okay, closing this now. We can open a new issue about Cone Search async test being unstable if needed. Thanks, everyone!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions