TypeError prevents downloading Sentinel-2 data through sentinelhub library

Hello !

I’m regularly using sentinelhub library, specifically I make use of the AwsTileRequest() class to regularly query and save on my disks specific Sentinel-2 L2A images from the AWS repository.

Since approximately 10 days, I have this error whichs occurs regularly but quite randomly when I launch the same script I always do :

Traceback (most recent call last):
File "<ipython-input-2-961ca4d497c3>", line 45, in download_aws_tile_L2A_basic
    tile_request = AwsTileRequest(
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/data_request.py", line 856, in __init__
    super().__init__(**kwargs)
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/data_request.py", line 758, in __init__
    super().__init__(AwsDownloadClient, **kwargs)
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/data_request.py", line 47, in __init__
    self.create_request()
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/data_request.py", line 860, in create_request
    self.aws_service = SafeTile(self.tile, self.time, self.aws_index, bands=self.bands,
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/aws_safe.py", line 166, in __init__
    super().__init__(*args, **kwargs)
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/aws.py", line 502, in __init__
    self.aws_index = self.get_aws_index()
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/aws.py", line 557, in get_aws_index
    tile_info_list = get_tile_info(self.tile_name, self.timestamp, all_tiles=True)
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/opensearch.py", line 61, in get_tile_info
    for tile_info in search_iter(start_date=start_date, end_date=end_date):
  File "/home/linguere/louise/miniconda3/envs/am-map-mini/lib/python3.8/site-packages/sentinelhub/opensearch.py", line 173, in search_iter
    for tile_info in response["features"]:
TypeError: string indices must be integers

I really don’t understand why this issue pops, sometimes for the same query its throws this error a couple of times and then I re-launch it later without changing anything and it runs normally. Please help me understand what is happening because it is becoming very time-consuming to query images now, thank you !

Hello,

Thank you for the question, can you please supply the code block that you are using. Then we can try and reproduce the error you are getting and help find a solution.

Thanks :slight_smile:

Thank you for your answer ! This is the script I use to get the error : :slight_smile:

# My function to download a specific Sentinel-2 image
def download_aws_tile_L2A_basic(tile_id: str, sensing_date: str, output_dir: str):
    metafiles = ['metadata', 'tileInfo', 'qi/MSK_CLOUDS_B00']
    tile_request = AwsTileRequest(
        tile=tile_id, # 'T35LQD'
        time=sensing_date, # '2016-12-16'
        data_collection=DataCollection.SENTINEL2_L2A,
        data_folder=output_dir,
        metafiles=metafiles,
        safe_format=True,
    )
    out_path = tile_request.get_filename_list()[0]
    tile_request.save_data(redownload=False, raise_download_errors=True)
    return out_path

# My main part
out_product = download_aws_tile_L2A_basic("T35MLT", "2019-03-15", my_output_dir)

Hi @jeanbon4012 ,

Due to some recent changes (such as switch in file extensions) the utilities of .aws module are only partially usable. We’ve decided to deprecate most of the functionalities of the .aws module and stop actively maintaining this module.

We’ve updated the AWS example notebook on workaround for issues, which should help you patch your scripts. It interacts with S3 more directly and is easier for you to adjust.

I also recommend to update the sentinelhub python package to the latest version 3.8.4 to ensure other functionalities works reliably. Hope this would help :slight_smile:

Hi @chung.horng, thank you for your feedback ! :slightly_smiling_face:

Ok, very sad to here that you are not maintaining this package but thanks for the precision.

The notebook is clear, however my script is exactly using the same request format as described in the latest sections on how to download Sentinel data, so I don’t really see how to upgrade it. Are you suggesting I should refacto all to use instead the method described in the 1st “warning” section ?

I wanted to add details on the TypeError issue:

  • I’m currently working with sentinelhub package version 3.4.2, and it’s hard to upgrade as my environment also relies on many other very sensitive dependencies… (I already tried and it broke my pipeline, so I reverted to previous state) ;
  • The TypeError issue is roughly happening for 50% of my requests ;
  • But it’s not a consistent error as sometimes I just have to re-run the command for a specific tile that raised the error yesterday, and the second time, no TypeError and the product is effectively downloaded… So it is very hard to debug sadly :smiling_face_with_tear:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.