From c8e595597166cb566b29a885079ddd1ea6bbaec0 Mon Sep 17 00:00:00 2001 From: Mostafa Gomaa Daoud <54531356+MostafaGomaa93@users.noreply.github.com> Date: Fri, 23 Aug 2024 14:18:27 +0200 Subject: [PATCH 1/2] Update comment in line 127 Co-authored-by: SarahAlidoost <55081872+SarahAlidoost@users.noreply.github.com> --- PyStemmusScope/config_io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyStemmusScope/config_io.py b/PyStemmusScope/config_io.py index 81abccca..f7b6f095 100644 --- a/PyStemmusScope/config_io.py +++ b/PyStemmusScope/config_io.py @@ -124,7 +124,7 @@ def _copy_data(input_dir: Path, config: dict) -> None: str(config[folder]), str(input_dir / folder), dirs_exist_ok=True ) - # copy input_data.xlsx and input_soilLayThick.csv + # copy input_data.xlsx shutil.copy(str(config["input_data"]), str(input_dir)) soilLay_file = Path(str(config["input_data"]).replace("input_data.xlsx", "input_soilLayThick.csv")) if soilLay_file.exists(): From ed456c35c2176435e8a75603e430f361c4abbf56 Mon Sep 17 00:00:00 2001 From: Mostafa Gomaa Daoud <54531356+MostafaGomaa93@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:01:31 +0200 Subject: [PATCH 2/2] Add a key for optional soil thickness layer csv file Co-authored-by: SarahAlidoost <55081872+SarahAlidoost@users.noreply.github.com> --- PyStemmusScope/config_io.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/PyStemmusScope/config_io.py b/PyStemmusScope/config_io.py index f7b6f095..88c96c45 100644 --- a/PyStemmusScope/config_io.py +++ b/PyStemmusScope/config_io.py @@ -126,9 +126,16 @@ def _copy_data(input_dir: Path, config: dict) -> None: # copy input_data.xlsx shutil.copy(str(config["input_data"]), str(input_dir)) - soilLay_file = Path(str(config["input_data"]).replace("input_data.xlsx", "input_soilLayThick.csv")) - if soilLay_file.exists(): - shutil.copy(soilLay_file, str(input_dir)) + # copy soil_layers_thickness, this is optional + if "soil_layers_thickness" in config: + if Path(config["soil_layers_thickness"]).is_file(): + shutil.copy(str(config["soil_layers_thickness"]), str(input_dir)) + else: + raise FileNotFoundError( + "The key `soil_layers_thickness` is provided in the config file, " + f"but file {config['soil_layers_thickness']} not found. " + "Remove the key from the config file or provide the file." + ) def _update_config_file( input_dir: Path,