MickaelRigault / ztfquery

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

test_files(redownload=True) has no session defined. #40

Open JTerwel opened 1 year ago

JTerwel commented 1 year ago

I am trying to download images through Simeon Reusch's fpbot code, which uses ztfquery for the download. While downloading an object I got a timeout error due to too many requests in a short timespan. This was caused by trying to run too many parallel downloads, and was fixed by reducing the number before restarting my code.

The crash however seems to have caused some files to be corrupted. Luckily ztfquery should check for this after a download and will redownload the corrupted files. This however causes a crash as no session has been defined.

ztfquery.io.test_files() does not define session (but it could be defined through **kwargs?) and is called from ztfquery.query.download_data(), which does not provide a definition for session, causing the issue.

This is the relevant part of the error message: Traceback (most recent call last): ... File "/home/users/terwelj/Late-time_interactions/real-time_version/lc_generator.py", line 102, in run_fpbot pl.download() File "/home/users/terwelj/.conda/envs/real-time_search/lib/python3.10/site-packages/fpbot/pipeline.py", line 496, in download fp.io.download_data( File "/home/users/terwelj/.conda/envs/real-time_search/lib/python3.10/site-packages/ztflc/io.py", line 131, in download_data self.zquery.download_data( File "/home/users/terwelj/.conda/envs/real-time_search/lib/python3.10/site-packages/ztfquery/query.py", line 470, in download_data fileissue = io.test_files( File "/home/users/terwelj/.conda/envs/real-time_search/lib/python3.10/site-packages/ztfquery/io.py", line 720, in test_files session=session, NameError: name 'session' is not defined

JTerwel commented 1 year ago

The fix is quite simple: just define the session properly just before the call that uses it by adding

session = open_irsa_session()