|
10 | 10 | from airflow.exceptions import AirflowSkipException |
11 | 11 | from airflow.models.baseoperator import chain |
12 | 12 | from airflow.utils.task_group import TaskGroup |
| 13 | +from google.cloud import monitoring_v3 |
13 | 14 |
|
| 15 | +from dags import composer_env |
14 | 16 | from dags.common import test_owner |
15 | 17 | from dags.common.vm_resource import Project |
16 | 18 | from dags.multipod.configs.common import Platform |
17 | 19 | from dags.tpu_observability.utils import gcp_util, time_util |
18 | | -from google.cloud import monitoring_v3 |
19 | | -from dags import composer_env |
20 | | - |
21 | 20 |
|
22 | 21 | _UNKNOWN_RESOURCE_NAME = 'Unknown' |
23 | 22 |
|
@@ -49,8 +48,10 @@ def metric_label(self) -> str: |
49 | 48 | def log_filter(self) -> str: |
50 | 49 | """Returns the corresponding filter for the interruption reason. |
51 | 50 |
|
52 | | - These filters are in accordance with the definitions in this file from Google3: |
53 | | - //depot/google3/java/com/google/cloud/cluster/manager/compute/services/instancemanagerevent/InstanceEventNotificationAction.java |
| 51 | + These filters are in accordance with the definitions in this file from |
| 52 | + Google3: |
| 53 | + //depot/google3/java/com/google/cloud/cluster/manager/compute/services/ |
| 54 | + instancemanagerevent/InstanceEventNotificationAction.java |
54 | 55 | """ |
55 | 56 |
|
56 | 57 | filters = [] |
@@ -157,7 +158,8 @@ def fetch_interruption_metric_records( |
157 | 158 | f'resource.labels.project_id = "{configs.project_id}" ' |
158 | 159 | f'metric.type = "{metric_type}" ' |
159 | 160 | f'resource.type = "{resource_type}" ' |
160 | | - f'metric.labels.interruption_reason = "{configs.interruption_reason.metric_label()}" ' |
| 161 | + 'metric.labels.interruption_reason = ' |
| 162 | + f'"{configs.interruption_reason.metric_label()}" ' |
161 | 163 | ) |
162 | 164 |
|
163 | 165 | # key: resource_name, value: EventRecord |
@@ -432,7 +434,9 @@ def validate_interruption_count( |
432 | 434 |
|
433 | 435 | if len(log_timestamps) != len(metric.record_timestamps): |
434 | 436 | mismatch_nodes.append( |
435 | | - f'mismatch resource name: {resource_name}, metric_count: {len(metric.record_timestamps)}, log_count: {len(log_timestamps)}' |
| 437 | + f'mismatch resource name: {resource_name}, ' |
| 438 | + f'metric_count: {len(metric.record_timestamps)}, ' |
| 439 | + f'log_count: {len(log_timestamps)}' |
436 | 440 | ) |
437 | 441 |
|
438 | 442 | if mismatch_nodes: |
@@ -527,13 +531,13 @@ def create_interruption_dag( |
527 | 531 | for project in Project: |
528 | 532 | match project: |
529 | 533 | case Project.TPU_PROD_ENV_AUTOMATED | Project.CLOUD_TPU_INFERENCE_TEST: |
530 | | - # Production composer lacks permission for these projects; ignore them. |
| 534 | + # Production composer lacks permission for these projects; ignore them |
531 | 535 | continue |
532 | 536 | case _: |
533 | 537 | with TaskGroup( |
534 | 538 | group_id=f'validation_for_{project.value}', |
535 | 539 | tooltip=f'Validation pipeline for Project ID: {project.value}', |
536 | | - ) as group: |
| 540 | + ): |
537 | 541 | configs = Configs( |
538 | 542 | project_id=project.value, |
539 | 543 | platform=platform, |
|
0 commit comments