astropy / astropy

Astronomy and astrophysics core library
https://www.astropy.org
BSD 3-Clause "New" or "Revised" License
4.41k stars 1.76k forks source link

Intermittent failures when parsing an ASCII table from a URL #7917

Open astrofrog opened 6 years ago

astrofrog commented 6 years ago

I have code that does:

from astropy.table import Table
EARTHQUAKES = 'https://worldwidetelescope.github.io/pywwt/data/earthquakes_2010.csv'
table = Table.read(EARTHQUAKES, delimiter=',', format='ascii.basic')

This works around half the time - and the other half I get an error:

$ python test_url.py 
Downloading https://worldwidetelescope.github.io/pywwt/data/earthquakes_2010.csv
|===================================| 3.8M/3.8M (100.00%)         0s

$ python test_url.py 
Traceback (most recent call last):
  File "test_url.py", line 3, in <module>
    table = Table.read(EARTHQUAKES, delimiter=',', format='ascii.basic')
  File "/Users/tom/Dropbox/Code/Astropy/astropy/astropy/table/table.py", line 2555, in read
    out = io_registry.read(cls, *args, **kwargs)
  File "/Users/tom/Dropbox/Code/Astropy/astropy/astropy/io/registry.py", line 517, in read
    data = reader(*args, **kwargs)
  File "/Users/tom/Dropbox/Code/Astropy/astropy/astropy/io/ascii/connect.py", line 37, in io_read
    return read(filename, format=format, **kwargs)
  File "/Users/tom/Dropbox/Code/Astropy/astropy/astropy/io/ascii/ui.py", line 368, in read
    dat = _guess(table, new_kwargs, format, fast_reader)
  File "/Users/tom/Dropbox/Code/Astropy/astropy/astropy/io/ascii/ui.py", line 525, in _guess
    dat = reader.read(table)
  File "/Users/tom/Dropbox/Code/Astropy/astropy/astropy/io/ascii/fastbasic.py", line 117, in read
    **self.kwargs)
  File "astropy/io/ascii/cparser.pyx", line 236, in astropy.io.ascii.cparser.CParser.__cinit__
  File "astropy/io/ascii/cparser.pyx", line 278, in astropy.io.ascii.cparser.CParser.setup_tokenizer
  File "astropy/io/ascii/cparser.pyx", line 126, in astropy.io.ascii.cparser.FileString.__cinit__
FileNotFoundError: [Errno 2] No such file or directory: 'https://worldwidetelescope.github.io/pywwt/data/earthquakes_2010.csv'
pllim commented 6 years ago

Does it work better if you don't use fast reader? Are you sure this is not a network problem? I can't seem to reproduce (although I only called it 10x).

p.s. Why is the second call not using cache? :thinking:

astrofrog commented 6 years ago

Yes it works fine if I explicitly disable the fast reader. But it shouldn't fail by default. I think it could be the fast reader doesn't know how to deal with URLs, and the order of guessing is non-deterministic.