From 38dfb268fbbc3e58f550672e8e3024600dc48974 Mon Sep 17 00:00:00 2001 From: gadorlhiac Date: Wed, 10 Apr 2024 14:47:42 -0700 Subject: [PATCH] MNT Pull experiment from environment variable if not in YAML, and env var defined --- lute/io/models/base.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lute/io/models/base.py b/lute/io/models/base.py index f049f584..719a1f49 100644 --- a/lute/io/models/base.py +++ b/lute/io/models/base.py @@ -47,7 +47,7 @@ class AnalysisHeader(BaseModel): "LUTE Task Configuration", description="Description of the configuration or experiment.", ) - experiment: str = Field("EXPX00000", description="Experiment.") + experiment: str = Field("", description="Experiment.") run: Union[str, int] = Field("", description="Data acquisition run.") date: str = Field("1970/01/01", description="Start date of analysis.") lute_version: Union[float, str] = Field( @@ -82,6 +82,13 @@ def validate_run( return int(run_time.split("_")[0]) return run + @validator("experiment", always=True) + def validate_experiment(cls, experiment: str, values: Dict[str, Any]) -> str: + if experiment == "": + arp_exp: str = os.environ.get("EXPERIMENT", "EXPX00000") + return arp_exp + return experiment + class TaskParameters(BaseSettings): """Base class for models of task parameters to be validated.