create AWS infra
This commit is contained in:
29
src/commands/utils.py
Normal file
29
src/commands/utils.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from pathlib import Path
|
||||
|
||||
import typer
|
||||
import yaml
|
||||
from rich.console import Console
|
||||
|
||||
from src.config import Config
|
||||
|
||||
CONSOLE = Console()
|
||||
CONFIG_OPT = typer.Option("config.yaml", "--config", "-c", help="Path to config file")
|
||||
|
||||
|
||||
def load_config(path: str = "config.yaml") -> Config:
|
||||
config_path = Path(path)
|
||||
if not config_path.exists():
|
||||
raise FileNotFoundError(
|
||||
f"Config file not found: {config_path}. Run 'qai-cli init' to create one."
|
||||
)
|
||||
with open(config_path) as f:
|
||||
data = yaml.safe_load(f)
|
||||
return Config.model_validate(data)
|
||||
|
||||
|
||||
def load_cfg(path: str = "config.yaml") -> Config:
|
||||
try:
|
||||
return load_config(path)
|
||||
except FileNotFoundError as e:
|
||||
CONSOLE.print(f"[red]{e}[/red]")
|
||||
raise typer.Exit(1)
|
||||
Reference in New Issue
Block a user