MickaelRigault / ztfquery

Access ZTF data from Python
Apache License 2.0
37 stars 18 forks source link

Crash when downloading "psfcat.fits" files with nprocess>1 #25

Open BenjaminRacine opened 3 years ago

BenjaminRacine commented 3 years ago

Hi,

I am working at CC-in2p3, right now, with version '1.12.9'. I have had issues when downloading "psfcat.fits" files using nprocess>1. Surpisingly, it works all fine when I download "sciimg.fits" files, or if I use nprocess=1.

Here is the code to reproduce the problem.

import numpy as np
import ztfquery
ztfquery.__version__
from ztfquery import query
zquery = query.ZTFQuery()
from astropy import time

starttime = time.Time(59114,format='mjd').jd
endtime = time.Time(59114+1,format='mjd').jd
zquery.load_metadata(radec=[354.6703139,  15.9540473],sql_query=f"obsjd>{starttime} and obsjd<{endtime}") 
# this should yield 4 expositions
zquery.get_data(["sciimg.fits","mskimg.fits","psfcat.fits"],show_progress=False,indexes=np.arange(4),maxnprocess=4)

This crashes with error message attached below. If I run instead

zquery.get_data(["sciimg.fits","mskimg.fits"],show_progress=False, indexes=np.arange(4),maxnprocess=4)
zquery.get_data("psfcat.fits",show_progress=False, indexes=np.arange(4),maxnprocess=1)

It works fine.

Best,

Ben

Here is the error message:

---------------------------------------------------------------------------
RemoteTraceback                           Traceback (most recent call last)
RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_distrib/v21.0.0/conda/miniconda3-py37_4.8.2/envs/lsst-scipipe-cb4e2dc/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/sps/lsst/users/bracine/ZTF/ztfquery/ztfquery/io.py", line 483, in _download_
    download_single_url(url, fileout=fileout, overwrite=overwrite, verbose=verbose)
  File "/sps/lsst/users/bracine/ZTF/ztfquery/ztfquery/io.py", line 584, in download_single_url
    ipython_widget=is_running_from_notebook()) as bar:
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_distrib/v21.0.0/conda/miniconda3-py37_4.8.2/envs/lsst-scipipe-cb4e2dc/lib/python3.7/site-packages/astropy/utils/console.py", line 571, in __init__
    self.update(0)
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_distrib/v21.0.0/conda/miniconda3-py37_4.8.2/envs/lsst-scipipe-cb4e2dc/lib/python3.7/site-packages/astropy/utils/console.py", line 614, in update
    self._update_ipython_widget(value)
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_distrib/v21.0.0/conda/miniconda3-py37_4.8.2/envs/lsst-scipipe-cb4e2dc/lib/python3.7/site-packages/astropy/utils/console.py", line 687, in _update_ipython_widget
    frac = (value/self._total)
ZeroDivisionError: division by zero
"""

The above exception was the direct cause of the following exception:

ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-5-7fc1b5ac5fa0> in <module>
      1 idx=np.arange(4)
----> 2 Files=zquery.get_data(["sciimg.fits","mskimg.fits","psfcat.fits"],show_progress=False, indexes=idx,maxnprocess=4)
      3 
      4 # old way
      5 #zquery.download_data("sciimg.fits",show_progress=False, indexes=idx)

/sps/lsst/users/bracine/ZTF/ztfquery/ztfquery/query.py in get_data(self, suffix, indexes, downloadit, check_suffix, dlfrom, overwrite, maxnprocess, exist, show_progress, **kwargs)
    295         return io.get_file(self.get_data_path(indexes=indexes), suffix=suffix, exist=exist,
    296                                downloadit=downloadit, show_progress=show_progress, dlfrom=dlfrom,
--> 297                                maxnprocess=maxnprocess, check_suffix=check_suffix, **kwargs)
    298 
    299 

/sps/lsst/users/bracine/ZTF/ztfquery/ztfquery/io.py in get_file(filename, suffix, downloadit, verbose, check_suffix, dlfrom, overwrite, maxnprocess, exist, squeeze, show_progress, **kwargs)
     75         _ = download_from_filename(local_filenames[flag_todl],show_progress=show_progress,
     76                                     host=dlfrom, overwrite=overwrite, maxnprocess=maxnprocess,
---> 77                                     check_suffix=check_suffix)
     78     # - Output
     79     if len(local_filenames)==1 and squeeze:

/sps/lsst/users/bracine/ZTF/ztfquery/ztfquery/io.py in download_from_filename(filename, suffix, verbose, overwrite, auth, nodl, host, maxnprocess, show_progress, check_suffix, **kwargs)
    117                             cookies = get_cookie(*auth),
    118                             show_progress=show_progress,
--> 119                             **kwargs)
    120 
    121 

/sps/lsst/users/bracine/ZTF/ztfquery/ztfquery/io.py in download_url(to_download_urls, download_location, show_progress, verbose, overwrite, nprocess, cookies, **kwargs)
    519             for j, result in enumerate( p.imap_unordered(_download_, zip(to_download_urls,
    520                                                                     download_location,
--> 521                                                                  overwrite_, verbose_))):
    522                 if bar is not None:
    523                     bar.update(j)

/cvmfs/sw.lsst.eu/linux-x86_64/lsst_distrib/v21.0.0/conda/miniconda3-py37_4.8.2/envs/lsst-scipipe-cb4e2dc/lib/python3.7/multiprocessing/pool.py in next(self, timeout)
    746         if success:
    747             return value
--> 748         raise value
    749 
    750     __next__ = next                    # XXX

ZeroDivisionError: division by zero