anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: google/openhtf
Issue: Add mutablerecords==0.2.4 to setup.py to allow proper wheel installation

Add mutablerecords==0.2.4 to setup.py to allow proper wheel installation


Changed files:
setup.py

diff --git a/setup.py b/setup.py
index d314b08..36548b6 100644
--- a/setup.py
+++ b/setup.py
@@ -45,6 +45,7 @@ requires = [    # pylint: disable=invalid-name
     'libusb1==1.3.0',
     'M2Crypto==0.22.3',
     'MarkupSafe==0.23',
+    'mutablerecords==0.2.4',
     'pyaml==15.3.1',
     'python-gflags==2.0',
     'PyYAML==3.11',
Repository: google/openhtf
Issue: Start Test Prompt is timing out and raising PromptUnansweredError

Start Test Prompt appears to be using same timeout as user prompts.  When using this in loop mode we shouldn't have a timeout


Changed files:
openhtf/exe/triggers.py

diff --git a/openhtf/exe/triggers.py b/openhtf/exe/triggers.py
index 9068413..33d5d71 100644
--- a/openhtf/exe/triggers.py
+++ b/openhtf/exe/triggers.py
@@ -61,18 +61,20 @@ def AutoStop(dummy_dut_id):  # pylint: disable=invalid-name
 
 # pylint: disable=invalid-name
 def PromptForTestStart(message='Provide a DUT ID in order to start the test.',
-                       text_input=True):
+                       text_input=False, timeout_s=60*60*24):
   """Make a test start trigger based on prompting the user for input."""
   def trigger():  # pylint: disable=missing-docstring
     prompt_manager = user_input.get_prompt_manager()
-    return prompt_manager.DisplayPrompt(message, text_input=text_input)
+    return prompt_manager.DisplayPrompt(
+        message, text_input=text_input, timeout_s=timeout_s)
   return trigger
 
 
 def PromptForTestStop(message='Hit ENTER to complete the test.',
-                      text_input=False):
+                      text_input=False, timeout_s=60*60*24):
   """Make a test stop trigger based on prompting the user for a response."""
   def trigger(dummy_dut_id):  # pylint: disable=missing-docstring
     prompt_manager = user_input.get_prompt_manager()
-    return prompt_manager.DisplayPrompt(message, text_input=text_input)
+    return prompt_manager.DisplayPrompt(
+        message, text_input=text_input, timeout_s=timeout_s)
   return trigger
Repository: google/openhtf
Issue: flag a measurement as FAIL if the returned value is 'nan'

Can we flag a measurement as FAIL if the returned value is ‘nan’, if the measurement is assigned the pass/fail limits? Currently it’s marked as “PASS” as the example below. 

"measured_values":{"foo":"nan"},

"foo":{"units":{"uom_suffix":"dBmW","uom_code":"2N"},"outcome":"PASS","docstring":"blah","name":"foo","validators":["0 <= x <= 10"]},


Changed files:
openhtf/util/validators.py

