Skip to content

Commit ff1982a

Browse files
committed
fix: Docstring
1 parent 810b144 commit ff1982a

2 files changed

Lines changed: 28 additions & 23 deletions

File tree

dags/tpu_observability/jobset_healthiness_validation.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from dags import composer_env
2525
from dags.tpu_observability.utils import jobset_util as jobset
2626
from dags.tpu_observability.utils import node_pool_util as node_pool
27-
from dags.tpu_observability.utils.jobset_util import Workload, ReplicatedJobStatus
27+
from dags.tpu_observability.utils.jobset_util import Workload, JobSetHealthiness
2828
from dags.tpu_observability.configs.common import (
2929
MachineConfigMap,
3030
GCS_CONFIG_PATH,
@@ -64,18 +64,20 @@
6464
doc_md="""
6565
# JobSet Healthiness Test For the "Suspended" Status
6666
### Description
67-
This DAG automates the process of creating node-pools, ensuring the
68-
correct number of "Suspended" replicas appear, then launching a jobset on
69-
multiple replicas to ensure the correct number begin running.
67+
This DAG automates node-pool creation and validates JobSet healthiness
68+
by examining replica-based metrics: Specified, Active, Ready,
69+
Suspended, Succeeded, and Failed. It ensures the JobSet controller
70+
accurately reports these states during startup, maintenance,
71+
and failure scenarios.
7072
### Prerequisites
7173
This test requires an existing cluster to run.
7274
### Procedures
73-
First a node-pool is created. The validation test is then run to
74-
check if the number of "Suspended" replicas is 0. Once the jobset is
75-
running the jobs should quickly enter the "Ready" state. Then using
76-
command to suspend entire jobset. The number of found replicas is
77-
tested against the number of replicas which should be "Suspended".
78-
If they match the DAG is a success.
75+
First a node-pool is created. This test uses a State-Trigger-Observe pattern:
76+
it triggers lifecycle transitions (e.g., suspension, failure or succeeded)
77+
and verifies that GKE telemetry reflects these shifts. Using sensors,
78+
the DAG polls for eventual consistency to account for ingestion latency,
79+
dynamically matching runtime JobSet configurations against normalized monitoring
80+
data types to ensure accurate state validation.
7981
""",
8082
) as dag:
8183
for machine in MachineConfigMap:
@@ -119,12 +121,12 @@
119121

120122
with TaskGroup(group_id="validate_running_metrics") as validate_running:
121123
running_metrics = [
122-
(ReplicatedJobStatus.SPECIFIED, "USE_CONFIG_REPLICAS"),
123-
(ReplicatedJobStatus.ACTIVE, "USE_CONFIG_REPLICAS"),
124-
(ReplicatedJobStatus.READY, "USE_CONFIG_REPLICAS"),
125-
(ReplicatedJobStatus.FAILED, 0),
126-
(ReplicatedJobStatus.SUCCEEDED, 0),
127-
(ReplicatedJobStatus.SUSPENDED, 0),
124+
(JobSetHealthiness.SPECIFIED, "USE_CONFIG_REPLICAS"),
125+
(JobSetHealthiness.ACTIVE, "USE_CONFIG_REPLICAS"),
126+
(JobSetHealthiness.READY, "USE_CONFIG_REPLICAS"),
127+
(JobSetHealthiness.FAILED, 0),
128+
(JobSetHealthiness.SUCCEEDED, 0),
129+
(JobSetHealthiness.SUSPENDED, 0),
128130
]
129131
for status, expected in running_metrics:
130132
jobset.wait_for_jobset_metrics.override(
@@ -147,8 +149,8 @@
147149
group_id="validate_suspended_metrics"
148150
) as validate_suspended:
149151
suspended_metrics = [
150-
(ReplicatedJobStatus.ACTIVE, 0),
151-
(ReplicatedJobStatus.SUSPENDED, "USE_CONFIG_REPLICAS"),
152+
(JobSetHealthiness.ACTIVE, 0),
153+
(JobSetHealthiness.SUSPENDED, "USE_CONFIG_REPLICAS"),
152154
]
153155
for status, expected in suspended_metrics:
154156
jobset.wait_for_jobset_metrics.override(
@@ -184,7 +186,7 @@
184186
validate_succeeded_metric = jobset.wait_for_jobset_metrics.override(
185187
task_id="wait_for_succeeded_count"
186188
)(
187-
metric_name=ReplicatedJobStatus.SUCCEEDED,
189+
metric_name=JobSetHealthiness.SUCCEEDED,
188190
expected_value="USE_CONFIG_REPLICAS",
189191
node_pool=cluster_info,
190192
jobset_config=jobset_config,
@@ -209,7 +211,7 @@
209211
validate_failed_metric = jobset.wait_for_jobset_metrics.override(
210212
task_id="wait_for_failed_count"
211213
)(
212-
metric_name=ReplicatedJobStatus.FAILED,
214+
metric_name=JobSetHealthiness.FAILED,
213215
expected_value="USE_CONFIG_REPLICAS",
214216
node_pool=cluster_info,
215217
jobset_config=jobset_config,

dags/tpu_observability/utils/jobset_util.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,11 @@ class JobSetStartupOutput:
326326
jobset_start_time: XComArg
327327

328328

329-
class ReplicatedJobStatus(enum.Enum):
330-
"""Defines status of a replicated job."""
329+
class JobSetHealthiness(enum.Enum):
330+
"""Enumeration of JobSet healthiness metrics based on replica states.
331+
The values represent the metric name suffix used in Prometheus/GKE
332+
observability to track the count of replicas in each lifecycle state.
333+
"""
331334

332335
READY = "ready"
333336
SUSPENDED = "suspended"
@@ -899,7 +902,7 @@ def wait_for_jobset_started(
899902

900903
@task.sensor(poke_interval=60, timeout=3600, mode="poke")
901904
def wait_for_jobset_metrics(
902-
metric_name: ReplicatedJobStatus,
905+
metric_name: JobSetHealthiness,
903906
expected_value: any,
904907
node_pool: node_pool_info,
905908
jobset_config: JobSet,

0 commit comments

Comments
 (0)