Skip to content

Commit

Permalink
Add try catch to hopefully make robust to failing windows tests due t…
Browse files Browse the repository at this point in the history
…o intermittent premissions erors
  • Loading branch information
rosepearson committed Jun 20, 2024
1 parent cf92f2d commit 08cb1f2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/geofabrics/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,13 @@ def run(self):
self.raw_dem.save_and_load_dem(temp_file)

# Remove previous cached file and replace with new one
cached_file.unlink()
try:
cached_file.unlink()
except (Exception, PermissionError) as caught_exception:
logging.warning(f"Caught error {caught_exception} "
"during unlink of cached_file. "
"Supressing. You will have to "
"manually delete.")
cached_file = temp_file

# Add a coarse DEM if significant area without LiDAR and a coarse DEM
Expand Down Expand Up @@ -1014,7 +1020,13 @@ def run(self):
self.raw_dem.save_and_load_dem(temp_file)

# Remove previous cached file and replace with new one
cached_file.unlink()
try:
cached_file.unlink()
except (Exception, PermissionError) as caught_exception:
logging.warning(f"Caught error {caught_exception} "
"during unlink of cached_file. "
"Supressing. You will have to "
"manually delete.")
cached_file = temp_file

# compute and save raw DEM
Expand Down Expand Up @@ -1229,13 +1241,13 @@ def run(self):
generator=self.hydrologic_dem,
)
except (Exception, KeyboardInterrupt) as caught_exception:
pathlib.Path(self.get_instruction_path("result_dem")).unlink()
self.logger.info(
f"Caught error {caught_exception} and deleting"
"partially created netCDF output "
f"{self.get_instruction_path('result_dem')}"
" before re-raising error."
)
pathlib.Path(self.get_instruction_path("result_dem")).unlink()
raise caught_exception
if self.debug:
# Record the parameter used during execution - append to existing
Expand Down

0 comments on commit 08cb1f2

Please sign in to comment.