[Metrics] Call GetMeasureDoubleByName to prevent override (#12860)

This commit is contained in:
Simon Mo
2020-12-15 09:39:39 -08:00
committed by GitHub
parent 5a142d5bd6
commit b291dd4486
2 changed files with 41 additions and 2 deletions
+28
View File
@@ -2,6 +2,7 @@ import json
import pathlib
import platform
from pprint import pformat
import time
from unittest.mock import MagicMock
import requests
@@ -293,6 +294,33 @@ def test_custom_metrics_edge_cases(metric_mock):
Count("name", tag_keys=("a"))
def test_metrics_override_shouldnt_warn(ray_start_regular, log_pubsub):
# https://github.com/ray-project/ray/issues/12859
@ray.remote
def override():
a = Count("num_count", description="")
b = Count("num_count", description="")
a.record(1)
b.record(1)
ray.get(override.remote())
# Check the stderr from the worker.
start = time.time()
while True:
if (time.time() - start) > 5:
break
msg = log_pubsub.get_message()
if msg is None:
time.sleep(0.01)
continue
log_lines = json.loads(ray.utils.decode(msg["data"]))["lines"]
for line in log_lines:
assert "Attempt to register measure" not in line
if __name__ == "__main__":
import sys
sys.exit(pytest.main(["-v", __file__]))