Skip to content

Commit 2c38a3e

Browse files
authored
feat: Separate out GitHub callback job for pre-training and post-training DAG (GoogleCloudPlatform#1325)
1 parent 7552974 commit 2c38a3e

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

dags/multipod/maxtext_e2e_tests.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
"""
1616
Parent DAG that triggers MaxText E2E TPU pre-training and post-training child
17-
DAGs in parallel, waits for both to complete, then fires a GitHub
18-
repository_dispatch callback with the aggregated result.
17+
DAGs in parallel, firing separate GitHub repository_dispatch callbacks for
18+
pre-training and post-training upon completion of each job.
1919
"""
2020
import datetime
2121
from airflow import models
@@ -79,19 +79,24 @@
7979
poke_interval=600, # check every 10 minutes for child DAG completion
8080
)
8181

82-
github_callback = PythonOperator(
83-
task_id="fire_github_callback",
82+
github_callback_pre_training = PythonOperator(
83+
task_id="fire_github_callback_pre_training",
8484
python_callable=fire_github_callback,
85-
trigger_rule=TriggerRule.ALL_SUCCESS, # Only fire if all upstream tasks succeeded
85+
op_kwargs={"test_type": "pre_training"},
86+
trigger_rule=TriggerRule.ALL_SUCCESS,
87+
)
88+
89+
github_callback_post_training = PythonOperator(
90+
task_id="fire_github_callback_post_training",
91+
python_callable=fire_github_callback,
92+
op_kwargs={"test_type": "post_training"},
93+
trigger_rule=TriggerRule.ALL_SUCCESS,
8694
)
8795

8896
validate_task = PythonOperator(
8997
task_id="validate_trigger",
9098
python_callable=validate_git_trigger,
9199
)
92100

93-
(
94-
validate_task
95-
>> [trigger_pre_training, trigger_post_training]
96-
>> github_callback
97-
)
101+
(validate_task >> trigger_pre_training >> github_callback_pre_training)
102+
(validate_task >> trigger_post_training >> github_callback_post_training)

xlml/utils/github.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,21 @@ def validate_git_trigger(**context):
3636
)
3737

3838

39-
def fire_github_callback(**context):
39+
def fire_github_callback(test_type: str | None = None, **context):
4040
"""Fires a GitHub repository_dispatch callback with the DAG run result."""
4141
params = context["params"]
4242
dag_run = context["dag_run"]
4343

44+
client_payload = {
45+
"state": "success",
46+
"dag_id": dag_run.dag_id,
47+
"dag_run_id": dag_run.run_id,
48+
"sha": params["maxtext_sha"],
49+
"github_run_id": params["github_run_id"],
50+
}
51+
if test_type:
52+
client_payload["test_type"] = test_type
53+
4454
response = requests.post(
4555
f"https://api.github.com/repos/{params['github_repo']}/dispatches",
4656
headers={
@@ -50,13 +60,7 @@ def fire_github_callback(**context):
5060
},
5161
json={
5262
"event_type": "airflow-dag-complete",
53-
"client_payload": {
54-
"state": "success",
55-
"dag_id": dag_run.dag_id,
56-
"dag_run_id": dag_run.run_id,
57-
"sha": params["maxtext_sha"],
58-
"github_run_id": params["github_run_id"],
59-
},
63+
"client_payload": client_payload,
6064
},
6165
timeout=30,
6266
)

0 commit comments

Comments
 (0)