import sys
import os
import json
from pydantic import BaseModel
from datetime import datetime

class Config(BaseModel):
    clock_start: datetime = datetime.now()
    data_path: str
    model: str

def load_config() -> Config:
    config_flag = [arg for arg in sys.argv if arg.startswith("--config=")]
    if config_flag:
        config_file = config_flag[0].split("=")[1]
    elif os.getenv("CONFIG_FILE"):
        config_file = os.getenv("CONFIG_FILE")
    else:
        config_file = "./config.json"
    
    with open(config_file, "r") as f:
        config = json.load(f)
    return Config(**config)