stac-utils / stactools

Command line utility and Python library for STAC
https://stactools.readthedocs.io/
Other
104 stars 28 forks source link

STAC Copy not working for new installations #464

Closed baloola closed 11 months ago

baloola commented 11 months ago

running copy command fails, due to not finding the target file. The issue is pretty much the same as #168

To reproduce new stactools installation, ( with new installation for dependencies -e.g docker images-), then trying copy command

Screenshots and shell session dumps

Traceback (most recent call last):                                                                                                 
  File "/usr/local/bin/stac", line 8, in <module>                                                                                  
    sys.exit(run_cli())                                                                                                            
  File "/usr/local/lib/python3.10/dist-packages/stactools/cli/cli.py", line 37, in run_cli                                         
    cli(prog_name="stac")
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/stactools/cli/commands/copy.py", line 108, in copy_command
    copy_catalog(
  File "/usr/local/lib/python3.10/dist-packages/stactools/core/copy.py", line 297, in copy_catalog
    catalog.save(catalog_type, dest_directory)
  File "/usr/local/lib/python3.10/dist-packages/pystac/catalog.py", line 962, in save
    item.save_object(
  File "/usr/local/lib/python3.10/dist-packages/pystac/stac_object.py", line 476, in save_object
    stac_io.save_json(dest_href, self.to_dict(include_self_link=include_self_link))
  File "/usr/local/lib/python3.10/dist-packages/pystac/stac_io.py", line 260, in save_json
    self.write_text(dest, txt)
  File "/usr/local/lib/python3.10/dist-packages/stactools/core/io/__init__.py", line 94, in write_text
    return self.write_text_to_href(href, txt, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/stactools/core/io/__init__.py", line 112, in write_text_to_href
    with fsspec.open(href, "w", **kwargs) as destination:
  File "/usr/local/lib/python3.10/dist-packages/fsspec/core.py", line 102, in __enter__
    f = self.fs.open(self.path, mode=mode)
  File "/usr/local/lib/python3.10/dist-packages/fsspec/spec.py", line 1309, in open
    f = self._open(
  File "/usr/local/lib/python3.10/dist-packages/fsspec/implementations/local.py", line 180, in _open
    return LocalFileOpener(path, mode, fs=self, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/fsspec/implementations/local.py", line 298, in __init__
    self._open()
  File "/usr/local/lib/python3.10/dist-packages/fsspec/implementations/local.py", line 303, in _open
    self.f = open(self.path, mode=self.mode)
FileNotFoundError: [Errno 2] No such file or directory: '/out/SENTINEL2_L2A_MOSAIC_120/SENTINEL2_L2A_MOSAIC_120.json'

Additional context I did confirm that using fsspec version 2023.9.0 the issue does not happen, while installing lates release (2023.9.1) will cause the issue.

jsignell commented 11 months ago

I think this is solved by #463 so should be fixed in the next release.

gadomski commented 11 months ago

Hey, looks like we should release! I'll cook one up.

gadomski commented 11 months ago

Release v0.5.2: https://github.com/stac-utils/stactools/releases/tag/v0.5.2. @baloola can you update and check to see if your issue is fixed?

baloola commented 11 months ago

@gadomski I've tested the new release on a docker image( ubuntu:22.04), and on a github workflow instance, and both works just fine. thank a lot :)