Commit 53d2d606 authored by Hines, Jesse's avatar Hines, Jesse
Browse files

Set base_path in ServerSimConfig

parent b0270c02
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
from __future__ import annotations
from typing import Optional, Literal, Annotated as A
import json
from pathlib import Path
from pydantic import AwareDatetime, Field, model_validator
from raps import SingleSimConfig
from raps.utils import AutoAwareDatetime
@@ -99,6 +100,18 @@ class ServerSimConfig(SingleSimConfig):
    start: AutoAwareDatetime  # make start required
    """ Start of the simulation """

    def __init__(self, /, **data):
        # Override context to set base_path
        RAPS_PATH = (Path(__file__) / '../../../raps').resolve()
        self.__pydantic_validator__.validate_python(
            data,
            self_instance=self,
            context={
                "base_path": RAPS_PATH,
                "force_under_base_path": True,
            }
        )

    @model_validator(mode = "after")
    def _validate_server_sim_config(self):
        # Force these options regardless of input