Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Reset telemetry client between tests

James Murdza34d160eabd78
diff --git a/libs/python/core/core/telemetry/__init__.py b/libs/python/core/core/telemetry/__init__.py
index 04f3f05764..fe55bb8b58 100644
--- a/libs/python/core/core/telemetry/__init__.py
+++ b/libs/python/core/core/telemetry/__init__.py
@@ -13,6 +13,7 @@ from core.telemetry.telemetry import (
record_event,
is_telemetry_enabled,
is_telemetry_globally_disabled,
+ destroy_telemetry_client,
)
@@ -26,4 +27,5 @@ __all__ = [
"record_event",
"is_telemetry_enabled",
"is_telemetry_globally_disabled",
+ "destroy_telemetry_client",
]
diff --git a/libs/python/core/core/telemetry/telemetry.py b/libs/python/core/core/telemetry/telemetry.py
index f01421cda7..c04423f8c5 100644
--- a/libs/python/core/core/telemetry/telemetry.py
+++ b/libs/python/core/core/telemetry/telemetry.py
@@ -190,6 +190,10 @@ def get_telemetry_client(
return _universal_client
+def destroy_telemetry_client() -> None:
+ """Destroy the global telemetry client."""
+ global _universal_client
+ _universal_client = None
def increment(counter_name: str, value: int = 1) -> None:
"""Increment a named counter using the global telemetry client.
diff --git a/tests/test_telemetry.py b/tests/test_telemetry.py
index 0de0af6cfc..80a7877932 100644
--- a/tests/test_telemetry.py
+++ b/tests/test_telemetry.py
@@ -23,7 +23,7 @@ for path in pythonpath.split(":"):
sys.path.insert(0, path) # Insert at beginning to prioritize
print(f"Added to sys.path: {path}")
-from core.telemetry import record_event, is_telemetry_enabled
+from core.telemetry import record_event, is_telemetry_enabled, destroy_telemetry_client
class TestTelemetry:
@@ -31,6 +31,7 @@ class TestTelemetry:
"""Reset environment variables before each test"""
os.environ.pop('CUA_TELEMETRY', None)
os.environ.pop('CUA_TELEMETRY_ENABLED', None)
+ destroy_telemetry_client()
def test_telemetry_disabled_when_cua_telemetry_is_off(self):
"""Should return false when CUA_TELEMETRY is off"""