Skip to content

Commit 8035568

Browse files
committed
feat: Refactor TPU info validation DAG to improve task grouping and command execution
1 parent d702fd6 commit 8035568

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

dags/tpu_observability/tpu_info_help_validation_dags.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def _get_tpu_version_output(info: node_pool.Info, pod_name: str) -> str:
8585
with tempfile.NamedTemporaryFile() as temp_config_file:
8686
env = os.environ.copy()
8787
env["KUBECONFIG"] = temp_config_file.name
88+
8889
cmd = " && ".join([
8990
jobset.Command.get_credentials_command(info),
9091
f"kubectl exec {pod_name} -n default -- tpu-info --version",
@@ -121,8 +122,9 @@ def _get_tpu_process_output(info: node_pool.Info, pod_name: str) -> str:
121122
with tempfile.NamedTemporaryFile() as temp_config_file:
122123
env = os.environ.copy()
123124
env["KUBECONFIG"] = temp_config_file.name
125+
124126
cmd = " && ".join([
125-
jobset.append_credentials_command(info),
127+
jobset.Command.get_credentials_command(info),
126128
f"kubectl exec {pod_name} -n default -- tpu-info --process",
127129
])
128130
return subprocess.run_exec(cmd, env=env)
@@ -243,17 +245,22 @@ def validate_tpu_info_process(info: node_pool.Info, pod_name: str) -> str:
243245
task_id="wait_for_job_start", timeout=1200
244246
)(cluster_info, pod_name_list=pod_names, job_apply_time=apply_time)
245247

246-
validate_help = validate_tpu_info_help.partial(info=cluster_info).expand(
247-
pod_name=pod_names
248-
)
248+
# Keyword arguments are generated dynamically at runtime (pylint does not
249+
# know this signature).
250+
with TaskGroup( # pylint: disable=unexpected-keyword-arg
251+
group_id="verification_group"
252+
) as verification_group:
253+
validate_help = validate_tpu_info_help.partial(
254+
info=cluster_info
255+
).expand(pod_name=pod_names)
249256

250-
validate_version = validate_tpu_info_version.partial(
251-
info=cluster_info
252-
).expand(pod_name=pod_names)
257+
validate_version = validate_tpu_info_version.partial(
258+
info=cluster_info
259+
).expand(pod_name=pod_names)
253260

254-
validate_process = validate_tpu_info_process.partial(
255-
info=cluster_info
256-
).expand(pod_name=pod_names)
261+
validate_process = validate_tpu_info_process.partial(
262+
info=cluster_info
263+
).expand(pod_name=pod_names)
257264

258265
cleanup_workload = jobset.end_workload.override(
259266
task_id="cleanup_workload", trigger_rule=TriggerRule.ALL_DONE
@@ -279,9 +286,7 @@ def validate_tpu_info_process(info: node_pool.Info, pod_name: str) -> str:
279286
>> apply_time
280287
>> pod_names
281288
>> wait_for_job_start
282-
>> validate_help
283-
>> validate_process
284-
>> validate_version
289+
>> verification_group
285290
>> cleanup_workload
286291
>> cleanup_node_pool
287292
)

0 commit comments

Comments
 (0)