From ce0ce46cf25bcd5a23fab5cd21920a5b7c6509cb Mon Sep 17 00:00:00 2001 From: hellkite500 Date: Tue, 25 Apr 2023 15:26:15 -0600 Subject: [PATCH] fix path handling for routing test --- test/CMakeLists.txt | 1 + .../routing/ngen_routing_config_unit_test.yaml | 16 ++++++++-------- test/routing/Routing_Py_Bind_Test.cpp | 9 +++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 78b7e0920a..722da840d2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -285,6 +285,7 @@ if(NGEN_ACTIVATE_ROUTING) test_routing_pybind 1 routing/Routing_Py_Bind_Test.cpp + NGen::core # for filechecker utility NGen::routing pybind11::embed ) diff --git a/test/data/routing/ngen_routing_config_unit_test.yaml b/test/data/routing/ngen_routing_config_unit_test.yaml index 80f4a40aba..a93eaf5c05 100644 --- a/test/data/routing/ngen_routing_config_unit_test.yaml +++ b/test/data/routing/ngen_routing_config_unit_test.yaml @@ -9,7 +9,7 @@ network_topology_parameters: supernetwork_parameters: #---------- geo_file_type: HYFeaturesNetwork - geo_file_path: ./test/data/routing/gauge_01073000.gpkg + geo_file_path: ../../test/data/routing/gauge_01073000.gpkg mask_file_path: # domain/unit_test_noRS/coastal_subset.txt synthetic_wb_segments: #- 4800002 @@ -21,8 +21,8 @@ network_topology_parameters: break_network_at_waterbodies: False level_pool: #---------- - level_pool_waterbody_parameter_file_path: ./test/data/routing/gauge_01073000.gpkg - reservoir_parameter_file : ./test/data/routing/gauge_01073000.gpkg + level_pool_waterbody_parameter_file_path: ../../test/data/routing/gauge_01073000.gpkg + reservoir_parameter_file : ../../test/data/routing/gauge_01073000.gpkg #rfc: #---------- #reservoir_parameter_file : domain/reservoir_index_AnA.nc @@ -58,11 +58,11 @@ compute_parameters: #---------- qts_subdivisions : 12 dt : 300 # [sec] - qlat_input_folder : ./test/data/routing/ + qlat_input_folder : ../../test/data/routing/ qlat_file_pattern_filter : "nex-*" - nexus_input_folder : ./test/data/routing/ + nexus_input_folder : ../../test/data/routing/ nexus_file_pattern_filter : "nex-*" #OR "*NEXOUT.parquet" OR "nex-*" - binary_nexus_file_folder : ./test/data/routing/ # this is required if nexus_file_pattern_filter="nex-*" + binary_nexus_file_folder : ../../test/data/routing/ # this is required if nexus_file_pattern_filter="nex-*" #coastal_boundary_input_file : channel_forcing/schout_1.nc nts : 8640 #288 for 1day max_loop_size : 720 # [hr] @@ -98,6 +98,6 @@ output_parameters: #wrf_hydro_channel_output_source_folder: ./ chanobs_output: #---------- - chanobs_output_directory: ./test/data/routing/ + chanobs_output_directory: ../../test/data/routing/ chanobs_filepath : Chanobs.nc - lakeout_output: ./test/data/routing/ + lakeout_output: ../../test/data/routing/ diff --git a/test/routing/Routing_Py_Bind_Test.cpp b/test/routing/Routing_Py_Bind_Test.cpp index 2831368e5d..a89da36c9a 100644 --- a/test/routing/Routing_Py_Bind_Test.cpp +++ b/test/routing/Routing_Py_Bind_Test.cpp @@ -1,6 +1,7 @@ #ifdef ROUTING_PYBIND_TESTS_ACTIVE #include "gtest/gtest.h" #include "Routing_Py_Adapter.hpp" +#include "FileChecker.h" #include #include #include @@ -33,8 +34,12 @@ TEST_F(RoutingPyBindTest, TestRoutingPyBind) //std::vector nexus_values_vec{1.1, 2.2, 3.3, 4.4, 5.5}; //SET THESE AS INPUTS - std::string t_route_config_file_with_path = "./test/data/routing/ngen_routing_config_unit_test.yaml"; - + std::vector paths = { + "./test/data/routing/ngen_routing_config_unit_test.yaml", + "../test/data/routing/ngen_routing_config_unit_test.yaml", + "../../test/data/routing/ngen_routing_config_unit_test.yaml" + }; + std::string t_route_config_file_with_path = utils::FileChecker::find_first_readable(paths); //Note: Currently, delta_time is set in the t-route yaml configuration file, and the //number_of_timesteps is determined from the total number of nexus outputs in t-rout //It is recommended to still pass these values to the routing_py_adapter object in