From fe2ed3043f9754651e22ff1fb3fb7a514841a156 Mon Sep 17 00:00:00 2001 From: Caleb Schilly Date: Thu, 16 May 2024 16:25:50 -0400 Subject: [PATCH] #422: try putting vttv import in a try/except block for ci --- src/lbaf/Applications/LBAF_app.py | 61 +++++++++++++++++-------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/src/lbaf/Applications/LBAF_app.py b/src/lbaf/Applications/LBAF_app.py index 8d68b2f06..ed143a5f2 100644 --- a/src/lbaf/Applications/LBAF_app.py +++ b/src/lbaf/Applications/LBAF_app.py @@ -6,7 +6,11 @@ import importlib import yaml -import vttv +try: + import vttv + using_vttv = True +except ModuleNotFoundError: + using_vttv = False # pylint:disable=C0413:wrong-import-position # Use lbaf module from source if lbaf package is not installed @@ -572,33 +576,34 @@ def run(self): ] # Call vttv visualization - self.__logger.info("Calling vt-tv") - - # Serialize data to JSON-formatted string - self.__rank_phases = {} - for p in phases.values(): - for r in p.get_ranks(): - self.__rank_phases.setdefault(r.get_id(), {}) - self.__rank_phases[r.get_id()][p.get_id()] = r - - ranks_json_str = [] - for i in range(len(self.__rank_phases.items())): - ranks_json_str.append(self.__json_writer._json_serializer((i, self.__rank_phases[i]))) - - vttv_params = { - "x_ranks": self.__parameters.grid_size[0], - "y_ranks": self.__parameters.grid_size[1], - "z_ranks": self.__parameters.grid_size[2], - "object_jitter": self.__parameters.object_jitter, - "rank_qoi": self.__parameters.rank_qoi, - "object_qoi": self.__parameters.object_qoi, - "save_meshes": self.__parameters.save_meshes, - "force_continuous_object_qoi": self.__parameters.continuous_object_qoi, - "output_visualization_dir": self.__parameters.output_dir, - "output_visualization_file_stem": self.__parameters.output_file_stem - } - num_ranks = self.__parameters.grid_size[0] * self.__parameters.grid_size[1] * self.__parameters.grid_size[2] - vttv.tv_from_json(ranks_json_str, str(vttv_params), num_ranks) + if using_vttv: + self.__logger.info("Calling vt-tv") + + # Serialize data to JSON-formatted string + self.__rank_phases = {} + for p in phases.values(): + for r in p.get_ranks(): + self.__rank_phases.setdefault(r.get_id(), {}) + self.__rank_phases[r.get_id()][p.get_id()] = r + + ranks_json_str = [] + for i in range(len(self.__rank_phases.items())): + ranks_json_str.append(self.__json_writer._json_serializer((i, self.__rank_phases[i]))) + + vttv_params = { + "x_ranks": self.__parameters.grid_size[0], + "y_ranks": self.__parameters.grid_size[1], + "z_ranks": self.__parameters.grid_size[2], + "object_jitter": self.__parameters.object_jitter, + "rank_qoi": self.__parameters.rank_qoi, + "object_qoi": self.__parameters.object_qoi, + "save_meshes": self.__parameters.save_meshes, + "force_continuous_object_qoi": self.__parameters.continuous_object_qoi, + "output_visualization_dir": self.__parameters.output_dir, + "output_visualization_file_stem": self.__parameters.output_file_stem + } + num_ranks = self.__parameters.grid_size[0] * self.__parameters.grid_size[1] * self.__parameters.grid_size[2] + vttv.tvFromJson(ranks_json_str, str(vttv_params), num_ranks) # Report on rebalanced phase when available if rebalanced_phase: