|
56 | 56 | from ray.data.context import DataContext |
57 | 57 | from ray.data.tests.util import column_udf |
58 | 58 | from ray.tests.conftest import * # noqa |
| 59 | +from ray.util.metrics import Gauge |
59 | 60 |
|
60 | 61 |
|
61 | 62 | @dataclass(frozen=True) |
@@ -353,7 +354,6 @@ def gen_expected_metrics( |
353 | 354 | "'average_rows_outputs_per_task': N", |
354 | 355 | "'op_task_duration_stats': {'num_samples': N, 'mean': N, 'variance': N, 'min': N, 'max': N, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P}", |
355 | 356 | "'max_uss_bytes': H", |
356 | | - "'average_max_uss_per_task': H", |
357 | 357 | "'num_inputs_received': N", |
358 | 358 | "'num_row_inputs_received': N", |
359 | 359 | "'bytes_inputs_received': N", |
@@ -443,7 +443,6 @@ def gen_expected_metrics( |
443 | 443 | "'average_rows_outputs_per_task': None", |
444 | 444 | "'op_task_duration_stats': {'num_samples': Z, 'mean': Z, 'variance': Z, 'min': None, 'max': None, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P}", |
445 | 445 | "'max_uss_bytes': H", |
446 | | - "'average_max_uss_per_task': H", |
447 | 446 | "'num_inputs_received': N", |
448 | 447 | "'num_row_inputs_received': N", |
449 | 448 | "'bytes_inputs_received': N", |
@@ -635,11 +634,6 @@ def canonicalize( |
635 | 634 | # Replace tabs with spaces. |
636 | 635 | canonicalized_stats = re.sub("\t", " ", canonicalized_stats) |
637 | 636 |
|
638 | | - canonicalized_stats = re.sub( |
639 | | - r"(average_max_uss_per_task:|'average_max_uss_per_task':) (?:N|Z|None)\b", |
640 | | - r"\g<1> H", |
641 | | - canonicalized_stats, |
642 | | - ) |
643 | 637 | # Percentile values in DistributionTracker dicts can be None (when datasketches |
644 | 638 | # is not installed) or a number (canonicalized to N). Normalize to P. |
645 | 639 | canonicalized_stats = re.sub( |
@@ -932,7 +926,6 @@ def test_dataset__repr__(ray_start_regular_shared, restore_data_context): |
932 | 926 | " average_rows_outputs_per_task: N,\n" |
933 | 927 | " op_task_duration_stats: {'num_samples': N, 'mean': N, 'variance': N, 'min': N, 'max': N, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P},\n" |
934 | 928 | " max_uss_bytes: H,\n" |
935 | | - " average_max_uss_per_task: H,\n" |
936 | 929 | " num_inputs_received: N,\n" |
937 | 930 | " num_row_inputs_received: N,\n" |
938 | 931 | " bytes_inputs_received: N,\n" |
@@ -1097,7 +1090,6 @@ def check_stats(): |
1097 | 1090 | " average_rows_outputs_per_task: N,\n" |
1098 | 1091 | " op_task_duration_stats: {'num_samples': N, 'mean': N, 'variance': N, 'min': N, 'max': N, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P},\n" |
1099 | 1092 | " max_uss_bytes: H,\n" |
1100 | | - " average_max_uss_per_task: H,\n" |
1101 | 1093 | " num_inputs_received: N,\n" |
1102 | 1094 | " num_row_inputs_received: N,\n" |
1103 | 1095 | " bytes_inputs_received: N,\n" |
@@ -1215,7 +1207,6 @@ def check_stats(): |
1215 | 1207 | " average_rows_outputs_per_task: N,\n" |
1216 | 1208 | " op_task_duration_stats: {'num_samples': N, 'mean': N, 'variance': N, 'min': N, 'max': N, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P, 'pN': P},\n" |
1217 | 1209 | " max_uss_bytes: H,\n" |
1218 | | - " average_max_uss_per_task: H,\n" |
1219 | 1210 | " num_inputs_received: N,\n" |
1220 | 1211 | " num_row_inputs_received: N,\n" |
1221 | 1212 | " bytes_inputs_received: N,\n" |
@@ -2017,6 +2008,46 @@ def test_stats_actor_iter_metrics(): |
2017 | 2008 | assert update_fn.call_args_list[-1].args[2] is None |
2018 | 2009 |
|
2019 | 2010 |
|
| 2011 | +def test_stats_actor_exports_distribution_metrics(): |
| 2012 | + actor = _StatsActor.__ray_metadata__.modified_class() |
| 2013 | + |
| 2014 | + metrics = actor.execution_metrics_tasks["max_uss_bytes"] |
| 2015 | + assert set(metrics) == {"mean", "max"} |
| 2016 | + for statistic, metric in metrics.items(): |
| 2017 | + assert isinstance(metric, Gauge) |
| 2018 | + assert metric.info["name"] == f"data_max_uss_bytes_{statistic}" |
| 2019 | + assert metric.info["tag_keys"] == ("dataset", "operator") |
| 2020 | + |
| 2021 | + actor.update_dataset = MagicMock() |
| 2022 | + |
| 2023 | + with ( |
| 2024 | + patch.object(metrics["mean"], "set") as set_mean, |
| 2025 | + patch.object(metrics["max"], "set") as set_max, |
| 2026 | + ): |
| 2027 | + actor.update_execution_metrics( |
| 2028 | + "dataset_1", |
| 2029 | + [{"max_uss_bytes": {"num_samples": 0, "mean": 0, "max": None}}], |
| 2030 | + ["MapBatches_1"], |
| 2031 | + {}, |
| 2032 | + ) |
| 2033 | + set_mean.assert_not_called() |
| 2034 | + set_max.assert_not_called() |
| 2035 | + |
| 2036 | + actor.update_execution_metrics( |
| 2037 | + "dataset_1", |
| 2038 | + [{"max_uss_bytes": {"num_samples": 2, "mean": 200, "max": 300}}], |
| 2039 | + ["MapBatches_1"], |
| 2040 | + {}, |
| 2041 | + ) |
| 2042 | + |
| 2043 | + set_mean.assert_called_once_with( |
| 2044 | + 200, {"dataset": "dataset_1", "operator": "MapBatches_1"} |
| 2045 | + ) |
| 2046 | + set_max.assert_called_once_with( |
| 2047 | + 300, {"dataset": "dataset_1", "operator": "MapBatches_1"} |
| 2048 | + ) |
| 2049 | + |
| 2050 | + |
2020 | 2051 | @pytest.mark.parametrize( |
2021 | 2052 | "split_index_arg, expected_split_label", |
2022 | 2053 | [ |
|
0 commit comments