From 982e63140d02787e5b5acfa4616471fe1c0fb746 Mon Sep 17 00:00:00 2001
From: Markus Willman <mpewil@utu.fi>
Date: Sat, 10 Mar 2018 11:53:10 +0200
Subject: [PATCH] wrap up: harden requirements files - things are less likely
 to break when left unattended - update README.md

---
 Dockerfile                  |  5 ++++-
 README.md                   | 19 ++++++++++++------
 requirements.dev.txt        | 21 ++++++++++++++++++++
 requirements.txt            | 39 +++++++++++++++++++------------------
 system-requirements.dev.txt |  2 ++
 system-requirements.txt     |  4 ++--
 6 files changed, 62 insertions(+), 28 deletions(-)
 create mode 100644 requirements.dev.txt
 create mode 100644 system-requirements.dev.txt

diff --git a/Dockerfile b/Dockerfile
index 0903264..76f27f7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -27,7 +27,10 @@ RUN apt-get update -qqy --fix-missing \
 	&& ln -s /opt/services/smartbusstop/conf/nginx/default.conf /etc/nginx/conf.d/default.conf \
 	&& ln -s /opt/services/smartbusstop/conf/supervisor/nginx.conf /etc/supervisor/conf.d/01_nginx.conf \
 	&& ln -s /opt/services/smartbusstop/conf/supervisor/smartbusstop.conf /etc/supervisor/conf.d/02_smartbusstop.conf \
-	&& git clone --depth=1 --branch=master https://github.com/oarriaga/face_classification /opt/services/smartbusstop/face_classification \
+	&& git clone --branch=master https://github.com/oarriaga/face_classification /opt/services/smartbusstop/face_classification \
+	&& cd /opt/services/smartbusstop/face_classification \
+	&& git reset --hard eb5d76ffd1a13c450a1dabb4f249d08cb2bd64b3 \
+	&& cd /opt/services/smartbusstop \
 	&& rm -rf /opt/services/smartbusstop/face_classification/.git \
 	&& apt-get remove -qqy --purge git \
 	&& apt-get autoremove -y
diff --git a/README.md b/README.md
index c0dc7fb..61848cf 100644
--- a/README.md
+++ b/README.md
@@ -72,19 +72,26 @@ storing them in this git repository itself.
 Changes must be deployed manually through the gitlab web UI, using the "Run pipeline"
 button under CI / CD > [Pipelines](https://gitlab.utu.fi/Smart_Bus_Stop/tensorflow-server/pipelines).
 
-### API endpoints (tentative)
+### Database
 
-**TODO**
+The database schema and access details are located in `contrib/src/web/database.py`
+the same file can also be ran as a CLI script to create an empty database if it does 
+not yet exist.
+
+Currently the docker container running the database is expected to be linked under the
+name `database` (rancher-compose/docker-compose) using the default PostgreSQL port.
+
+### API endpoints
 
 The api endpoints are similar to what had been defined upstream, notably support
 for GET requests and json results has been added. The ability to turn emotion
 detection on or off was also added and the processor code refactored for  more
 control and better memory management. 
 
-There is no usage control or sanity checks which is a problem. *Logging requests is
-largely absent when they succeed.* Version number added as part of the URI same as
-frontend WIP endpoints. Stop code can optionally be passed as a query string argument
-(stop_code), but it is only logged for processing errors.
+There is no usage control or sanity checks which is a problem. Version number was
+added as part of the URI same as frontend endpoints. Stop code can optionally
+be passed as a query string argument (stop_code), it is logged for erros and in
+the database alongside classification results.
 
 ```
 URI: POST /api/v1/classifyImage[/<type>][?stop_code=<gtfs_stop_code>&detect_emotion=<1/0>]
diff --git a/requirements.dev.txt b/requirements.dev.txt
new file mode 100644
index 0000000..009f1a8
--- /dev/null
+++ b/requirements.dev.txt
@@ -0,0 +1,21 @@
+Flask>=0.12.2
+flask-request-id-middleware
+numpy
+scipy
+scikit-learn
+pillow
+tensorflow
+pandas
+h5py
+opencv-python==3.2.0.8
+keras
+statistics
+pyyaml
+pyparsing
+cycler
+matplotlib
+requests
+psycopg2-binary
+peewee
+python-dateutil
+pytz
diff --git a/requirements.txt b/requirements.txt
index ef6865f..8b09f0e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,20 +1,21 @@
-Flask>=0.12.2
-flask-request-id-middleware
-numpy
-scipy
-scikit-learn
-pillow
-tensorflow
-pandas
-h5py
+Flask==0.12.2
+flask-request-id-middleware==1.1
+numpy==1.14.1
+scikit-learn==0.19.1
+scipy==1.0.0
+pillow==5.0.0
+tensorflow==1.6.0
+pandas==0.22.0
+h5py==2.7.1
 opencv-python==3.2.0.8
-keras
-statistics
-pyyaml
-pyparsing
-cycler
-matplotlib
-requests
-psycopg2-binary
-peewee
-python-dateutil
+keras==2.1.4
+statistics==1.0.3.5
+pyyaml==3.12
+pyparsing==2.2.0
+cycler==0.10.0
+matplotlib==2.1.2
+requests==2.18.4
+psycopg2-binary==2.7.4
+peewee==3.1.2
+python-dateutil==2.6.1
+pytz
diff --git a/system-requirements.dev.txt b/system-requirements.dev.txt
new file mode 100644
index 0000000..6c1399c
--- /dev/null
+++ b/system-requirements.dev.txt
@@ -0,0 +1,2 @@
+uWSGI>=2.0.15
+virtualenv>=15.1.0
diff --git a/system-requirements.txt b/system-requirements.txt
index 6c1399c..743ccbd 100644
--- a/system-requirements.txt
+++ b/system-requirements.txt
@@ -1,2 +1,2 @@
-uWSGI>=2.0.15
-virtualenv>=15.1.0
+uWSGI==2.0.17
+virtualenv==15.1.0
-- 
GitLab