From 717659cf965ddd0e8ea777925f35ed0f51dd04a7 Mon Sep 17 00:00:00 2001 From: "Kevin H. Luu" Date: Fri, 11 Oct 2024 11:10:26 -0700 Subject: [PATCH] [6/n][pipeline-gen] Update buildkite step format and add validators (#46) * p Signed-off-by: kevin * p Signed-off-by: kevin --------- Signed-off-by: kevin --- scripts/pipeline_generator/step.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/pipeline_generator/step.py b/scripts/pipeline_generator/step.py index 8e73c45..3fdccb4 100644 --- a/scripts/pipeline_generator/step.py +++ b/scripts/pipeline_generator/step.py @@ -58,7 +58,7 @@ def validate_multi_node(self) -> Self: class BuildkiteStep(BaseModel): """This class represents a step in Buildkite format.""" label: str - agents: Dict[str, AgentQueue] = {"queue": AgentQueue.AWS_CPU} + agents: Dict[str, str] = {"queue": AgentQueue.AWS_CPU.value} commands: List[str] key: Optional[str] = None plugins: Optional[List[Dict]] = None @@ -68,12 +68,18 @@ class BuildkiteStep(BaseModel): env: Optional[Dict[str, str]] = None retry: Optional[Dict[str, Any]] = None + @model_validator(mode="after") + def validate_agent_queue(self) -> Self: + queue = self.agents.get("queue") + if not AgentQueue(queue): + raise ValueError(f"Invalid agent queue: {queue}") + class BuildkiteBlockStep(BaseModel): """This class represents a block step in Buildkite format.""" block: str - depends_on: Optional[str] = BUILD_STEP_KEY key: str + depends_on: Optional[str] = BUILD_STEP_KEY def get_step_key(step_label: str) -> str: