From 08b5b9f5aadd312fb9b12d9b2c3a1024eeab0d43 Mon Sep 17 00:00:00 2001 From: Maxime N Date: Thu, 19 Sep 2024 09:46:19 +0200 Subject: [PATCH 1/8] #61: Create config validator class --- bindings/python/config_validator.cc | 17 ++++++++ bindings/python/config_validator.h | 62 +++++++++++++++++++++++++++++ bindings/python/tv.cc | 11 +++++ tests/test_bindings.py | 37 ++++++++++------- 4 files changed, 112 insertions(+), 15 deletions(-) create mode 100644 bindings/python/config_validator.cc create mode 100644 bindings/python/config_validator.h diff --git a/bindings/python/config_validator.cc b/bindings/python/config_validator.cc new file mode 100644 index 0000000000..3762ba9b4f --- /dev/null +++ b/bindings/python/config_validator.cc @@ -0,0 +1,17 @@ +#include "config_validator.h" + +namespace vt::tv::bindings::python { + + bool ConfigValidator::isValid() + { + bool is_valid = true; + for (std::string requiredParameter: requiredParameters) { + if (!config[requiredParameter]) { + is_valid = false; + break; + } + } + return is_valid; + } + +} /* end namespace vt::tv::bindings::python */ diff --git a/bindings/python/config_validator.h b/bindings/python/config_validator.h new file mode 100644 index 0000000000..b958e8af9a --- /dev/null +++ b/bindings/python/config_validator.h @@ -0,0 +1,62 @@ +/* +//@HEADER +// ***************************************************************************** +// +// config_validator.h +// DARMA/vt-tv => Virtual Transport -- Task Visualizer +// +// Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact darma@sandia.gov +// +// ***************************************************************************** +//@HEADER +*/ +// A2DD.h +#ifndef vt_tv_config_validator_h +#define vt_tv_config_validator_h + +#include + +namespace vt::tv::bindings::python { + class ConfigValidator + { + public: + std::array requiredParameters = {"output_visualization_dir", "output_visualization_file_stem"}; + YAML::Node config; + bool isValid(); + ConfigValidator(YAML::Node configData) { + config = configData; + } + }; +} + +#endif diff --git a/bindings/python/tv.cc b/bindings/python/tv.cc index 3558fa631c..2f45948db8 100644 --- a/bindings/python/tv.cc +++ b/bindings/python/tv.cc @@ -1,4 +1,5 @@ #include "tv.h" +#include "config_validator.h" namespace vt::tv::bindings::python { @@ -16,7 +17,17 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const try { // Load the configuration from serialized YAML YAML::Node viz_config = YAML::Load(input_yaml_params_str); + + // Config Validator + ConfigValidator config_validator(viz_config); + // Check configuration + bool is_config_valid = config_validator.isValid(); + + // Throw error if configuration is not valid + if (!is_config_valid) { + throw std::runtime_error("The YML configuration file is not valid: missing required paramaters "); + } std::array qoi_request = { viz_config["rank_qoi"].as(), diff --git a/tests/test_bindings.py b/tests/test_bindings.py index d3fffcf0df..a9a50aaa10 100644 --- a/tests/test_bindings.py +++ b/tests/test_bindings.py @@ -1,33 +1,40 @@ +'''TESTS BINDING''' + +import os import json import yaml -import vttv -import sys -import os +import vttv # source dir is the directory a level above this file source_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) with open(f'{source_dir}/tests/test_bindings_conf.yaml', 'r') as stream: - try: - params = yaml.safe_load(stream) - except yaml.YAMLError as exc: - print(exc) + try: + params = yaml.safe_load(stream) + except yaml.YAMLError as exc: + print(exc) # make output_visualization_dir directory parameter absolute -params["visualization"]["output_visualization_dir"] = os.path.abspath(params["visualization"]["output_visualization_dir"]) +if 'visualization' in params and 'output_visualization_dir' in params["visualization"]: + params["visualization"]["output_visualization_dir"] = os.path.abspath( + params["visualization"]["output_visualization_dir"] + ) params_serialized = yaml.dump(params["visualization"]) -n_ranks = params["visualization"]["x_ranks"] * params["visualization"]["y_ranks"] * params["visualization"]["z_ranks"] -rank_data = [] +n_ranks = params["visualization"]["x_ranks"] +n_ranks *= params["visualization"]["y_ranks"] +n_ranks *= params["visualization"]["z_ranks"] +# Prepare rank data +rank_data = [] for rank in range(n_ranks): - with open(f'{source_dir}/data/lb_test_data/data.{rank}.json', 'r') as f: - data = json.load(f) - - data_serialized = json.dumps(data) + with open(f'{source_dir}/data/lb_test_data/data.{rank}.json', 'r') as f: + data = json.load(f) - rank_data.append((data_serialized)) + data_serialized = json.dumps(data) + rank_data.append((data_serialized)) +# Launch vttv.tvFromJson(rank_data, params_serialized, n_ranks) From 2777478cd6c9e28b288431b7413d33166c33274e Mon Sep 17 00:00:00 2001 From: Maxime N Date: Thu, 19 Sep 2024 10:25:43 +0200 Subject: [PATCH 2/8] #61: Add the list of missing parameters into the error message --- bindings/python/config_validator.cc | 28 ++++++++++++++++++++++++++++ bindings/python/config_validator.h | 4 ++++ bindings/python/tv.cc | 2 +- tests/test_bindings.py | 9 ++++++++- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/bindings/python/config_validator.cc b/bindings/python/config_validator.cc index 3762ba9b4f..cf300be4c2 100644 --- a/bindings/python/config_validator.cc +++ b/bindings/python/config_validator.cc @@ -2,6 +2,11 @@ namespace vt::tv::bindings::python { + /** + * Check if the configuration file is valid + * + * @return true if the configuration is valid + */ bool ConfigValidator::isValid() { bool is_valid = true; @@ -14,4 +19,27 @@ namespace vt::tv::bindings::python { return is_valid; } + + /** + * Get the list of missing parameters + * + * @return A string containing the list of the missing parameters + */ + std::string ConfigValidator::getMissingRequiredParameters() + { + int i = 0; + std::string parameters; + for (std::string requiredParameter: requiredParameters) { + if (!config[requiredParameter]) { + if (i == 0 ) { + parameters = parameters + requiredParameter; + } else { + parameters = parameters + ", " + requiredParameter; + } + i++; + } + } + return parameters; + } + } /* end namespace vt::tv::bindings::python */ diff --git a/bindings/python/config_validator.h b/bindings/python/config_validator.h index b958e8af9a..f4bf420b6d 100644 --- a/bindings/python/config_validator.h +++ b/bindings/python/config_validator.h @@ -47,12 +47,16 @@ #include namespace vt::tv::bindings::python { + /** + * ConfiValidator Class + */ class ConfigValidator { public: std::array requiredParameters = {"output_visualization_dir", "output_visualization_file_stem"}; YAML::Node config; bool isValid(); + std::string getMissingRequiredParameters(); ConfigValidator(YAML::Node configData) { config = configData; } diff --git a/bindings/python/tv.cc b/bindings/python/tv.cc index 2f45948db8..0c1794d6ac 100644 --- a/bindings/python/tv.cc +++ b/bindings/python/tv.cc @@ -26,7 +26,7 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const // Throw error if configuration is not valid if (!is_config_valid) { - throw std::runtime_error("The YML configuration file is not valid: missing required paramaters "); + throw std::runtime_error("The YAML configuration file is not valid: missing required paramaters: " + config_validator.getMissingRequiredParameters()); } std::array qoi_request = { diff --git a/tests/test_bindings.py b/tests/test_bindings.py index a9a50aaa10..5e33758c2f 100644 --- a/tests/test_bindings.py +++ b/tests/test_bindings.py @@ -3,20 +3,27 @@ import os import json import yaml +import sys import vttv # source dir is the directory a level above this file source_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +# Read the YAML config file with open(f'{source_dir}/tests/test_bindings_conf.yaml', 'r') as stream: try: params = yaml.safe_load(stream) except yaml.YAMLError as exc: print(exc) +# Check main key is "visualization" +if 'visualization' not in params: + print("The YAML configuration file is not valid: missing required paramaters: visualization") + sys.exit(1) + # make output_visualization_dir directory parameter absolute -if 'visualization' in params and 'output_visualization_dir' in params["visualization"]: +if 'output_visualization_dir' in params["visualization"]: params["visualization"]["output_visualization_dir"] = os.path.abspath( params["visualization"]["output_visualization_dir"] ) From 7c7b17ab3caeb5d205a1bdc42bee753e1f964f21 Mon Sep 17 00:00:00 2001 From: Maxime N Date: Thu, 19 Sep 2024 10:35:17 +0200 Subject: [PATCH 3/8] #61: fix whitespaces --- bindings/python/config_validator.cc | 6 +++--- bindings/python/tv.cc | 2 +- tests/test_bindings.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bindings/python/config_validator.cc b/bindings/python/config_validator.cc index cf300be4c2..3b58c45d7a 100644 --- a/bindings/python/config_validator.cc +++ b/bindings/python/config_validator.cc @@ -23,7 +23,7 @@ namespace vt::tv::bindings::python { /** * Get the list of missing parameters * - * @return A string containing the list of the missing parameters + * @return A string containing the list of the missing parameters */ std::string ConfigValidator::getMissingRequiredParameters() { @@ -32,9 +32,9 @@ namespace vt::tv::bindings::python { for (std::string requiredParameter: requiredParameters) { if (!config[requiredParameter]) { if (i == 0 ) { - parameters = parameters + requiredParameter; + parameters = parameters + requiredParameter; } else { - parameters = parameters + ", " + requiredParameter; + parameters = parameters + ", " + requiredParameter; } i++; } diff --git a/bindings/python/tv.cc b/bindings/python/tv.cc index 0c1794d6ac..9986dbc2b7 100644 --- a/bindings/python/tv.cc +++ b/bindings/python/tv.cc @@ -17,7 +17,7 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const try { // Load the configuration from serialized YAML YAML::Node viz_config = YAML::Load(input_yaml_params_str); - + // Config Validator ConfigValidator config_validator(viz_config); diff --git a/tests/test_bindings.py b/tests/test_bindings.py index 5e33758c2f..92b78a23a7 100644 --- a/tests/test_bindings.py +++ b/tests/test_bindings.py @@ -10,7 +10,7 @@ # source dir is the directory a level above this file source_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -# Read the YAML config file +# Read the YAML config file with open(f'{source_dir}/tests/test_bindings_conf.yaml', 'r') as stream: try: params = yaml.safe_load(stream) From eac4268a23f518c5c112767a621361956bcd42da Mon Sep 17 00:00:00 2001 From: Maxime N Date: Thu, 19 Sep 2024 13:51:23 +0200 Subject: [PATCH 4/8] #61: Apply reviews --- bindings/python/config_validator.h | 2 +- bindings/python/tv.cc | 2 +- tests/test_bindings.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/python/config_validator.h b/bindings/python/config_validator.h index f4bf420b6d..b6d105335a 100644 --- a/bindings/python/config_validator.h +++ b/bindings/python/config_validator.h @@ -5,7 +5,7 @@ // config_validator.h // DARMA/vt-tv => Virtual Transport -- Task Visualizer // -// Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC +// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC // (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. // Government retains certain rights in this software. // diff --git a/bindings/python/tv.cc b/bindings/python/tv.cc index 9986dbc2b7..c0a74c8a14 100644 --- a/bindings/python/tv.cc +++ b/bindings/python/tv.cc @@ -24,7 +24,7 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const // Check configuration bool is_config_valid = config_validator.isValid(); - // Throw error if configuration is not valid + // Throw error if configuration is invalid if (!is_config_valid) { throw std::runtime_error("The YAML configuration file is not valid: missing required paramaters: " + config_validator.getMissingRequiredParameters()); } diff --git a/tests/test_bindings.py b/tests/test_bindings.py index 92b78a23a7..2c88bafb93 100644 --- a/tests/test_bindings.py +++ b/tests/test_bindings.py @@ -2,8 +2,8 @@ import os import json -import yaml import sys +import yaml import vttv @@ -18,12 +18,12 @@ print(exc) # Check main key is "visualization" -if 'visualization' not in params: +if "visualization" not in params: print("The YAML configuration file is not valid: missing required paramaters: visualization") sys.exit(1) # make output_visualization_dir directory parameter absolute -if 'output_visualization_dir' in params["visualization"]: +if "output_visualization_dir" in params["visualization"]: params["visualization"]["output_visualization_dir"] = os.path.abspath( params["visualization"]["output_visualization_dir"] ) @@ -43,5 +43,5 @@ data_serialized = json.dumps(data) rank_data.append((data_serialized)) -# Launch +# Launch VT TV from JSON data vttv.tvFromJson(rank_data, params_serialized, n_ranks) From c85eea9e2ea0aa3b37866fd5152976e4aab2a29e Mon Sep 17 00:00:00 2001 From: Maxime N Date: Tue, 24 Sep 2024 11:27:47 +0200 Subject: [PATCH 5/8] #61: Apply reviews --- bindings/python/config_validator.cc | 4 ++-- bindings/python/config_validator.h | 9 ++++----- tests/test_bindings.py | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bindings/python/config_validator.cc b/bindings/python/config_validator.cc index 3b58c45d7a..1650a41dbc 100644 --- a/bindings/python/config_validator.cc +++ b/bindings/python/config_validator.cc @@ -10,7 +10,7 @@ namespace vt::tv::bindings::python { bool ConfigValidator::isValid() { bool is_valid = true; - for (std::string requiredParameter: requiredParameters) { + for (std::string requiredParameter: required_parameters) { if (!config[requiredParameter]) { is_valid = false; break; @@ -29,7 +29,7 @@ namespace vt::tv::bindings::python { { int i = 0; std::string parameters; - for (std::string requiredParameter: requiredParameters) { + for (std::string requiredParameter: required_parameters) { if (!config[requiredParameter]) { if (i == 0 ) { parameters = parameters + requiredParameter; diff --git a/bindings/python/config_validator.h b/bindings/python/config_validator.h index b6d105335a..6ceb938590 100644 --- a/bindings/python/config_validator.h +++ b/bindings/python/config_validator.h @@ -48,18 +48,17 @@ namespace vt::tv::bindings::python { /** - * ConfiValidator Class + * ConfigValidator Class */ class ConfigValidator { public: - std::array requiredParameters = {"output_visualization_dir", "output_visualization_file_stem"}; + std::array required_parameters = {"output_visualization_dir", "output_visualization_file_stem"}; YAML::Node config; bool isValid(); std::string getMissingRequiredParameters(); - ConfigValidator(YAML::Node configData) { - config = configData; - } + ConfigValidator(YAML::Node in_config) + :config(in_config) {} }; } diff --git a/tests/test_bindings.py b/tests/test_bindings.py index 2c88bafb93..49dac55085 100644 --- a/tests/test_bindings.py +++ b/tests/test_bindings.py @@ -1,4 +1,4 @@ -'''TESTS BINDING''' +"""TEST BINDINGS""" import os import json @@ -11,7 +11,7 @@ source_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Read the YAML config file -with open(f'{source_dir}/tests/test_bindings_conf.yaml', 'r') as stream: +with open(f'{source_dir}/tests/test_bindings_conf.yaml', 'r', encoding="UTF-8") as stream: try: params = yaml.safe_load(stream) except yaml.YAMLError as exc: @@ -37,7 +37,7 @@ # Prepare rank data rank_data = [] for rank in range(n_ranks): - with open(f'{source_dir}/data/lb_test_data/data.{rank}.json', 'r') as f: + with open(f'{source_dir}/data/lb_test_data/data.{rank}.json', 'r', encoding="UTF-8") as f: data = json.load(f) data_serialized = json.dumps(data) From 5c68eb5755e4dae3db135d82da96efccce2f1cf0 Mon Sep 17 00:00:00 2001 From: Maxime N Date: Tue, 24 Sep 2024 11:29:28 +0200 Subject: [PATCH 6/8] #61: Apply reviews --- bindings/python/config_validator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/config_validator.h b/bindings/python/config_validator.h index 6ceb938590..362bfac230 100644 --- a/bindings/python/config_validator.h +++ b/bindings/python/config_validator.h @@ -57,7 +57,7 @@ namespace vt::tv::bindings::python { YAML::Node config; bool isValid(); std::string getMissingRequiredParameters(); - ConfigValidator(YAML::Node in_config) + ConfigValidator(YAML::Node in_config) :config(in_config) {} }; } From 48f7aee8c4642b46cb2a6f99914a001da18fea7d Mon Sep 17 00:00:00 2001 From: Maxime N Date: Fri, 27 Sep 2024 14:27:09 +0200 Subject: [PATCH 7/8] #61: Apply TD reviews --- bindings/python/config_validator.cc | 16 ++++----- bindings/python/config_validator.h | 1 - bindings/python/tv.cc | 52 ++++++++++++++++++----------- tests/test_bindings.py | 13 +++++--- 4 files changed, 47 insertions(+), 35 deletions(-) diff --git a/bindings/python/config_validator.cc b/bindings/python/config_validator.cc index 1650a41dbc..c9066b4ebf 100644 --- a/bindings/python/config_validator.cc +++ b/bindings/python/config_validator.cc @@ -10,8 +10,8 @@ namespace vt::tv::bindings::python { bool ConfigValidator::isValid() { bool is_valid = true; - for (std::string requiredParameter: required_parameters) { - if (!config[requiredParameter]) { + for (std::string parameter: required_parameters) { + if (!config[parameter]) { is_valid = false; break; } @@ -27,16 +27,14 @@ namespace vt::tv::bindings::python { */ std::string ConfigValidator::getMissingRequiredParameters() { - int i = 0; std::string parameters; - for (std::string requiredParameter: required_parameters) { - if (!config[requiredParameter]) { - if (i == 0 ) { - parameters = parameters + requiredParameter; + for (std::string parameter: required_parameters) { + if (!config[parameter]) { + if (parameters.empty()) { + parameters = parameter; } else { - parameters = parameters + ", " + requiredParameter; + parameters = parameters + ", " + parameter; } - i++; } } return parameters; diff --git a/bindings/python/config_validator.h b/bindings/python/config_validator.h index 362bfac230..8354180bb7 100644 --- a/bindings/python/config_validator.h +++ b/bindings/python/config_validator.h @@ -40,7 +40,6 @@ // ***************************************************************************** //@HEADER */ -// A2DD.h #ifndef vt_tv_config_validator_h #define vt_tv_config_validator_h diff --git a/bindings/python/tv.cc b/bindings/python/tv.cc index aaafa8f33f..331fe638f8 100644 --- a/bindings/python/tv.cc +++ b/bindings/python/tv.cc @@ -4,19 +4,25 @@ namespace vt::tv::bindings::python { void tvFromJson(const std::vector& input_json_per_rank_list, const std::string& input_yaml_params_str, uint64_t num_ranks) { - std::string startup_logo = std::string(" __ __\n") - + std::string(" _ __/ /_ / /__ __\n") - + std::string("| | / / __/ _____ / __/ | / /\n") - + std::string("| |/ / / /____/ / /_ | |/ /\n") - + std::string("|___/\\__/ \\__/ |___/\n"); - fmt::print("==============================\n"); - fmt::print(startup_logo); - fmt::print("==============================\n"); - - // parse the input yaml parameters - try { - // Load the configuration from serialized YAML - YAML::Node viz_config = YAML::Load(input_yaml_params_str); + std::string startup_logo = std::string(" __ __\n") + + std::string(" _ __/ /_ / /__ __\n") + + std::string("| | / / __/ _____ / __/ | / /\n") + + std::string("| |/ / / /____/ / /_ | |/ /\n") + + std::string("|___/\\__/ \\__/ |___/\n"); + fmt::print("==============================\n"); + fmt::print(startup_logo); + fmt::print("==============================\n"); + + YAML::Node viz_config; + try { + // Load the configuration from serialized YAML + viz_config = YAML::Load(input_yaml_params_str); + } catch (std::exception const& e) { + throw std::runtime_error(fmt::format( + "vt-tv: Error reading the configuration file: {}", + e.what() + )); + } // Config Validator ConfigValidator config_validator(viz_config); @@ -26,7 +32,10 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const // Throw error if configuration is invalid if (!is_config_valid) { - throw std::runtime_error("The YAML configuration file is not valid: missing required paramaters: " + config_validator.getMissingRequiredParameters()); + throw std::runtime_error(fmt::format( + "vt-tv: Error validating the configuration file: {}", + config_validator.getMissingRequiredParameters() + )); } std::array qoi_request = { @@ -52,10 +61,16 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const // Throw an error if the output directory does not exist or is not absolute if (!std::filesystem::exists(output_path)) { - throw std::runtime_error(fmt::format("Visualization output directory does not exist at {}", output_dir)); + throw std::runtime_error(fmt::format( + "vt-tv: Visualization output directory does not exist at {}", + output_dir + )); } if (!output_path.is_absolute()) { - throw std::runtime_error("Visualization output directory must be absolute."); + throw std::runtime_error(fmt::format( + "vt-tv: Visualization output directory must be absolute: {}", + output_dir + )); } // append / to avoid problems with file stems @@ -134,11 +149,8 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const output_dir, output_file_stem, 1.0, save_meshes, save_pngs, std::numeric_limits::max() ); render.generate(font_size, win_size); - } catch (std::exception const& e) { - throw std::runtime_error(fmt::format("vt-tv: Error reading the configuration file: {}", e.what())); - } - fmt::print("vt-tv: Done.\n"); + fmt::print("vt-tv: Done.\n"); } namespace nb = nanobind; diff --git a/tests/test_bindings.py b/tests/test_bindings.py index 4113b2235a..bbbffc2a2a 100644 --- a/tests/test_bindings.py +++ b/tests/test_bindings.py @@ -9,7 +9,7 @@ source_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Read the YAML config file -with open(f'{source_dir}/tests/test_bindings_conf.yaml', 'r', encoding='utf-8') as stream: +with open(f"{source_dir}/tests/test_bindings_conf.yaml", "r", encoding="utf-8") as stream: try: params = yaml.safe_load(stream) except yaml.YAMLError as exc: @@ -17,7 +17,10 @@ # Check main key is "visualization" if "visualization" not in params: - print("The YAML configuration file is not valid: missing required paramaters: visualization") + print( + "The YAML configuration file is not valid: "+\ + "missing required paramater \"visualization\"" + ) sys.exit(1) # make output_visualization_dir directory parameter absolute @@ -29,16 +32,16 @@ # Serialize visualization parameters params_serialized = yaml.dump(params["visualization"]) -# Calcul n_ranks +# Calculate n_ranks n_ranks = params["visualization"]["x_ranks"] * \ params["visualization"]["y_ranks"] * params["visualization"]["z_ranks"] rank_data = [] for rank in range(n_ranks): - with open(f'{source_dir}/data/lb_test_data/data.{rank}.json', 'r', encoding='utf-8') as f: + with open(f"{source_dir}/data/lb_test_data/data.{rank}.json", "r", encoding="utf-8") as f: data = json.load(f) - # Add serialized data into the rank + # Add serialized data into the rank rank_data.append((json.dumps(data))) # Launch VT TV from JSON data From 7589afda862609db7217ae05912420b79f7309e5 Mon Sep 17 00:00:00 2001 From: Maxime N Date: Fri, 27 Sep 2024 14:29:18 +0200 Subject: [PATCH 8/8] #61: fix whitespaces --- bindings/python/tv.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bindings/python/tv.cc b/bindings/python/tv.cc index 331fe638f8..2276e1f0ac 100644 --- a/bindings/python/tv.cc +++ b/bindings/python/tv.cc @@ -19,7 +19,7 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const viz_config = YAML::Load(input_yaml_params_str); } catch (std::exception const& e) { throw std::runtime_error(fmt::format( - "vt-tv: Error reading the configuration file: {}", + "vt-tv: Error reading the configuration file: {}", e.what() )); } @@ -33,7 +33,7 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const // Throw error if configuration is invalid if (!is_config_valid) { throw std::runtime_error(fmt::format( - "vt-tv: Error validating the configuration file: {}", + "vt-tv: Error validating the configuration file: {}", config_validator.getMissingRequiredParameters() )); } @@ -62,7 +62,7 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const // Throw an error if the output directory does not exist or is not absolute if (!std::filesystem::exists(output_path)) { throw std::runtime_error(fmt::format( - "vt-tv: Visualization output directory does not exist at {}", + "vt-tv: Visualization output directory does not exist at {}", output_dir )); }