Skip to content

Commit

Permalink
BUG Fix parsing of run number using lute_config.run validator
Browse files Browse the repository at this point in the history
  • Loading branch information
gadorlhiac committed Apr 10, 2024
1 parent e555d21 commit 115c127
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lute/io/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class AnalysisHeader(BaseModel):
description="Description of the configuration or experiment.",
)
experiment: str = Field("EXPX00000", description="Experiment.")
run: Union[str, int] = Field(
os.environ.get("RUN", ""), description="Data acquisition run."
)
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(
0.1, description="Version of LUTE used for analysis."
Expand All @@ -73,6 +71,17 @@ def validate_work_dir(cls, work_dir: str, values: Dict[str, Any]) -> str:
)
return work_dir

@validator("run", always=True)
def validate_run(
cls, run: Union[str, int], values: Dict[str, Any]
) -> Union[str, int]:
if run == "":
# From Airflow RUN_NUM should have Format "RUN_DATETIME" - Num is first part
run_time: str = os.environ.get("RUN_NUM", "")
if run_time != "":
return int(run_time.split("_")[0])
return run


class TaskParameters(BaseSettings):
"""Base class for models of task parameters to be validated.
Expand Down

0 comments on commit 115c127

Please sign in to comment.