Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make deleting run output optional #549

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flood_adapt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

FloodAdaptLogging() # Initialize logging once for the entire package


__version__ = "0.1.1"

# this will be a part of Settings() when that PR is merged (https://github.com/Deltares-research/FloodAdapt/pull/546)
# Set this to False to disable the deletion of crashed/corrupted runs.
DELETE_CRASHED_RUNS = True
8 changes: 0 additions & 8 deletions flood_adapt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,3 @@ def parse_user_input(

if any(val is not None for val in [database_root, system_folder, database_name]):
print("Parsed user input successfully")


def main() -> None:
pass


if __name__ == "__main__":
main()
4 changes: 4 additions & 0 deletions flood_adapt/dbs_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from cht_cyclones.tropical_cyclone import TropicalCyclone
from geopandas import GeoDataFrame

from flood_adapt import DELETE_CRASHED_RUNS
from flood_adapt.dbs_classes.dbs_benefit import DbsBenefit
from flood_adapt.dbs_classes.dbs_event import DbsEvent
from flood_adapt.dbs_classes.dbs_measure import DbsMeasure
Expand Down Expand Up @@ -1036,6 +1037,9 @@ def cleanup(self) -> None:
- does not have a corresponding input

"""
if not DELETE_CRASHED_RUNS:
return

scn_input_path = self.scenarios.get_database_path()
scn_output_path = self.scenarios.get_database_path(get_input_path=False)
if not scn_output_path.is_dir():
Expand Down
3 changes: 2 additions & 1 deletion flood_adapt/object_model/hazard/hazard.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from numpy import matlib

import flood_adapt.config as FloodAdapt_config
from flood_adapt import DELETE_CRASHED_RUNS
from flood_adapt.integrator.sfincs_adapter import SfincsAdapter
from flood_adapt.log import FloodAdaptLogging
from flood_adapt.object_model.hazard.event.event import Event
Expand Down Expand Up @@ -289,7 +290,7 @@ def run_sfincs(self):
run_success = False
break

if not run_success:
if DELETE_CRASHED_RUNS and not run_success:
# Remove all files in the simulation folder except for the log files
for simulation_path in self.simulation_paths:
for subdir, _, files in os.walk(simulation_path):
Expand Down
Loading