diff --git a/openhtf/util/validators.py b/openhtf/util/validators.py
index 7d6667d..d57750a 100644
--- a/openhtf/util/validators.py
+++ b/openhtf/util/validators.py
@@ -50,16 +50,14 @@ if they are implemented by a class that has internal state that is not copyable
 by the default copy.deepcopy().
 """
 
-import numbers
-import re
 import sys
 
 
 class Validators(object):
+  """Validators class."""
 
-  def __init__(self, re_module, numbers_module):
-    self.re_module = re_module
-    self.numbers_module = numbers_module
+  def __init__(self, modules):
+    self.modules = modules
     self._validators = {}
 
   def Register(self, validator, name=None):
@@ -87,6 +85,11 @@ class Validators(object):
       self.maximum = maximum
 
     def __call__(self, value):
+      # pylint: disable=g-import-not-at-top
+      import math
+      # Check for nan
+      if math.isnan(value):
+        return False
       # Check for equal bounds first so we can use with non-numeric values.
       if self.minimum == self.maximum and value != self.minimum:
         return False
@@ -115,10 +118,10 @@ class Validators(object):
       return not self == other
 
   def Equals(self, value):
-    if isinstance(value, self.numbers_module.Number):
+    if isinstance(value, self.modules['numbers'].Number):
       return self.InRange(minimum=value, maximum=value)
     else:
-      return self.MatchesRegex(self.re_module.escape(value))
+      return self.MatchesRegex(self.modules['re'].escape(value))
 
   class RegexMatcher(object):
     """Validator to verify a string value matches a regex."""
@@ -145,7 +148,6 @@ class Validators(object):
   # We have to use our saved reference to the re module because this module
   # has lost all references by the sys.modules replacement and has been gc'd.
   def MatchesRegex(self, regex):
-    return self.RegexMatcher(regex, self.re_module.compile(regex))
-
+    return self.RegexMatcher(regex, self.modules['re'].compile(regex))
 
-sys.modules[__name__] = Validators(re, numbers)
+sys.modules[__name__] = Validators(sys.modules)
Repository: google/openhtf
Issue: mfg_inspector output broken.

Traceback (most recent call last):
  File "C:\\Users\\CameraLab02\\venv\\lib\\site-packages\\openhtf__init__.py", line 110, in OutputTestRecord
    output_cb(record)
  File "C:\\Users\\CameraLab02\\venv\\lib\\site-packages\\openhtf\\io\\output\\mfg_inspector.py", line 469, in **call**
    testrun = _TestRunFromTestRecord(test_record)
  File "C:\\Users\\CameraLab02\\venv\\lib\\site-packages\\openhtf\\io\\output\\mfg_inspector.py", line 334, in _TestRunFromTestRe
cord
    mangled_parameters = _ExtractParameters(record, testrun, used_parameter_names)
  File "C:\\Users\\CameraLab02\\venv\\lib\\site-packages\\openhtf\\io\\output\\mfg_inspector.py", line 260, in _ExtractParameters

```
for d in measurement.dimensions]
```

AttributeError: 'NoneType' object has no attribute 'encode'


Changed files:
openhtf/io/output/mfg_inspector.py

diff --git a/openhtf/io/output/mfg_inspector.py b/openhtf/io/output/mfg_inspector.py
index 65f52bd..3fe83c4 100644
--- a/openhtf/io/output/mfg_inspector.py
+++ b/openhtf/io/output/mfg_inspector.py
@@ -256,7 +256,8 @@ def _ExtractParameters(record, testrun, used_parameter_names):
         attachment = testrun.info_parameters.add()
         attachment.name = 'multidim_%s' % name
         dims = [{
-            'uom_suffix': d.uom_suffix.encode('utf8'), 'uom_code': d.uom_code}
+            'uom_suffix': d.uom_suffix and d.uom_suffix.encode('utf8'),
+            'uom_code': d.uom_code}
             for d in measurement.dimensions]
         # Refer to the module docstring for the expected schema.
         attachment.value_binary = json.dumps({
Repository: google/openhtf
Issue: "Provide a DUT ID in order to start the test" does not reliably print to stdout

Cloned repo from head, hello world hangs, CTRL+C shows:

python hello_world.py 
^C2016-05-16 16:25:54,533 - ERROR - Received SIGINT.
2016-05-16 16:25:54,534 - ERROR - Stopping Test due to SIGINT: None
Traceback (most recent call last):
  File "hello_world.py", line 87, in <module>
    test.Execute(test_start=triggers.PromptForTestStart())
  File "/home/source/openhtf/openhtf/**init**.py", line 181, in Execute
    record = self._executor.GetState().GetFinishedRecord()
AttributeError: 'NoneType' object has no attribute 'GetFinishedRecord'


Changed files:
openhtf/io/user_input.py

diff --git a/openhtf/io/user_input.py b/openhtf/io/user_input.py
index a545271..8858e05 100644
--- a/openhtf/io/user_input.py
+++ b/openhtf/io/user_input.py
@@ -157,7 +157,7 @@ class ConsolePrompt(threading.Thread):
         print self._message
 
         # Before reading, clear any lingering buffered terminal input.
-        termios.tcflush(sys.stdin, termios.TCIOFLUSH)
+        termios.tcflush(sys.stdin, termios.TCIFLUSH)
 
         while not self._stopped:
           inputs, _, _ = select.select([sys.stdin], [], [], 0.001)