sertit / eoreader

Remote-sensing opensource python library reading optical and SAR sensors, loading and stacking bands, clouds, DEM and spectral indices in a sensor-agnostic way.
https://eoreader.readthedocs.io/en/latest/
Apache License 2.0
278 stars 22 forks source link

Path exception for Planet products #160

Closed jteulade closed 2 months ago

jteulade commented 3 months ago

For this product: s3://sertit-projects-archives/projects/2019/PREFER/Traitements/TEST_SITES/PORTUGAL/Images/RE/Traces/RE00_MSI_IMG_1B_20110301T120743_20110301T120751_BRB_13522_626f.ntf/2011-03-01T120749_RE3_1B-NAC_7083365_116771.tar I get this error:

Traceback (most recent call last):
  File "E:\JTeulade\repositories\stac\scripts\find_valid_product.py", line 33, in <module>
    path_products = get_path_products(PATH_TO_CRAWL)
  File "E:\JTeulade\repositories\stac\libs\sertit-utils\sertit\s3.py", line 99, in s3_env_wrapper
    return function(*_args, **_kwargs)
  File "E:\JTeulade\repositories\stac\stac\product.py", line 63, in get_path_products
    if all(d not in full_path.parts for d in BLACKLIST_DIRECTORIES) and check_product_and_fill_path(
  File "E:\JTeulade\repositories\stac\stac\product.py", line 103, in check_product_and_fill_path
    with Reader().open(path_to_check, remove_tmp=True) as prod:
  File "C:\Users\jteulade\AppData\Local\anaconda3\envs\arcgispro-eo\lib\contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "e:\jteulade\repositories\eoreader\eoreader\reader.py", line 540, in open
    prod = self._open_path(
  File "e:\jteulade\repositories\eoreader\eoreader\reader.py", line 706, in _open_path
    prod = create_product(
  File "e:\jteulade\repositories\eoreader\eoreader\reader.py", line 978, in create_product
    prod = class_(
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\planet_product.py", line 147, in __init__
    super().__init__(product_path, archive_path, output_path, remove_tmp, **kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\optical_product.py", line 116, in __init__
    super().__init__(product_path, archive_path, output_path, remove_tmp, **kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\products\product.py", line 268, in __init__
    self._post_init(**kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\re_product.py", line 125, in _post_init
    super()._post_init(**kwargs)
  File "e:\jteulade\repositories\eoreader\eoreader\products\optical\planet_product.py", line 207, in _post_init
    path.get_filename(self._get_stack_path(as_list=False)).upper().split("_")
  File "E:\JTeulade\repositories\stac\libs\sertit-utils\sertit\path.py", line 314, in get_filename
    file_path = AnyPath(file_path)
  File "C:\Users\jteulade\AppData\Local\anaconda3\envs\arcgispro-eo\lib\site-packages\cloudpathlib\anypath.py", line 27, in __new__
    raise AnyPathTypeError(
cloudpathlib.exceptions.AnyPathTypeError: Invalid input for both CloudPath and Path. CloudPath exception: InvalidPrefixError("Path [] does not begin with a known prefix ['az://', 's3://', 'gs://'].") Path exception: TypeError('expected str, bytes or os.PathLike object, not list')

If we extract this archive we get a more coherent error: NotImplementedError: Basic Scene Product are not managed for RapidEye products:

This is due to this code

If it's an archive, the regex is case sensitive, otherwise the glob is not.

Solutions: