I ran the following portion of code (minimal search example, from a tutorial). It ran just fine a few weeks ago, but does not run anymore:
ASFSearch4xxError Traceback (most recent call last)
Cell In[7], line 1
----> 1 results = asf.search(platform=asf.PLATFORM.SENTINEL1, maxResults=2)
File ~/testenv/lib/python3.12/site-packages/asf_search/search/search.py:181, in search(absoluteOrbit, asfFrame, beamMode, beamSwath, campaign, maxDoppler, minDoppler, end, maxFaradayRotation, minFaradayRotation, flightDirection, flightLine, frame, granule_list, groupID, insarStackId, instrument, intersectsWith, lookDirection, offNadirAngle, platform, polarization, processingDate, processingLevel, product_list, relativeOrbit, season, start, absoluteBurstID, relativeBurstID, fullBurstID, temporalBaselineDays, operaBurstID, frameCoverage, mainBandPolarization, sideBandPolarization, rangeBandwidth, jointObservation, productionConfiguration, dataset, collections, shortName, cmr_keywords, maxResults, opts)
179 # The last page will be marked as complete if results sucessful
180 perf = time.time()
--> 181 for page in search_generator(opts=opts):
182 ASF_LOGGER.debug(f'Page Time Elapsed {time.time() - perf}')
183 results.extend(page)
File ~/testenv/lib/python3.12/site-packages/asf_search/search/search_generator.py:241, in search_generator(absoluteOrbit, asfFrame, beamMode, beamSwath, campaign, maxDoppler, minDoppler, end, maxFaradayRotation, minFaradayRotation, flightDirection, flightLine, frame, granule_list, groupID, insarStackId, instrument, intersectsWith, lookDirection, offNadirAngle, platform, polarization, processingDate, processingLevel, product_list, relativeOrbit, season, start, absoluteBurstID, relativeBurstID, fullBurstID, temporalBaselineDays, operaBurstID, frameCoverage, mainBandPolarization, sideBandPolarization, rangeBandwidth, jointObservation, productionConfiguration, dataset, collections, shortName, cmr_keywords, maxResults, opts)
239 try:
240 ASF_LOGGER.debug(f'SUBQUERY {subquery_idx + 1}: Fetching page {page_number}')
--> 241 items, subquery_max_results, cmr_search_after_header = query_cmr(
242 opts.session, url, translated_opts, subquery_count
243 )
244 except ASFSearchError as exc:
245 message = str(exc)
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:338, in BaseRetrying.wraps.<locals>.wrapped_f(*args, **kw)
336 copy = self.copy()
337 wrapped_f.statistics = copy.statistics # type: ignore[attr-defined]
--> 338 return copy(f, *args, **kw)
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:477, in Retrying.__call__(self, fn, *args, **kwargs)
475 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
476 while True:
--> 477 do = self.iter(retry_state=retry_state)
478 if isinstance(do, DoAttempt):
479 try:
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:378, in BaseRetrying.iter(self, retry_state)
376 result = None
377 for action in self.iter_state.actions:
--> 378 result = action(retry_state)
379 return result
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:400, in BaseRetrying._post_retry_check_actions.<locals>.<lambda>(rs)
398 def _post_retry_check_actions(self, retry_state: "RetryCallState") -> None:
399 if not (self.iter_state.is_explicit_retry or self.iter_state.retry_run_result):
--> 400 self._add_action_func(lambda rs: rs.outcome.result())
401 return
403 if self.after is not None:
File /usr/lib/python3.12/concurrent/futures/_base.py:449, in Future.result(self, timeout)
447 raise CancelledError()
448 elif self._state == FINISHED:
--> 449 return self.__get_result()
451 self._condition.wait(timeout)
453 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
File /usr/lib/python3.12/concurrent/futures/_base.py:401, in Future.__get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
404 self = None
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:480, in Retrying.__call__(self, fn, *args, **kwargs)
478 if isinstance(do, DoAttempt):
479 try:
--> 480 result = fn(*args, **kwargs)
481 except BaseException: # noqa: B902
482 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]
File ~/testenv/lib/python3.12/site-packages/asf_search/search/search_generator.py:303, in query_cmr(session, url, translated_opts, sub_query_count)
291 @retry(
292 reraise=True,
293 retry=retry_if_exception_type(CMRIncompleteError),
(...) 301 sub_query_count: int,
302 ):
--> 303 response = get_page(session=session, url=url, translated_opts=translated_opts)
305 perf = time.time()
306 items = [as_ASFProduct(f, session=session) for f in response.json()['items']]
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:338, in BaseRetrying.wraps.<locals>.wrapped_f(*args, **kw)
336 copy = self.copy()
337 wrapped_f.statistics = copy.statistics # type: ignore[attr-defined]
--> 338 return copy(f, *args, **kw)
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:477, in Retrying.__call__(self, fn, *args, **kwargs)
475 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
476 while True:
--> 477 do = self.iter(retry_state=retry_state)
478 if isinstance(do, DoAttempt):
479 try:
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:378, in BaseRetrying.iter(self, retry_state)
376 result = None
377 for action in self.iter_state.actions:
--> 378 result = action(retry_state)
379 return result
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:400, in BaseRetrying._post_retry_check_actions.<locals>.<lambda>(rs)
398 def _post_retry_check_actions(self, retry_state: "RetryCallState") -> None:
399 if not (self.iter_state.is_explicit_retry or self.iter_state.retry_run_result):
--> 400 self._add_action_func(lambda rs: rs.outcome.result())
401 return
403 if self.after is not None:
File /usr/lib/python3.12/concurrent/futures/_base.py:449, in Future.result(self, timeout)
447 raise CancelledError()
448 elif self._state == FINISHED:
--> 449 return self.__get_result()
451 self._condition.wait(timeout)
453 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
File /usr/lib/python3.12/concurrent/futures/_base.py:401, in Future.__get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
404 self = None
File ~/testenv/lib/python3.12/site-packages/tenacity/__init__.py:480, in Retrying.__call__(self, fn, *args, **kwargs)
478 if isinstance(do, DoAttempt):
479 try:
--> 480 result = fn(*args, **kwargs)
481 except BaseException: # noqa: B902
482 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]
File ~/testenv/lib/python3.12/site-packages/asf_search/search/search_generator.py:357, in get_page(session, url, translated_opts)
355 error_message = f'HTTP {response.status_code}: {response.json()["errors"]}'
356 if 400 <= response.status_code <= 499:
--> 357 raise ASFSearch4xxError(error_message) from exc
358 if 500 <= response.status_code <= 599:
359 raise ASFSearch5xxError(error_message) from exc
ASFSearch4xxError: HTTP 401: ['Token does not exist']
Since I manage to connect through terminal, I assume that it is an issue with the Python library. Did I setup something wrong? Any idea on what could solve it? Thanks in advance!
I am working under python 3.12 with asf_search 9.0.2 (8.1.4 previously also triggered the error). I have also tried relaunching on a new environment with only asf, with no more sucess.
Hello,
I ran the following portion of code (minimal search example, from a tutorial). It ran just fine a few weeks ago, but does not run anymore:
The search triggers error:
I have also tried launching with a session with credentials and/or with a newly generated token (on https://urs.earthdata.nasa.gov/users/_/user_tokens) but I had the same error:
More interestingly I tried to reach the url
Unauthorized for url: https://cmr.earthdata.nasa.gov/search/granules.umm_jsonthrough terminal:curl -H "" "https://cmr.earthdata.nasa.gov/search/granules.umm_json?short_name=SENTINEL-1A_SLC&page_size=1"And I got an answer with no error (
{"hits":1923631,"took":963,"items":[{"meta":{"concept-type":"granule","concept-id":"G1287941210-ASF" ...).Since I manage to connect through terminal, I assume that it is an issue with the Python library. Did I setup something wrong? Any idea on what could solve it? Thanks in advance!
I am working under python 3.12 with asf_search 9.0.2 (8.1.4 previously also triggered the error). I have also tried relaunching on a new environment with only asf, with no more sucess.