Parcourir la source

Merge branch 'release/v0.0.6'

Jérôme BUISINE il y a 4 ans
Parent
commit
0cc8bc1360
7 fichiers modifiés avec 104 ajouts et 15 suppressions
  1. 21 0
      Dockerfile
  2. 39 0
      Makefile
  3. 26 3
      README.md
  4. 7 5
      expe/expes/run.py
  5. 3 3
      expe/templates/expe/expe_indications.html
  6. 3 3
      expe/templates/expe/expe_list.html
  7. 5 1
      static/css/expe.css

+ 21 - 0
Dockerfile

@@ -0,0 +1,21 @@
+from python
+
+COPY . /usr/src/app
+WORKDIR /usr/src/app
+
+# Server port
+EXPOSE 8000
+
+RUN apt-get update
+
+# update project source code if necessary (use by default https protocol)
+RUN git remote set-url origin https://github.com/prise-3d/Thesis-WebExpe-Django.git
+RUN git pull origin master
+
+# Install dependencies and prepare project
+RUN python --version
+RUN pip install -r requirements.txt
+RUN python manage.py makemigrations
+RUN python manage.py migrate
+
+CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

+ 39 - 0
Makefile

@@ -0,0 +1,39 @@
+build:
+	@echo "----------------------------------------------------------------"
+	@echo "Update of djangowebexpe image"
+	@echo "----------------------------------------------------------------"
+	docker build --no-cache . --tag djangowebexpe
+	@echo "----------------------------------------------------------------"
+	@echo "Image is now build you can run instance using 'make run'
+	@echo "----------------------------------------------------------------"
+
+run: 
+	@echo "----------------------------------------------------------------"
+	@echo "Process to run new instance"
+	@echo "----------------------------------------------------------------"
+	docker run -p 8000:8000 -it -d --name webexpeinstance djangowebexpe
+	@echo "----------------------------------------------------------------"
+	@echo "Your docker instance is now launched with name 'webexpeinstance'"
+	@echo "Your website is now accessible at http://localhost:8000"
+	@echo "----------------------------------------------------------------"
+
+stop:
+	@echo "----------------------------------------------------------------"
+	@echo "Process to stop current instance"
+	@echo "----------------------------------------------------------------"
+	docker stop webexpeinstance
+	@echo "----------------------------------------------------------------"
+	@echo "App is now stopped"
+	@echo "----------------------------------------------------------------"
+
+remove:
+	@echo "----------------------------------------------------------------"
+	@echo "Process to stop current instance"
+	@echo "----------------------------------------------------------------"
+	docker stop webexpeinstance
+	docker rm webexpeinstance
+	@echo "----------------------------------------------------------------"
+	@echo "App is now stopped and removed"
+	@echo "----------------------------------------------------------------"
+
+deploy: build run

+ 26 - 3
README.md

@@ -6,15 +6,17 @@ Web site which contains experiences on synthesis images (perception of noise).
 
 ## Installation
 
-## Requirements
+### 1. Manually
+
+#### Requirements
 
 You need to have python, pip
 
 ```
-pip install -r requirements.txt
+pip install -r requirementst.txt
 ```
 
-## Run server
+#### Run server
 
 And then, run the server :
 
@@ -28,6 +30,27 @@ or if you want to precise a specific port number :
 python project/manage.py runserver 8080
 ```
 
+### 2. Using docker (recommended)
+
+You can use make commands:
+
+```
+make build
+```
+
+```
+make run
+```
+
+Or simply:
+
+```
+make deploy
+```
+
+Will run `build` and `run` commands at once.
+
+You also have `stop` and `remove` commands to stop and remove current generated docker instance.
 
 ## How to contribute ?
 

+ 7 - 5
expe/expes/run.py

@@ -23,14 +23,16 @@ def run_quest_one_image(request, model_filepath, output_file):
     expe_name = request.session.get('expe')
 
     # by default
-    iterations = 0
+    iteration = 0
+
+    # used to stop when necessary
+    if 'iteration' in request.GET:
+        iteration = int(request.GET.get('iteration'))
 
     # first time only init `quest`
     # if experience is started we can save data
     if request.session.get('expe_started'):
         answer = int(request.GET.get('answer'))
-        iterations = int(request.GET.get('iteration'))
-
         answer_time = time.time() - request.session['answer_time']
         print("Answer time is ", answer_time)
         previous_percentage = request.session.get('expe_percentage')
@@ -51,7 +53,7 @@ def run_quest_one_image(request, model_filepath, output_file):
         qp = pickle.load(filehandler)
     
     # construct image and update `quest` only if necessary
-    if iterations < cfg.expes_configuration[expe_name]['params']['iterations']:
+    if iteration < cfg.expes_configuration[expe_name]['params']['iterations']:
         # process `quest`
         next_stim = qp.next_contrast()
         print("Next quality ", next_stim)
@@ -72,7 +74,7 @@ def run_quest_one_image(request, model_filepath, output_file):
         # TODO : check `i` variable 
         # update of `quest`
         # qp.update(qualities[i], answer)
-        qp.update(qualities[iterations], answer) 
+        qp.update(qualities[iteration], answer) 
         entropy = qp.get_entropy()
 
         line = str(next_stim) 

+ 3 - 3
expe/templates/expe/expe_indications.html

@@ -9,10 +9,10 @@
 {% block content %}
     
     <h3>{{question}}</h3>
-    <p>{{indication}}</p>
-
     <br />
-    <p>Press enter to begin experience</p>
+    <h5>{{indication}}</h5>
+
+    <p id="expeIndication"><strong>Press enter to begin experience</strong></p>
     
     {% block javascripts %}
         <script src="{% static "js/indications.js" %}"></script>

+ 3 - 3
expe/templates/expe/expe_list.html

@@ -7,10 +7,10 @@
 {% endblock %}
 
 {% block content %}
-    <p>Choose you experience and dataset</p>
+    <h2>Choose you experience and dataset</h2>
 
     <div class="row">
-        <div class="col-md-4 col-md-offset-4">
+        <div class="col-md-4 offset-md-4">
             <form action="/indications" id="expeChoice">
 
                 <div class="form-group">
@@ -23,7 +23,7 @@
                 </div>
 
                 <div class="form-group">
-                    <label for="expe">Select experience:</label>
+                    <label for="expe" style="position:static">Select experience:</label>
                     <select class="form-control " name="expe">
                         {% for expe in expes %}
                             <option value="{{expe}}">{{expe}}</option>

+ 5 - 1
static/css/expe.css

@@ -1,5 +1,5 @@
 body {
-    background-color: grey;
+    background-color: lightgrey;
 }
 
 .container{
@@ -9,4 +9,8 @@ body {
 
 #expeImg{
     display: none;
+}
+
+#expeIndication{
+    margin-top: 30%;
 }