From 273b856a47b15c8ddd343a926cb26937e3057adc Mon Sep 17 00:00:00 2001 From: "T.J.Rogers" Date: Wed, 7 Nov 2018 18:03:19 -0500 Subject: [PATCH 1/8] Added a __main__ reference to get simple python invocation unittest working Re: python test_Scheduler.py -v --- tests/test_Scheduler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_Scheduler.py b/tests/test_Scheduler.py index e29a1e25..003b5f4e 100644 --- a/tests/test_Scheduler.py +++ b/tests/test_Scheduler.py @@ -121,3 +121,6 @@ def test_measurements(self): # should be unchanged assert seq == result + +if __name__ == "__main__": + unittest.main() From 81bb8f1a681298d1f26a872179e59d76646f35d8 Mon Sep 17 00:00:00 2001 From: "T.J.Rogers" Date: Fri, 9 Nov 2018 12:07:34 -0500 Subject: [PATCH 2/8] Added test_QGL comments regarding Git LFS data file usage (and error encountered when git-lfs library is NOT installed). --- tests/test_QGL.py | 14 ++++++++++++++ tests/test_pulse_types.py | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_QGL.py b/tests/test_QGL.py index 89615e54..b91156b0 100644 --- a/tests/test_QGL.py +++ b/tests/test_QGL.py @@ -88,7 +88,21 @@ def load(self): 'Warning: valid waveform file for {0} not found at: {1}'.format( caseName, fileName)) continue + # ----- + # print( "\n\rDBG::Calling \"with h5py.File( {0}, 'r')\"...".format( fileName) ) + # ----- + # The following pulls in Git Large File Storage (LFS) data files + # from cached signature references; if the h5py.File call fails + # with an OSError, double-check git-lfs library installation (in + # addition to git) -- + # + # Where git-lfs was NOT installed the h5py.File() call was observed + # returning: + # + # OSError: Unable to open file (file signature not found)) + # with h5py.File(fileName, 'r') as FID: + # print( "DBG::FID: {0}".format( FID)) for name, waveform in FID['/channels'].items(): validWaveform[name] = waveform[:] self.validWaveforms[caseName] = validWaveform diff --git a/tests/test_pulse_types.py b/tests/test_pulse_types.py index 69d8221f..7f574b4a 100644 --- a/tests/test_pulse_types.py +++ b/tests/test_pulse_types.py @@ -16,7 +16,9 @@ def setUp(self): self.q3 = QubitFactory('q3') self.q4 = QubitFactory('q4') - @unittest.skip("Type promition for CNOT(q1, q2) * X(q3) gives PulseBlock not CompoundGate. Looking into this issue.") + # This appears to run successfully with the skip commented out; + # TJR, 07 Nov 2018 + #@unittest.skip("Type promition for CNOT(q1, q2) * X(q3) gives PulseBlock not CompoundGate. Looking into this issue.") def test_promotion_rules(self): q1, q2, q3, q4 = self.q1, self.q2, self.q3, self.q4 @@ -28,3 +30,8 @@ def test_promotion_rules(self): assert( type(CNOT_CR(q1, q2) * X(q3)) == CompoundGate ) assert( type(X(q3) * CNOT_CR(q1, q2)) == CompoundGate ) assert( type(CNOT_CR(q1, q2) * CNOT_CR(q3, q4)) == CompoundGate ) + +# Added to support simple python invocation +# +if __name__ == "__main__": + unittest.main() From 6ca6ef8d485143b969823efc85995c8026f2b179 Mon Sep 17 00:00:00 2001 From: "T.J.Rogers" Date: Fri, 9 Nov 2018 12:27:18 -0500 Subject: [PATCH 3/8] Added README.md tail comment regarding Git LFS usage for some unittest data files. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 77a91176..5540bddb 100644 --- a/README.md +++ b/README.md @@ -63,3 +63,7 @@ The QGL config file will be created the first time you run `import QGL` or `from * networkx * iPython/Jupyter 4.0 (only for Jupyter notebooks) * ruamel_yaml + +## UnitTest data support +This repository uses the Git Large File Storage (LFS) extension to manage a few +UnitTest data files (see https://git-lfs.github.com/). From 355d1209984be4e253839400c6a47c549d92e25f Mon Sep 17 00:00:00 2001 From: "T.J.Rogers" Date: Wed, 14 Nov 2018 17:25:53 -0500 Subject: [PATCH 4/8] Defined ReadMeDocs.txt to briefly describe the MkDocs document library use case. --- ReadMe_Docs.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 ReadMe_Docs.txt diff --git a/ReadMe_Docs.txt b/ReadMe_Docs.txt new file mode 100644 index 00000000..0e42164e --- /dev/null +++ b/ReadMe_Docs.txt @@ -0,0 +1,6 @@ +#---------- 14 Nov 2018 +This repository uses the MkDocs (v0.17.2) utilities for documentation rendering. +From the repo root directory, "mkdocs --help" shows the options. +"mkdocs build" for example, writes a set of html documents under the ./site subdirectory + +(Aside: ./site is NOT currently in the .gitignore file; insertion pending for consistency). From 5cfc75d18e23a9be3050aa9be0e803135d58e5bd Mon Sep 17 00:00:00 2001 From: "T.J.Rogers" Date: Fri, 30 Nov 2018 13:12:02 -0500 Subject: [PATCH 5/8] Defined renderDocs.sh and runUnitTests.sh shell scripts to automate documentation rendering and unit test invocation logic. --- renderDocs.sh | 26 ++++++++++++++++++ runUnitTests.sh | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100755 renderDocs.sh create mode 100755 runUnitTests.sh diff --git a/renderDocs.sh b/renderDocs.sh new file mode 100755 index 00000000..04b03d12 --- /dev/null +++ b/renderDocs.sh @@ -0,0 +1,26 @@ +#!/bin/bash +echo "" +echo "#---------- $0 (QGL) start..." +echo "" +#----- Simple script to capture basic documentation rendering logic. + +echo "#-----Building QGL docs via ~:" + +export CMD="mkdocs build" +echo $CMD +echo "" +$CMD + +pushd . + +cd site +echo "" +echo "Target QGL documents list as follows:" +pwd +ls -l + + +echo "" +echo "#---------- $0 (QGL) stop." +echo "" + diff --git a/runUnitTests.sh b/runUnitTests.sh new file mode 100755 index 00000000..d063b6bf --- /dev/null +++ b/runUnitTests.sh @@ -0,0 +1,72 @@ +#!/bin/bash +echo "" +echo "#---------- $0 (QGL) start..." +echo "" +#----- Simple script to capture basic documentation rendering logic. + +pwd + +export szGit_LFS_Path=`which git-lfs` +echo "szGit_LFS_Path: [${szGit_LFS_Path}]" + + +# Instantiate the git lfs cached data files... +export CMD="git lfs pull" +echo "" +if [ -z ${szGit_LFS_Path} ]; then + echo "" + echo "#--------------------" + echo "# W A R N I N G -- git-lfs extension library unavailable;" + echo "# -- QGL h5 data file processing may fail." + echo "# << [${szGit_LFS_Path}] << 'which git-lfs'" + echo "#--------------------" +else + echo "git-lfs available; retrieving/instantiating cached QGL h5 data files via ~:" + echo $CMD + echo "" + $CMD +fi +echo "" + + +# Don't forget to set the BBN_MEAS_FILE reference. +export BBN_MEAS_FILE=tests/test_measure.yml + +echo "" +echo "#-----Unit-Testing general QGL (BBN_MEAS_FILE=${BBN_MEAS_FILE}) via ~:" +# -f option fails fast +#export CMD="python -m unittest discover . -v -f" +#export CMD="python -m unittest discover . -v" +# Trimm'ed down (non LFS unitest calls) syntax as follows: +export CMD="python -m unittest tests/test_A*.py tests/test_C*.py tests/test_Scheduler.py tests/test_config.py tests/test_pulse_types.py -v" +echo $CMD +echo "" +$CMD + +if [ -z ${szGit_LFS_Path} ]; then + echo "" + echo "#----- W A R N I N G:" + echo " Fast-failing unittest modules test_QGL.py, and test_Sequences.py," + echo " currently, due to git lfs data file dependencies; in-short, the" + echo " docker continuumio/miniconda load appears to omit the necessary" + echo " git-lfs library installation." + echo "" + echo " Without the git-lfs library extension, h5 data calls from these" + echo " modules typically error out with ~:" + echo " OSError: Unable to open file (file signature not found)" + echo "" + echo " If/when the git-lfs library becomes available in the docker load, " + echo " remove the \"-f\"from the invocation, below:" +fi + +echo "" +echo "#----- Testing LFS data file dependent QGL modules via ~:" +export CMD="python -m unittest tests.test_QGL tests.test_Sequences.py -v -f" +echo $CMD +echo "" +$CMD + +echo "" +echo "#---------- $0 (QGL) stop." +echo "" + From 3c72462c0912a245e6b29f865e30f527592ec2d2 Mon Sep 17 00:00:00 2001 From: "T.J.Rogers" Date: Fri, 30 Nov 2018 13:22:22 -0500 Subject: [PATCH 6/8] Corrected runUnitTests.sh description header. --- runUnitTests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runUnitTests.sh b/runUnitTests.sh index d063b6bf..5ff573ab 100755 --- a/runUnitTests.sh +++ b/runUnitTests.sh @@ -2,7 +2,7 @@ echo "" echo "#---------- $0 (QGL) start..." echo "" -#----- Simple script to capture basic documentation rendering logic. +#----- Simple script to capture unittest preparation and invocation logic. pwd From e124ef395897e1e5b4f3b4aa38abfd83229d5f73 Mon Sep 17 00:00:00 2001 From: "T.J.Rogers" Date: Tue, 4 Dec 2018 14:28:54 -0500 Subject: [PATCH 7/8] Fixed a typo in runUnitTests.sh (removed the .py reference in second test set). Added test_Sequences.py logic (set_awg_dir) to invoke config.load_conifg() when config.AWGDir is undefined. (when running as a stand-alone test, this case was causing failures). --- runUnitTests.sh | 4 +++- tests/test_Sequences.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/runUnitTests.sh b/runUnitTests.sh index 5ff573ab..ffab4f0f 100755 --- a/runUnitTests.sh +++ b/runUnitTests.sh @@ -61,7 +61,9 @@ fi echo "" echo "#----- Testing LFS data file dependent QGL modules via ~:" -export CMD="python -m unittest tests.test_QGL tests.test_Sequences.py -v -f" +# Careful -- in this format (tests.moduleName) DON'T cite the .py suffix +# (it will render an odd error regarding missing 'py' attribute) +export CMD="python -m unittest tests.test_QGL tests.test_Sequences -v -f" echo $CMD echo "" $CMD diff --git a/tests/test_Sequences.py b/tests/test_Sequences.py index e4f63ddb..0e1a7745 100644 --- a/tests/test_Sequences.py +++ b/tests/test_Sequences.py @@ -8,6 +8,11 @@ from QGL.Channels import Edge, Measurement, LogicalChannel, LogicalMarkerChannel, PhysicalMarkerChannel, PhysicalQuadratureChannel from QGL.drivers import APSPattern, APS2Pattern, TekPattern +# Pulled in logger to help debug stand-alone run issue with the config.AWGDir +# (the configuration was NOT gettng loaded when run independently) +# +import logging +logger = logging.getLogger( 'sequences') class AWGTestHelper(object): testFileDirectory = './tests/test_data/awg/' @@ -93,6 +98,13 @@ def get_qubits(self): def set_awg_dir(self, footer=""): cn = self.__class__.__name__ + if None == QGL.config.AWGDir: + logger.warning( "\n\r#----- EEE NULL QGL.config.AWGDir {%s} cited; calling load_config()...", QGL.config.AWGDir) + QGL.config.load_config() + logger.warning( "#----- Post load-config QGL.config.AWGDir: {%s}.\n\r", QGL.config.AWGDir) + #else: + # logger.warning( "\n\r#----- Using QGL.config.AWGDir {%s} 8-p", QGL.config.AWGDir) + self.awg_dir = os.path.abspath(QGL.config.AWGDir + os.path.sep + cn) self.truth_dir = os.path.abspath(self.testFileDirectory + os.path.sep + cn) From 89e64ca994aab96dd62c0bd1032c978a93988bcc Mon Sep 17 00:00:00 2001 From: Matthew Ware Date: Sat, 5 Jan 2019 19:14:29 -0500 Subject: [PATCH 8/8] fixed a mkdocs dep warning --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 5d43ff40..6ff817c8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,5 +1,5 @@ site_name: QGL -pages: +nav: - Intro: index.md - Configuration: config.md - Examples: examples.md