Skip to content

Commit 3b1358d

Browse files
committed
p
Signed-off-by: Kevin H. Luu <khluu000@gmail.com>
1 parent 35ba0e7 commit 3b1358d

File tree

4 files changed

+34
-49
lines changed

4 files changed

+34
-49
lines changed

buildkite/pipeline_generator/buildkite_step.py

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,12 @@ class BuildkiteCommandStep(BaseModel):
2020
env: Optional[Dict[str, str]] = None
2121
parallelism: Optional[int] = None
2222

23-
def to_yaml(self):
24-
return {
25-
"label": self.label,
26-
"group": self.group,
27-
"commands": self.commands,
28-
"depends_on": self.depends_on,
29-
"soft_fail": self.soft_fail,
30-
"retry": self.retry,
31-
"plugins": self.plugins,
32-
"env": self.env,
33-
"retry": self.retry,
34-
"parallelism": self.parallelism
35-
}
3623

3724
class BuildkiteBlockStep(BaseModel):
3825
block: str
3926
depends_on: Optional[Union[str, List[str]]] = None
4027
key: Optional[str] = None
4128

42-
def to_yaml(self):
43-
return {
44-
"block": self.block,
45-
"depends_on": self.depends_on,
46-
"key": self.key
47-
}
48-
4929
class BuildkiteGroupStep(BaseModel):
5030
group: str
5131
steps: List[Union[BuildkiteCommandStep, BuildkiteBlockStep]]
@@ -57,29 +37,27 @@ def _get_step_plugin(step: Step):
5737
else:
5838
return {"docker#v5.2.0": get_docker_plugin(step, get_image(step.no_gpu))}
5939

40+
_GPU_TO_QUEUE = {
41+
GPUType.A100.value: AgentQueue.A100_QUEUE,
42+
GPUType.H100.value: AgentQueue.MITHRIL_H100_POOL,
43+
GPUType.H200.value: AgentQueue.SKYLAB_H200,
44+
GPUType.B200.value: AgentQueue.B200,
45+
}
46+
47+
6048
def get_agent_queue(step: Step):
6149
branch = get_global_config()["branch"]
6250
if step.label.startswith(":docker:"):
63-
if branch == "main":
64-
return AgentQueue.CPU_QUEUE_POSTMERGE_US_EAST_1
65-
else:
66-
return AgentQueue.CPU_QUEUE_PREMERGE_US_EAST_1
67-
elif step.label == "Documentation Build":
51+
return AgentQueue.CPU_QUEUE_POSTMERGE_US_EAST_1 if branch == "main" else AgentQueue.CPU_QUEUE_PREMERGE_US_EAST_1
52+
if step.label == "Documentation Build":
6853
return AgentQueue.SMALL_CPU_QUEUE_PREMERGE
69-
elif step.no_gpu:
54+
if step.no_gpu:
7055
return AgentQueue.CPU_QUEUE_PREMERGE_US_EAST_1
71-
elif step.gpu == GPUType.A100:
72-
return AgentQueue.A100_QUEUE
73-
elif step.gpu == GPUType.H100:
74-
return AgentQueue.MITHRIL_H100_POOL
75-
elif step.gpu == GPUType.H200:
76-
return AgentQueue.SKYLAB_H200
77-
elif step.gpu == GPUType.B200:
78-
return AgentQueue.B200
79-
elif step.num_gpus == 2 or step.num_gpus == 4:
56+
if step.gpu in _GPU_TO_QUEUE:
57+
return _GPU_TO_QUEUE[step.gpu]
58+
if step.num_gpus in (2, 4):
8059
return AgentQueue.GPU_4_QUEUE
81-
else:
82-
return AgentQueue.GPU_1_QUEUE
60+
return AgentQueue.GPU_1_QUEUE
8361

8462
def _get_variables_to_inject() -> Dict[str, str]:
8563
global_config = get_global_config()
@@ -189,12 +167,15 @@ def _step_should_run(step: Step, list_file_diff: List[str]) -> bool:
189167
return False
190168
if global_config["run_all"]:
191169
return True
192-
if step.source_file_dependencies:
193-
for source_file in step.source_file_dependencies:
194-
for diff_file in list_file_diff:
195-
if source_file in diff_file:
196-
return True
197-
return True
170+
# If no dependencies specified, always run
171+
if not step.source_file_dependencies:
172+
return True
173+
# Only run if at least one dependency matches a changed file
174+
for source_file in step.source_file_dependencies:
175+
for diff_file in list_file_diff:
176+
if source_file in diff_file:
177+
return True
178+
return False
198179

199180
def _generate_step_key(step_label: str) -> str:
200181
return (

buildkite/pipeline_generator/global_config.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def init_global_config(pipeline_config_path: str):
3737
list_file_diff = get_list_file_diff(branch, merge_base_commit)
3838
pr_labels = get_pr_labels(pull_request)
3939

40+
run_all_patterns = pipeline_config.get("run_all_patterns") or []
41+
run_all_exclude_patterns = pipeline_config.get("run_all_exclude_patterns") or []
42+
run_all = _should_run_all(pr_labels, list_file_diff, run_all_patterns, run_all_exclude_patterns)
43+
4044
config = GlobalConfig(
4145
name=pipeline_config["name"],
4246
job_dirs=pipeline_config["job_dirs"],
@@ -46,14 +50,14 @@ def init_global_config(pipeline_config_path: str):
4650
commit=os.getenv("BUILDKITE_COMMIT"),
4751
pull_request=pull_request,
4852
docs_only_disable=os.getenv("DOCS_ONLY_DISABLE", "0"),
49-
run_all_patterns=pipeline_config.get("run_all_patterns", None),
50-
run_all_exclude_patterns=pipeline_config.get("run_all_exclude_patterns", None),
53+
run_all_patterns=run_all_patterns or None,
54+
run_all_exclude_patterns=run_all_exclude_patterns or None,
5155
nightly=os.getenv("NIGHTLY", "0"),
52-
run_all=_should_run_all(pr_labels, list_file_diff, pipeline_config.get("run_all_patterns", None), pipeline_config.get("run_all_exclude_patterns", None)),
56+
run_all=run_all,
5357
merge_base_commit=merge_base_commit,
5458
list_file_diff=list_file_diff,
5559
fail_fast=_should_fail_fast(pr_labels),
56-
use_precompiled=_should_use_precompiled(_should_run_all(pr_labels, list_file_diff, pipeline_config.get("run_all_patterns", None), pipeline_config.get("run_all_exclude_patterns", None)), merge_base_commit),
60+
use_precompiled=_should_use_precompiled(run_all, merge_base_commit),
5761
)
5862

5963
def get_global_config():

buildkite/pipeline_generator/pipeline_generator_helper.py

Whitespace-only changes.

buildkite/pipeline_generator/plugin/docker_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161

6262
def get_docker_plugin(step: Step, image: str):
6363
plugin = None
64-
if step.gpu == GPUType.H200:
64+
if step.gpu == GPUType.H200.value:
6565
plugin = copy.deepcopy(h200_plugin_template)
66-
elif step.gpu == GPUType.B200:
66+
elif step.gpu == GPUType.B200.value:
6767
plugin = copy.deepcopy(b200_plugin_template)
6868
else:
6969
plugin = copy.deepcopy(docker_plugin_template)

0 commit comments

Comments
 (0)