diff --git a/projects/cluster/library/prom.py b/projects/cluster/library/prom.py index 27aac4751..e231cb6d9 100644 --- a/projects/cluster/library/prom.py +++ b/projects/cluster/library/prom.py @@ -20,11 +20,16 @@ def dump_prometheus(prom_start_ts, namespace, delay=60): prom_end_ts = datetime.datetime.now() args = dict( duration_s = (prom_end_ts - prom_start_ts).total_seconds(), - promquery_file = TESTING_THIS_DIR / "metrics.txt", + promquery_file = config.project.testing_dir / "metrics.txt", dest_dir = env.ARTIFACT_DIR / "metrics", namespace = namespace, ) + if not args["promquery_file"].exists(): + msg = f"Requested tests.capture_prom=with-queries, but '{args['promquery_file']}' does not exist. Cannot proceed." + logging.fatal(msg) + raise FileNotFoundError(msg) + with env.NextArtifactDir("cluster__dump_prometheus_dbs"): run.run_toolbox("cluster", "query_prometheus_db", **args) with env.NextArtifactDir("cluster__dump_prometheus_db"): diff --git a/projects/core/library/config.py b/projects/core/library/config.py index e3816edfb..b090f1f0f 100644 --- a/projects/core/library/config.py +++ b/projects/core/library/config.py @@ -38,7 +38,8 @@ def __exit__(self, ex_type, ex_value, exc_traceback): class Config: - def __init__(self, config_path): + def __init__(self, testing_dir, config_path): + self.testing_dir = testing_dir self.config_path = config_path if not self.config_path.exists(): @@ -242,7 +243,7 @@ def detect_apply_cluster_profile(self, node_profiles): return False -def _set_config_environ(base_dir): +def _set_config_environ(testing_dir): reloading = False config_path_final = pathlib.Path(env.ARTIFACT_DIR / "config.yaml") @@ -256,13 +257,13 @@ def _set_config_environ(base_dir): config_file_src = shared_dir_file_src logging.info(f"Reloading the config file from SHARED_DIR {config_file_src} ...") else: - config_file_src = base_dir / "config.yaml" + config_file_src = testing_dir / "config.yaml" logging.info(f"Reloading the config file from TOPSAIL project directory {config_file_src} ...") os.environ["TOPSAIL_FROM_CONFIG_FILE"] = str(config_path_final) if "TOPSAIL_FROM_COMMAND_ARGS_FILE" not in os.environ: - os.environ["TOPSAIL_FROM_COMMAND_ARGS_FILE"] = str(base_dir / "command_args.yml.j2") + os.environ["TOPSAIL_FROM_COMMAND_ARGS_FILE"] = str(testing_dir / "command_args.yml.j2") if not pathlib.Path(config_file_src) == config_path_final: @@ -296,15 +297,15 @@ def get_jsonpath(config, jsonpath): return jsonpath_ng.parse(jsonpath).find(config)[0].value -def init(base_dir, apply_preset_from_pr_args=False): +def init(testing_dir, apply_preset_from_pr_args=False): global project if project: logging.info("config.init: project config already configured.") return - config_path = _set_config_environ(base_dir) - project = Config(config_path) + config_path = _set_config_environ(testing_dir) + project = Config(testing_dir, config_path) if os.environ.get("TOPSAIL_LOCAL_CI_MULTI") == "true": logging.info("config.init: running in a local-ci multi Pod, skipping apply_config_overrides and apply_preset_from_pr_args.") diff --git a/projects/matrix_benchmarking/library/visualize.py b/projects/matrix_benchmarking/library/visualize.py index 302c4fd2f..4c24e5867 100755 --- a/projects/matrix_benchmarking/library/visualize.py +++ b/projects/matrix_benchmarking/library/visualize.py @@ -62,7 +62,7 @@ def init(allow_no_config_file=False): config.project.set_config("matbench.config_file", f"{matbench_preset}.yaml", dump_command_args=False) config.project.set_config("matbench.download.url_file", workload_storage_dir / "data" / f"{matbench_preset}.yaml", dump_command_args=False) - matbench_config = config.Config(workload_storage_dir / "data" / config.project.get_config("matbench.config_file")) + matbench_config = config.Config(workload_storage_dir, workload_storage_dir / "data" / config.project.get_config("matbench.config_file")) def entrypoint(allow_no_config_file=False):