feat(shared): do not exit on missing config file
This commit is contained in:
parent
35071ef834
commit
000f09b095
|
@ -23,6 +23,7 @@ class BaseConfig(BaseModel):
|
||||||
|
|
||||||
:param filepath: yaml configuration file to read from
|
:param filepath: yaml configuration file to read from
|
||||||
:param env_prefix: prefix for the environment variable names
|
:param env_prefix: prefix for the environment variable names
|
||||||
|
:param env_delimiter: delimiter for the environment variable names
|
||||||
:returns: configuration class
|
:returns: configuration class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -83,6 +84,11 @@ class BaseConfig(BaseModel):
|
||||||
filepath: Optional[Path] = None,
|
filepath: Optional[Path] = None,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
if filepath is None:
|
if filepath is None:
|
||||||
|
logger.debug("no config filepath is provided")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
if not filepath.is_file():
|
||||||
|
logger.warning(f"provided config filepath '{filepath}' is not a file")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# pylint: disable=fixme
|
# pylint: disable=fixme
|
||||||
|
@ -95,8 +101,9 @@ class BaseConfig(BaseModel):
|
||||||
try:
|
try:
|
||||||
return safe_load(filepath.read_text(encoding="utf-8"))
|
return safe_load(filepath.read_text(encoding="utf-8"))
|
||||||
except YAMLError as error:
|
except YAMLError as error:
|
||||||
logger.critical(error)
|
logger.error(f"config file '{filepath}' is not a valid yaml file: {error}")
|
||||||
sys.exit(1)
|
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
Loading…
Reference in New Issue