From 1c6103588dc7fc452face3b37e3447314e985c3f Mon Sep 17 00:00:00 2001 From: jaredonline Date: Sat, 10 Aug 2019 19:12:57 -0700 Subject: [PATCH 1/7] Docker Init Getting going on a docker environment for testing --- Makefile | 2 ++ docker-compose.yml | 7 +++++++ docker/test/Dockerfile | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 Makefile create mode 100644 docker-compose.yml create mode 100644 docker/test/Dockerfile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9479642 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +test: + docker-compose run test \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2d01359 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '3' +services: + test: + build: + context: . + dockerfile: docker/test/Dockerfile + command: which conda \ No newline at end of file diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile new file mode 100644 index 0000000..9d5eaf7 --- /dev/null +++ b/docker/test/Dockerfile @@ -0,0 +1,6 @@ +FROM continuumio/anaconda3 + +SHELL ["/bin/bash"] + + +CMD ["/bin/bash"] \ No newline at end of file From c4059c59d58ac2eb1bf426f2f43ddc5c29a3c9d8 Mon Sep 17 00:00:00 2001 From: jaredonline Date: Sun, 11 Aug 2019 07:17:23 -0700 Subject: [PATCH 2/7] Test harness is in place The dockerfied test harness is in place and tests are discovered and run. They currently fail because module import isn't quite right yet, but we'll get there. --- Makefile | 3 ++- Test/test.sh | 2 ++ Test/timeSeries/readUnrTxyz2_test.py | 7 +++++++ docker-compose.yml | 2 +- docker/test/Dockerfile | 8 ++++++-- 5 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 Test/test.sh create mode 100644 Test/timeSeries/readUnrTxyz2_test.py diff --git a/Makefile b/Makefile index 9479642..bf02b95 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,3 @@ +.PHONY: test test: - docker-compose run test \ No newline at end of file + docker-compose down && docker-compose build test && docker-compose run test && docker-compose down \ No newline at end of file diff --git a/Test/test.sh b/Test/test.sh new file mode 100644 index 0000000..b11842c --- /dev/null +++ b/Test/test.sh @@ -0,0 +1,2 @@ +. /opt/conda/bin/activate && \ +python -m pytest diff --git a/Test/timeSeries/readUnrTxyz2_test.py b/Test/timeSeries/readUnrTxyz2_test.py new file mode 100644 index 0000000..235df64 --- /dev/null +++ b/Test/timeSeries/readUnrTxyz2_test.py @@ -0,0 +1,7 @@ +import sys +sys.path.append("../../Lib") + +import timeSeries as ts + +def test_readUnrTxyz2(): + assert True == True \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 2d01359..e5b03ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,4 +4,4 @@ services: build: context: . dockerfile: docker/test/Dockerfile - command: which conda \ No newline at end of file + command: "./Test/test.sh" \ No newline at end of file diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile index 9d5eaf7..d50a221 100644 --- a/docker/test/Dockerfile +++ b/docker/test/Dockerfile @@ -1,6 +1,10 @@ FROM continuumio/anaconda3 -SHELL ["/bin/bash"] +RUN mkdir -p /tstools +COPY ./Lib /tstools/Lib +COPY ./Test /tstools/Test +WORKDIR /tstools +RUN chmod +x Test/test.sh -CMD ["/bin/bash"] \ No newline at end of file +ENTRYPOINT [ "/bin/bash"] \ No newline at end of file From 45944f0cde9434692cfa695e5da8274377920dcb Mon Sep 17 00:00:00 2001 From: jaredonline Date: Sun, 11 Aug 2019 07:26:12 -0700 Subject: [PATCH 3/7] Add some comments to files --- Makefile | 7 +++++++ Test/test.sh | 7 +++++-- docker-compose.yml | 12 ++++++++++++ docker/test/Dockerfile | 13 ++++++++++++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bf02b95..a80453b 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,10 @@ +# This marks the "test" target as 'phony', which means that it isn't based on actual +# files. Make has a ton of magic in it, and one of the bits of magic is it won't +# rebuild a target if it doesn't think any of its dependencies have changed. Phony +# means its not based on on-disk targets, so always build it when invoked .PHONY: test + +# The test target makes sure all docker images are up to date and runs the test +# suite test: docker-compose down && docker-compose build test && docker-compose run test && docker-compose down \ No newline at end of file diff --git a/Test/test.sh b/Test/test.sh index b11842c..a91863f 100644 --- a/Test/test.sh +++ b/Test/test.sh @@ -1,2 +1,5 @@ -. /opt/conda/bin/activate && \ -python -m pytest +# initialize Anaconda +. /opt/conda/bin/activate + +# Run our test suite +pytest diff --git a/docker-compose.yml b/docker-compose.yml index e5b03ae..071eef4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,19 @@ +# The full docker-compose spec is available here: https://docs.docker.com/compose/compose-file/#reference-and-guidelines version: '3' + +# docker-compose allows you to bundle a bunch of docker concepts together into +# a unit that all needs to be run at this same time. This could be many containers, +# volumes, or the networking between them all. services: + + # our test service is the image built specifically to run our test environment, + # and if we ever get CI/CD setup it will be what we run test: build: context: . dockerfile: docker/test/Dockerfile + + # we unfortunately can't invode "pytest" directly due to some weirdness with + # how Ananaconda sets up environments, so we use a wrapper script. This is + # run inside the docker container when it boots up command: "./Test/test.sh" \ No newline at end of file diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile index d50a221..8c7166d 100644 --- a/docker/test/Dockerfile +++ b/docker/test/Dockerfile @@ -1,10 +1,21 @@ +# This is the official Ananaconda Dockerfile maintained by ContinuumIO. At some point +# we will probably want to peg this to a specific version that TSTools supports FROM continuumio/anaconda3 +# Create a directory for our code RUN mkdir -p /tstools + +# Copy in the Library code COPY ./Lib /tstools/Lib + +# Copy in the test code COPY ./Test /tstools/Test +# Tell Docker that we want to do the rest of our work from this directory WORKDIR /tstools + +# Make our test runner executable RUN chmod +x Test/test.sh -ENTRYPOINT [ "/bin/bash"] \ No newline at end of file +# Set Bash as our entry +ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file From 631ec9f21f67956917337dbe910c9ee000fc77d0 Mon Sep 17 00:00:00 2001 From: jaredonline Date: Sun, 11 Aug 2019 07:40:46 -0700 Subject: [PATCH 4/7] Completely fucker up the directory structure This seems to be the cananocial source of organizing Python packages for consumption by other people or other programs: https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure I did most of what it recommends, with the caveat that I added a new level to differentiate by what language we're writing things in, now that I've introduced docker. If we have a bunch of bash or something else later, this will help keep things apart --- Lib/.gitkeep | 0 Test/README.md | 3 --- docker-compose.yml | 2 +- docker/test/Dockerfile | 11 +++++++---- python/src/timeSeries/__init__.py | 1 + {Lib => python/src/timeSeries}/timeSeries.py | 0 {Templates => python/templates}/README.md | 0 {Templates => python/templates}/module_temp.py | 0 {Templates => python/templates}/program_temp.py | 0 {Test => python/tests}/test.sh | 0 {Test => python/tests}/timeSeries/AREQ.IGS08.txyz2 | 0 .../tests}/timeSeries/readUnrTxyz2_test.py | 2 +- 12 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 Lib/.gitkeep delete mode 100644 Test/README.md create mode 100644 python/src/timeSeries/__init__.py rename {Lib => python/src/timeSeries}/timeSeries.py (100%) rename {Templates => python/templates}/README.md (100%) rename {Templates => python/templates}/module_temp.py (100%) rename {Templates => python/templates}/program_temp.py (100%) rename {Test => python/tests}/test.sh (100%) rename {Test => python/tests}/timeSeries/AREQ.IGS08.txyz2 (100%) rename {Test => python/tests}/timeSeries/readUnrTxyz2_test.py (74%) diff --git a/Lib/.gitkeep b/Lib/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Test/README.md b/Test/README.md deleted file mode 100644 index 0d47d64..0000000 --- a/Test/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Unit Test Directory - -Directory with unit tests for TSTools modules. diff --git a/docker-compose.yml b/docker-compose.yml index 071eef4..8a80350 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,4 +16,4 @@ services: # we unfortunately can't invode "pytest" directly due to some weirdness with # how Ananaconda sets up environments, so we use a wrapper script. This is # run inside the docker container when it boots up - command: "./Test/test.sh" \ No newline at end of file + command: "./test.sh" \ No newline at end of file diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile index 8c7166d..ae42a09 100644 --- a/docker/test/Dockerfile +++ b/docker/test/Dockerfile @@ -6,16 +6,19 @@ FROM continuumio/anaconda3 RUN mkdir -p /tstools # Copy in the Library code -COPY ./Lib /tstools/Lib +COPY ./python/src /tstools/src # Copy in the test code -COPY ./Test /tstools/Test +COPY ./python/tests /tstools/tests # Tell Docker that we want to do the rest of our work from this directory WORKDIR /tstools -# Make our test runner executable -RUN chmod +x Test/test.sh +# Move our test harness to the top-level directory to make Python pathing more happy +RUN mv tests/test.sh ./ + +# Make our test runner executable in the Docker container (not the local one) +RUN chmod +x ./test.sh # Set Bash as our entry ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file diff --git a/python/src/timeSeries/__init__.py b/python/src/timeSeries/__init__.py new file mode 100644 index 0000000..99c4176 --- /dev/null +++ b/python/src/timeSeries/__init__.py @@ -0,0 +1 @@ +__version__ = '0.0.1' \ No newline at end of file diff --git a/Lib/timeSeries.py b/python/src/timeSeries/timeSeries.py similarity index 100% rename from Lib/timeSeries.py rename to python/src/timeSeries/timeSeries.py diff --git a/Templates/README.md b/python/templates/README.md similarity index 100% rename from Templates/README.md rename to python/templates/README.md diff --git a/Templates/module_temp.py b/python/templates/module_temp.py similarity index 100% rename from Templates/module_temp.py rename to python/templates/module_temp.py diff --git a/Templates/program_temp.py b/python/templates/program_temp.py similarity index 100% rename from Templates/program_temp.py rename to python/templates/program_temp.py diff --git a/Test/test.sh b/python/tests/test.sh similarity index 100% rename from Test/test.sh rename to python/tests/test.sh diff --git a/Test/timeSeries/AREQ.IGS08.txyz2 b/python/tests/timeSeries/AREQ.IGS08.txyz2 similarity index 100% rename from Test/timeSeries/AREQ.IGS08.txyz2 rename to python/tests/timeSeries/AREQ.IGS08.txyz2 diff --git a/Test/timeSeries/readUnrTxyz2_test.py b/python/tests/timeSeries/readUnrTxyz2_test.py similarity index 74% rename from Test/timeSeries/readUnrTxyz2_test.py rename to python/tests/timeSeries/readUnrTxyz2_test.py index 235df64..e43ad0f 100644 --- a/Test/timeSeries/readUnrTxyz2_test.py +++ b/python/tests/timeSeries/readUnrTxyz2_test.py @@ -1,5 +1,5 @@ import sys -sys.path.append("../../Lib") +sys.path.append("./src") import timeSeries as ts From 6ab6d5772e24dddad812441b49953b739e2434b7 Mon Sep 17 00:00:00 2001 From: jaredonline Date: Sun, 11 Aug 2019 07:43:31 -0700 Subject: [PATCH 5/7] Add newlines to ends of files --- Makefile | 2 +- docker-compose.yml | 2 +- docker/test/Dockerfile | 2 +- python/src/timeSeries/__init__.py | 2 +- python/tests/timeSeries/readUnrTxyz2_test.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index a80453b..c13bd53 100644 --- a/Makefile +++ b/Makefile @@ -7,4 +7,4 @@ # The test target makes sure all docker images are up to date and runs the test # suite test: - docker-compose down && docker-compose build test && docker-compose run test && docker-compose down \ No newline at end of file + docker-compose down && docker-compose build test && docker-compose run test && docker-compose down diff --git a/docker-compose.yml b/docker-compose.yml index 8a80350..d99bbbd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,4 +16,4 @@ services: # we unfortunately can't invode "pytest" directly due to some weirdness with # how Ananaconda sets up environments, so we use a wrapper script. This is # run inside the docker container when it boots up - command: "./test.sh" \ No newline at end of file + command: "./test.sh" diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile index ae42a09..45eca29 100644 --- a/docker/test/Dockerfile +++ b/docker/test/Dockerfile @@ -21,4 +21,4 @@ RUN mv tests/test.sh ./ RUN chmod +x ./test.sh # Set Bash as our entry -ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file +ENTRYPOINT [ "/bin/bash" ] diff --git a/python/src/timeSeries/__init__.py b/python/src/timeSeries/__init__.py index 99c4176..b8023d8 100644 --- a/python/src/timeSeries/__init__.py +++ b/python/src/timeSeries/__init__.py @@ -1 +1 @@ -__version__ = '0.0.1' \ No newline at end of file +__version__ = '0.0.1' diff --git a/python/tests/timeSeries/readUnrTxyz2_test.py b/python/tests/timeSeries/readUnrTxyz2_test.py index e43ad0f..d4023a1 100644 --- a/python/tests/timeSeries/readUnrTxyz2_test.py +++ b/python/tests/timeSeries/readUnrTxyz2_test.py @@ -4,4 +4,4 @@ import timeSeries as ts def test_readUnrTxyz2(): - assert True == True \ No newline at end of file + assert True == True From 661f453a71eaf222a884d2921f8a699f9e0846da Mon Sep 17 00:00:00 2001 From: jaredonline Date: Sun, 11 Aug 2019 08:00:37 -0700 Subject: [PATCH 6/7] Add a toplevel shell folder --- docker/test/Dockerfile | 4 ++-- python/tests/test.sh => shell/python-tests.sh | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename python/tests/test.sh => shell/python-tests.sh (100%) diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile index 45eca29..18680d4 100644 --- a/docker/test/Dockerfile +++ b/docker/test/Dockerfile @@ -14,8 +14,8 @@ COPY ./python/tests /tstools/tests # Tell Docker that we want to do the rest of our work from this directory WORKDIR /tstools -# Move our test harness to the top-level directory to make Python pathing more happy -RUN mv tests/test.sh ./ +# Copy in our test harness +COPY ./shell/python-tests.sh ./test.sh # Make our test runner executable in the Docker container (not the local one) RUN chmod +x ./test.sh diff --git a/python/tests/test.sh b/shell/python-tests.sh similarity index 100% rename from python/tests/test.sh rename to shell/python-tests.sh From 4c45de7d92a212ce25d64f3f850efe0b84bdab21 Mon Sep 17 00:00:00 2001 From: jaredonline Date: Sun, 11 Aug 2019 08:01:41 -0700 Subject: [PATCH 7/7] Update template module Make our module template follow the rules --- python/templates/module/__init__.py | 1 + python/templates/{ => module}/module_temp.py | 0 2 files changed, 1 insertion(+) create mode 100644 python/templates/module/__init__.py rename python/templates/{ => module}/module_temp.py (100%) diff --git a/python/templates/module/__init__.py b/python/templates/module/__init__.py new file mode 100644 index 0000000..6853c36 --- /dev/null +++ b/python/templates/module/__init__.py @@ -0,0 +1 @@ +__version__ = '0.0.0' \ No newline at end of file diff --git a/python/templates/module_temp.py b/python/templates/module/module_temp.py similarity index 100% rename from python/templates/module_temp.py rename to python/templates/module/module_temp.py