icesat2py / icepyx

Python tools for obtaining and working with ICESat-2 data
https://icepyx.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
203 stars 101 forks source link

Intermittent Error on order_granules #463

Open rwegener2 opened 9 months ago

rwegener2 commented 9 months ago

When running an order_granules call such as: region.order_granules(Coverage=region.order_vars.wanted) (where region is a Query object)

I intermittently receive the error:

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[7], line 1
----> 1 region.order_granules(Coverage=region.order_vars.wanted)

File ~/icepyx/icepyx/core/query.py:1066, in Query.order_granules(self, verbose, subset, email, **kwargs)
   1055         self._granules.place_order(
   1056             tempCMRparams,
   1057             self.reqparams,
   (...)
   1062             geom_filepath=self._spatial._geom_file,
   1063         )
   1065 else:
-> 1066     self._granules.place_order(
   1067         self.CMRparams,
   1068         self.reqparams,
   1069         self.subsetparams(**kwargs),
   1070         verbose,
   1071         subset,
   1072         session=self.session,
   1073         geom_filepath=self._spatial._geom_file,
   1074     )

File ~/icepyx/icepyx/core/granules.py:443, in Granules.place_order(self, CMRparams, reqparams, subsetparams, verbose, subset, session, geom_filepath)
    441 print("Your order is:", status)
    442 messagelist = []
--> 443 for message in loop_root.findall("./processInfo/info"):
    444     messagelist.append(message.text)
    445 if messagelist != []:

UnboundLocalError: cannot access local variable 'loop_root' where it is not associated with a value

The error sometimes appears and other times does not, which makes me think it is being caused to some kind of race condition. The granules.py lines to be related to reading the output of an API response, which makes a race condition plausible. I believe a similar error also happened once while calling region.download_granules().

Full code to reproduce

I'm running this code on CryoCloud.

from icepyx.core.query import Query

short_name = 'ATL06'
spatial_extent = [-55, 68, -48, 71]
date_range = ['2019-02-20','2019-02-28']
region = Query(short_name, spatial_extent, date_range)
region.order_vars.append(beam_list=['gt1l'], var_list=['h_li', "latitude", "longitude"])
region.order_granules(Coverage=region.order_vars.wanted)