Skip to content

Commit

Permalink
Update measurements.py
Browse files Browse the repository at this point in the history
add set_time attribute for measurements
  • Loading branch information
wallacbe authored Feb 25, 2024
1 parent d1ebe96 commit 0476166
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion openhtf/core/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -504,7 +505,8 @@ class MeasuredValue(object):
stored_value = attr.ib(type=Optional[Any], default=None)
is_value_set = attr.ib(type=bool, default=False)
_cached_value = attr.ib(type=Optional[Any], default=None)

set_time_millis = attr.ib(type=int, default=None)

def __str__(self) -> Text:
return str(self.value) if self.is_value_set else 'UNSET'

Expand All @@ -527,6 +529,7 @@ def basetype_value(self) -> Any:

def set(self, value: Any) -> None:
"""Set the value for this measurement, with some sanity checks."""
self.set_time_millis = int(time.time() * 1000)

# Apply transform function if it is set.
if self.transform_fn:
Expand Down

0 comments on commit 0476166

Please sign in to comment.