asfadmin / Discovery-asf_search

BSD 3-Clause "New" or "Revised" License
126 stars 43 forks source link

[Bug] Importing asf_search causes TypeError #220

Closed SeongjaeHong closed 11 months ago

SeongjaeHong commented 1 year ago

Describe the bug When you try to import asf_search, you get TypeError

To Reproduce

import asf_search as asf

Desktop (please complete the following information):

Error Context

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 import asf_search as asf

File ~\Anaconda3\envs\satcrawler\lib\site-packages\asf_search\__init__.py:29
     27 from .constants import *
     28 from .health import *
---> 29 from .search import *
     30 from .download import *
     31 from .CMR import *

File ~\Anaconda3\envs\satcrawler\lib\site-packages\asf_search\search\__init__.py:1
----> 1 from .search import search
      2 from .granule_search import granule_search
      3 from .product_search import product_search

File ~\Anaconda3\envs\satcrawler\lib\site-packages\asf_search\search\search.py:7
      5 from asf_search import ASFSearchResults
      6 from asf_search.ASFSearchOptions import ASFSearchOptions
----> 7 from asf_search.search.search_generator import search_generator
      9 def search(
     10         absoluteOrbit: Union[int, Tuple[int, int], Iterable[Union[int, Tuple[int, int]]]] = None,
     11         asfFrame: Union[int, Tuple[int, int], Iterable[Union[int, Tuple[int, int]]]] = None,
   (...)
     44         opts: ASFSearchOptions = None,
     45 ) -> ASFSearchResults:
     46     """
     47     Performs a generic search using the ASF SearchAPI. Accepts a number of search parameters, and/or an ASFSearchOptions object. If an ASFSearchOptions object is provided as well as other specific parameters, the two sets of options will be merged, preferring the specific keyword arguments.
     48 
   (...)
     82     :return: ASFSearchResults(list) of search results
     83     """

File ~\Anaconda3\envs\satcrawler\lib\site-packages\asf_search\search\search_generator.py:134
    129         raise CMRIncompleteError(f"CMR returned page of incomplete results. Expected {min(INTERNAL.CMR_PAGE_SIZE, hits - sub_query_count)} results, got {len(items)}")
    131     return items, hits, response.headers.get('CMR-Search-After', None)
--> 134 def process_page(items: list[ASFProduct], max_results: int, subquery_max_results: int, total: int, subquery_count: int, opts: ASFSearchOptions):
    135     if max_results is None:
    136         last_page = ASFSearchResults(items[:min(subquery_max_results - subquery_count, len(items))], opts=opts)

TypeError: 'type' object is not subscriptable
SpicyGarlicAlbacoreRoll commented 1 year ago

Thank you for reporting, this bug should be remedied with the latest patch release! https://github.com/asfadmin/Discovery-asf_search/releases/tag/v6.6.3