From 24a27fad7b9b87dd4a0da6d4257498667bf8c7f8 Mon Sep 17 00:00:00 2001 From: wallacbe Date: Sun, 25 Feb 2024 21:26:11 -0800 Subject: [PATCH 1/3] Add set_time_millis to measurement Add set_time_millis to measurement --- openhtf/core/measurements.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openhtf/core/measurements.py b/openhtf/core/measurements.py index e8cfd36d..bd317611 100644 --- a/openhtf/core/measurements.py +++ b/openhtf/core/measurements.py @@ -63,6 +63,7 @@ def WidgetTestPhase(test): import enum import functools import logging +import time import typing from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, Union @@ -189,6 +190,7 @@ class Measurement(object): outcome: One of the Outcome() enumeration values, starting at UNSET. marginal: A bool flag indicating if this measurement is marginal if the outcome is PASS. + set_time_millis: The time the measurement is set in milliseconds. _cached: A cached dict representation of this measurement created initially during as_base_types and updated in place to save allocation time. """ @@ -214,6 +216,7 @@ class Measurement(object): _notification_cb = attr.ib(type=Optional[Callable[[], None]], default=None) outcome = attr.ib(type=Outcome, default=Outcome.UNSET) marginal = attr.ib(type=bool, default=False) + set_time_millis = attr.ib(type=int, default=None) # Runtime cache to speed up conversions. _cached = attr.ib(type=Optional[Dict[Text, Any]], default=None) @@ -845,6 +848,7 @@ def __setitem__(self, name: Text, value: Any) -> None: 'Cannot set dimensioned measurement without indices') m.measured_value.set(value) m.notify_value_set() + m.set_time_millis = int(time.time() * 1000) def __getitem__(self, name: Text) -> Any: self._assert_valid_key(name) From 912af9135ca9d49c2554862e412185fb9e0a7901 Mon Sep 17 00:00:00 2001 From: wallacbe Date: Sun, 25 Feb 2024 21:38:03 -0800 Subject: [PATCH 2/3] Update diagnoses_test.py --- test/core/diagnoses_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/core/diagnoses_test.py b/test/core/diagnoses_test.py index 25814dfe..79a9aa0e 100644 --- a/test/core/diagnoses_test.py +++ b/test/core/diagnoses_test.py @@ -1164,6 +1164,7 @@ def check_record_diagnoser(phase_record): is_value_set=True, stored_value=True, cached_value=True), + set_time_millis=phase_record.measurements['pass_measure'].set_time_millis, cached=mock.ANY), phase_record.measurements['pass_measure']) self.assertEqual( htf.Measurement( @@ -1175,6 +1176,7 @@ def check_record_diagnoser(phase_record): stored_value=False, cached_value=False), validators=[is_true], + set_time_millis=phase_record.measurements['fail_measure'].set_time_millis, cached=mock.ANY), phase_record.measurements['fail_measure']) return None From 4cf0734afdde7e248cd6dd1c60fec826d8df3630 Mon Sep 17 00:00:00 2001 From: wallacbe Date: Mon, 26 Feb 2024 11:41:20 -0800 Subject: [PATCH 3/3] util.time_millis() util.time_millis() --- openhtf/core/measurements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openhtf/core/measurements.py b/openhtf/core/measurements.py index bd317611..9dbbc5a6 100644 --- a/openhtf/core/measurements.py +++ b/openhtf/core/measurements.py @@ -848,7 +848,7 @@ def __setitem__(self, name: Text, value: Any) -> None: 'Cannot set dimensioned measurement without indices') m.measured_value.set(value) m.notify_value_set() - m.set_time_millis = int(time.time() * 1000) + m.set_time_millis = util.time_millis() def __getitem__(self, name: Text) -> Any: self._assert_valid_key(name)