PermafrostDiscoveryGateway / viz-points

Python package for post-processing point-cloud data for 3D visualization
Apache License 2.0
0 stars 1 forks source link

`os.rename` errors out with `FileNotFoundError` even though successful #7

Closed iannesbitt closed 1 year ago

iannesbitt commented 1 year ago

As referenced in #2, file archival process (here) succeeds in renaming the input file to the ./archive/ directory but throws the following error after doing so:

2023-04-11T18:30:02:INFO: Archiving input file to /home/shares/drp/pointcloud/archive/Site7.las
Traceback (most recent call last):
  File "/home/nesbitt/miniconda3/envs/workflow/bin/tilepoints", line 8, in <module>
    sys.exit(cli())
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/pdgpoints/cli.py", line 42, in cli
    p.run()
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/pdgpoints/pipeline.py", line 65, in run
    lastools_iface.las2las(f=self.f,
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/pdgpoints/lastools_iface.py", line 161, in las2las
    os.rename(str(f), str(archive_fn))
FileNotFoundError: [Errno 2] No such file or directory: '/home/shares/drp/pointcloud/Site7.las' -> '/home/shares/drp/pointcloud/archive/Site7.las'

Currently the workaround is an except FileNotFoundError. No documented issues with this online, so probably something to do with the setup on datateam. Still in search of a solution...

iannesbitt commented 1 year ago

Another instance of this problem pops up when using pathlib.Path(f).unlink() to remove a file. The process throws a FileNotFoundError even if the file exists and is deleted successfully.

2023-04-12T15:12:57:INFO: Starting merge process in 3dtiles
Traceback (most recent call last):
  File "/home/nesbitt/miniconda3/envs/workflow/bin/tilepoints", line 8, in <module>
    sys.exit(cli())
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/pdgpoints/cli.py", line 42, in cli
    p.run()
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/pdgpoints/pipeline.py", line 79, in run
    py3dtiles_iface.merge(dir=self.out_dir,
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/pdgpoints/py3dtiles_iface.py", line 54, in merge
    merger.merge_from_files(tileset_paths=paths,
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/py3dtiles/merger.py", line 277, in merge_from_files
    TileSet.from_file(output_tileset_path).delete_on_disk(
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/py3dtiles/tileset/tileset.py", line 102, in delete_on_disk
    self.root_tile.delete_on_disk(tileset_path.parent, delete_sub_tileset)
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/py3dtiles/tileset/tile.py", line 117, in delete_on_disk
    child.delete_on_disk(root_uri, delete_sub_tileset)
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/py3dtiles/tileset/tile.py", line 117, in delete_on_disk
    child.delete_on_disk(root_uri, delete_sub_tileset)
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/py3dtiles/tileset/tile.py", line 117, in delete_on_disk
    child.delete_on_disk(root_uri, delete_sub_tileset)
  [Previous line repeated 5 more times]
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/site-packages/py3dtiles/tileset/tile.py", line 132, in delete_on_disk
    tile_content_path.unlink()
  File "/home/nesbitt/miniconda3/envs/workflow/lib/python3.9/pathlib.py", line 1354, in unlink
    self._accessor.unlink(self)
FileNotFoundError: [Errno 2] No such file or directory: '/home/shares/drp/pointcloud/3dtiles/r.pnts'
iannesbitt commented 1 year ago

pathlib.Path(f).unlink(missing_ok=True) is a workaround but os.rename(f, f2) and pathlib.Path(f).rename(f2) still throw FileNotFoundError...

iannesbitt commented 1 year ago

This may be solved by recent changes; closing for now