Skip to content

Commit 8ff1ef1

Browse files
committed
Add histogram args tests
1 parent 2517f0f commit 8ff1ef1

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

qa/python_models/custom_metrics/model.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,11 @@ def test_histogram_e2e(self):
233233
description="test metric histogram kind end to end",
234234
kind=pb_utils.MetricFamily.HISTOGRAM,
235235
)
236-
labels = {"example1": "histogram_label1", "example2": "histogram_label2"}
237-
238-
# Test non-ascending order buckets
239-
with self.assertRaises(pb_utils.TritonModelException):
240-
metric = metric_family.Metric(
241-
labels=labels, buckets=[2.5, 0.1, 1.0, 10.0, 5.0]
242-
)
243236

237+
labels = {"example1": "histogram_label1", "example2": "histogram_label2"}
244238
buckets = [0.1, 1.0, 2.5, 5.0, 10.0]
245239
metric = metric_family.Metric(labels=labels, buckets=buckets)
240+
246241
labels_str = 'example1="histogram_label1",example2="histogram_label2"'
247242
self._histogram_api_helper(metric, name, labels_str)
248243

@@ -254,6 +249,25 @@ def test_histogram_e2e(self):
254249
self.assertEqual(metrics.count(sum_pattern), 1)
255250
self.assertEqual(metrics.count(bucket_pattern), len(buckets) + 1)
256251

252+
def test_histogram_args(self):
253+
name = "test_histogram_args"
254+
metric_family = pb_utils.MetricFamily(
255+
name=name,
256+
description="test metric histogram args",
257+
kind=pb_utils.MetricFamily.HISTOGRAM,
258+
)
259+
260+
# Test non-ascending order buckets
261+
with self.assertRaises(pb_utils.TritonModelException):
262+
metric_family.Metric(labels={}, buckets=[2.5, 0.1, 1.0, 10.0, 5.0])
263+
264+
# Test duplicate value buckets
265+
with self.assertRaises(pb_utils.TritonModelException):
266+
metric_family.Metric(labels={}, buckets=[1, 1, 2, 5, 5])
267+
268+
# Test non-ascending order buckets
269+
metric_family.Metric(labels={}, buckets=[])
270+
257271
def test_dup_metric_family_diff_kind(self):
258272
# Test that a duplicate metric family can't be added with a conflicting type/kind
259273
metric_family1 = pb_utils.MetricFamily(

0 commit comments

Comments
 (0)