From 5bce206033b44fe19c3031817892b0a699a1cc93 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Mon, 24 Jun 2024 04:40:40 +0000 Subject: [PATCH] fix: Handle ConfigurationError correctly --- src/ai/backend/storage/cli.py | 4 ++-- src/ai/backend/storage/config.py | 17 +++-------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/ai/backend/storage/cli.py b/src/ai/backend/storage/cli.py index 71a057a5c9..1e9d4bf85e 100644 --- a/src/ai/backend/storage/cli.py +++ b/src/ai/backend/storage/cli.py @@ -85,7 +85,7 @@ def status( local_config = load_local_config(config_path, log_level, debug=debug) except ConfigurationError as e: print( - "ConfigurationError: Could not read or validate the storage-proxy local config:", + "ConfigurationError: Could not read or validate the storage-proxy local config.", file=sys.stderr, ) print(pformat(e.invalid_data), file=sys.stderr) @@ -93,7 +93,7 @@ def status( pid_filepath = local_config["storage-proxy"]["pid-file"] - if not pid_filepath: + if not pid_filepath.is_file(): print( 'ConfigurationError: "pid-file" not found in the configuration file.', file=sys.stderr, diff --git a/src/ai/backend/storage/config.py b/src/ai/backend/storage/config.py index 7221242d1a..c326561f64 100644 --- a/src/ai/backend/storage/config.py +++ b/src/ai/backend/storage/config.py @@ -1,14 +1,11 @@ import os -import sys from pathlib import Path -from pprint import pformat from typing import Any import trafaret as t from ai.backend.common import validators as tx from ai.backend.common.config import ( - ConfigurationError, check, etcd_config_iv, override_key, @@ -132,17 +129,9 @@ def load_local_config( override_key(raw_cfg, ("logging", "level"), log_level) override_key(raw_cfg, ("logging", "pkg-ns", "ai.backend"), log_level) - try: - local_config = check(raw_cfg, storage_proxy_local_config_iv) - local_config["_src"] = cfg_src_path - return local_config - except ConfigurationError as e: - print( - "ConfigurationError: Validation of storage-proxy local config has failed:", - file=sys.stderr, - ) - print(pformat(e.invalid_data), file=sys.stderr) - raise + local_config = check(raw_cfg, storage_proxy_local_config_iv) + local_config["_src"] = cfg_src_path + return local_config def load_shared_config(local_config: dict[str, Any]) -> AsyncEtcd: