Skip to content

Commit

Permalink
#16: bindings: Fix test script
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Dec 12, 2023
1 parent ba129db commit c6fda0e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
30 changes: 16 additions & 14 deletions bindings/python/tv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ void tv_from_json(const std::vector<std::string>& input_json_per_rank_list, cons
}

// print all saved configuration parameters
fmt::print("vt-tv parameters:\n");
fmt::print(" x_ranks: {}\n", grid_size[0]);
fmt::print(" y_ranks: {}\n", grid_size[1]);
fmt::print(" z_ranks: {}\n", grid_size[2]);
fmt::print(" object_jitter: {}\n", object_jitter);
fmt::print(" rank_qoi: {}\n", qoi_request[0]);
fmt::print(" object_qoi: {}\n", qoi_request[2]);
fmt::print(" save_meshes: {}\n", save_meshes);
fmt::print(" save_pngs: {}\n", save_pngs);
fmt::print(" force_continuous_object_qoi: {}\n", continuous_object_qoi);
fmt::print(" output_visualization_dir: {}\n", output_dir);
fmt::print(" output_visualization_file_stem: {}\n", output_file_stem);
fmt::print(" window_size: {}\n", win_size);
fmt::print(" font_size: {}\n", font_size);
fmt::print("vt-tv:\n Parameters:\n");
fmt::print(" x_ranks: {}\n", grid_size[0]);
fmt::print(" y_ranks: {}\n", grid_size[1]);
fmt::print(" z_ranks: {}\n", grid_size[2]);
fmt::print(" object_jitter: {}\n", object_jitter);
fmt::print(" rank_qoi: {}\n", qoi_request[0]);
fmt::print(" object_qoi: {}\n", qoi_request[2]);
fmt::print(" save_meshes: {}\n", save_meshes);
fmt::print(" save_pngs: {}\n", save_pngs);
fmt::print(" force_continuous_object_qoi: {}\n", continuous_object_qoi);
fmt::print(" output_visualization_dir: {}\n", output_dir);
fmt::print(" output_visualization_file_stem: {}\n", output_file_stem);
fmt::print(" window_size: {}\n", win_size);
fmt::print(" font_size: {}\n", font_size);

// using json = nlohmann::json;
// // Read the json for the rank
Expand Down Expand Up @@ -239,6 +239,8 @@ void tv_from_json(const std::vector<std::string>& input_json_per_rank_list, cons
} catch (std::exception const& e) {
std::cout << "vt-tv: Error reading the configuration file: " << e.what() << std::endl;
}

fmt::print("vt-tv: Done.\n");
}

namespace nb = nanobind;
Expand Down
23 changes: 16 additions & 7 deletions tests/test_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@
# 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/unit/lb_test_data/data.0.json', 'r') as f:
data = json.load(f)

with open(f'{source_dir}/config/conf.yaml', 'r') as stream:
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)

# make output_visualization_dir directory parameter absolute
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 = []

for rank in range(n_ranks):
with open(f'{source_dir}/tests/unit/lb_test_data/data.{rank}.json', 'r') as f:
data = json.load(f)

data_serialized = json.dumps(data)

data_serialized = json.dumps(data)
params_serialized = yaml.dump(params)
rank_data.append((data_serialized))

vttv.tv_from_json(data_serialized, params_serialized)
vttv.tv_from_json(rank_data, params_serialized, n_ranks)
11 changes: 11 additions & 0 deletions tests/test_bindings_conf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
visualization:
x_ranks: 2
y_ranks: 2
z_ranks: 1
object_jitter: 0.5
rank_qoi: load
object_qoi: load
save_meshes: true
force_continuous_object_qoi: true
output_visualization_dir: ../output
output_visualization_file_stem: output_file

0 comments on commit c6fda0e

Please sign in to comment.