From 54b9dccf42286d3afa963c2f2cfa8ff25aef0e07 Mon Sep 17 00:00:00 2001 From: kdsudac Date: Mon, 11 Jul 2016 17:53:57 -0700 Subject: [PATCH 1/7] few fixes for docs and examples --- .gitignore | 1 + README.md | 1 + examples/all_the_things.py | 2 +- examples/measurements.py | 4 ++-- setup.py | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 16a24cd1e..96e9ada71 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ htmlcov/ # virtualenv env/ venv/ +.env # built protos *_pb2.py diff --git a/README.md b/README.md index 81461144f..0779c510e 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ The fastest way to get started is to take a look in the `examples/` directory, where you'll find sample test scripts and plugs. In addition, many of OpenHTF's modules are fairly well documented inline through the use of docstrings. +Note: some of the `examples/` require protocol buffer code to be generated via `setup python.py build` command. This requires protocol buffer compiler library to be installed. ## Nomenclature OpenHTF uses certain nomenclature internally for several of its core concepts. diff --git a/examples/all_the_things.py b/examples/all_the_things.py index ef4800ab5..021e85dfe 100644 --- a/examples/all_the_things.py +++ b/examples/all_the_things.py @@ -15,7 +15,7 @@ """Example OpenHTF test logic. Run with (your virtualenv must be activated first): -python all_the_things.py --config=example_config.yaml +python all_the_things.py --config-file=example_config.yaml """ import json diff --git a/examples/measurements.py b/examples/measurements.py index 88c1d8204..4ab9467d5 100644 --- a/examples/measurements.py +++ b/examples/measurements.py @@ -93,7 +93,7 @@ def LotsOfMeasurements(test): # describing the measurement. Validators can get quite complex, for more # details, see the validators.py example. @measures(Measurement('validated_measurement').InRange(0, 10).Doc( - 'This measurement is validated.').WithUnits(UOM['SECOND'])) + 'This measurement is validated.').WithUnits(units.SECOND)) def MeasureSeconds(test): # The 'outcome' of this measurement in the test_record result will be a PASS # because its value passes the validator specified (0 <= 5 <= 10). @@ -106,7 +106,7 @@ def MeasureSeconds(test): # must be a string containing the measurement name). If you want to specify # multiple measurements this way, you can stack multiple decorators. @measures('inline_kwargs', docstring='This measurement is declared inline!', - units=UOM['HERTZ'], validators=[validators.InRange(0, 10)]) + units=units.HERTZ, validators=[validators.InRange(0, 10)]) @measures('another_inline', docstring='Because why not?') def InlinePhase(test): # This measurement will have an outcome of FAIL, because the set value of 15 diff --git a/setup.py b/setup.py index d4a69ec89..743342238 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ def initialize_options(self): if platform.system() == 'Linux': # Default to /usr? prefix = '/usr' - elif platform.system() == 'Mac': + elif platform.system() in ['Mac', 'Darwin']: # Default to /usr/local for Homebrew prefix = '/usr/local' else: From 93e5a47da87998b7a430a3e585ebd7e093bad538 Mon Sep 17 00:00:00 2001 From: kdsudac Date: Tue, 12 Jul 2016 10:05:44 -0700 Subject: [PATCH 2/7] linewrapping in readme and removing config-file flag --- README.md | 5 ++++- examples/all_the_things.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0779c510e..3e68df3b9 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,10 @@ The fastest way to get started is to take a look in the `examples/` directory, where you'll find sample test scripts and plugs. In addition, many of OpenHTF's modules are fairly well documented inline through the use of docstrings. -Note: some of the `examples/` require protocol buffer code to be generated via `setup python.py build` command. This requires protocol buffer compiler library to be installed. +Note: some of the `examples/` require protocol buffer code to be generated via +`setup python.py build` command. This requires protocol buffer compiler +library to be installed ( +[additional instructions](CONTRIBUTING.md#setting-up-your-dev-environment)) ## Nomenclature OpenHTF uses certain nomenclature internally for several of its core concepts. diff --git a/examples/all_the_things.py b/examples/all_the_things.py index 021e85dfe..cf89dcab3 100644 --- a/examples/all_the_things.py +++ b/examples/all_the_things.py @@ -15,7 +15,7 @@ """Example OpenHTF test logic. Run with (your virtualenv must be activated first): -python all_the_things.py --config-file=example_config.yaml +python all_the_things.py """ import json From 1d36938f715b123c223ee0c032774ba6eab60e3c Mon Sep 17 00:00:00 2001 From: kdsudac Date: Tue, 12 Jul 2016 10:09:36 -0700 Subject: [PATCH 3/7] linebreak change and added period --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3e68df3b9..e940d4b51 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ modules are fairly well documented inline through the use of docstrings. Note: some of the `examples/` require protocol buffer code to be generated via `setup python.py build` command. This requires protocol buffer compiler -library to be installed ( -[additional instructions](CONTRIBUTING.md#setting-up-your-dev-environment)) +library to be installed +([additional instructions](CONTRIBUTING.md#setting-up-your-dev-environment)). ## Nomenclature OpenHTF uses certain nomenclature internally for several of its core concepts. From bda78d5b234cff6c427e19444d7235d8108e5444 Mon Sep 17 00:00:00 2001 From: kdsudac Date: Tue, 12 Jul 2016 13:21:03 -0700 Subject: [PATCH 4/7] sort dict before converting to string so order is consistent. Should reduce flaky tests --- openhtf/io/output/mfg_inspector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openhtf/io/output/mfg_inspector.py b/openhtf/io/output/mfg_inspector.py index 49d88aaf7..fe6c0b00d 100644 --- a/openhtf/io/output/mfg_inspector.py +++ b/openhtf/io/output/mfg_inspector.py @@ -26,7 +26,6 @@ } } """ - import httplib2 import json import logging @@ -119,7 +118,8 @@ def _PopulateHeader(record, testrun): if 'config' in record.metadata: attachment = testrun.info_parameters.add() attachment.name = 'config' - attachment.value_binary = str(record.metadata['config']) + config = record.metadata['config'] + attachment.value_binary = str(dict(sorted(config.items()))) def _EnsureUniqueParameterName(name, used_parameter_names): From d2ceb50f68c14b891603e0b8cce52e530cdd7e50 Mon Sep 17 00:00:00 2001 From: kdsudac Date: Tue, 12 Jul 2016 14:08:18 -0700 Subject: [PATCH 5/7] adding back in whitespace --- openhtf/io/output/mfg_inspector.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openhtf/io/output/mfg_inspector.py b/openhtf/io/output/mfg_inspector.py index fe6c0b00d..082cdf1e7 100644 --- a/openhtf/io/output/mfg_inspector.py +++ b/openhtf/io/output/mfg_inspector.py @@ -26,6 +26,7 @@ } } """ + import httplib2 import json import logging From 421d57a6f258cde7e7aadedba65c1bf9eff69553 Mon Sep 17 00:00:00 2001 From: kdsudac Date: Tue, 12 Jul 2016 15:21:52 -0700 Subject: [PATCH 6/7] use fix from fahhem's cl --- openhtf/io/output/mfg_inspector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openhtf/io/output/mfg_inspector.py b/openhtf/io/output/mfg_inspector.py index 082cdf1e7..c18b97fee 100644 --- a/openhtf/io/output/mfg_inspector.py +++ b/openhtf/io/output/mfg_inspector.py @@ -119,8 +119,8 @@ def _PopulateHeader(record, testrun): if 'config' in record.metadata: attachment = testrun.info_parameters.add() attachment.name = 'config' - config = record.metadata['config'] - attachment.value_binary = str(dict(sorted(config.items()))) + attachment.value_binary = json.dumps( + record.metadata['config'], sort_keys=True, indent=4) def _EnsureUniqueParameterName(name, used_parameter_names): From c12ac392c264c7c0967cbf77922ec588439fee7b Mon Sep 17 00:00:00 2001 From: kdsudac Date: Tue, 12 Jul 2016 15:32:27 -0700 Subject: [PATCH 7/7] updating test data record.testrun for json metadata config --- test/io/output/record.testrun | Bin 16241 -> 16252 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/io/output/record.testrun b/test/io/output/record.testrun index 2a20dc934c42340dea186137dacd407f54b58dd1..857bfb3bdfa08f94335b9c8ebc763f7eb8d24cd4 100644 GIT binary patch delta 34 qcmexZ_or^dQ4ZdCF1F