Skip to content

Commit 2d6df9a

Browse files
authored
Merge pull request #46 from ntorquet/dev
Documentation improved
2 parents 4bf3ce1 + ffb2e69 commit 2d6df9a

File tree

4 files changed

+58
-100
lines changed

4 files changed

+58
-100
lines changed

README.md

Lines changed: 57 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,25 @@ You can see the results divided in different tables, and download the whole in C
6161
![alt single move](https://github.com/ntorquet/lmt_toolkit_analysis/blob/main/lmt_toolkit_analysis/media/uploaded/img/screenshot_6_results.PNG?raw=true)
6262

6363

64-
## Licence
65-
LMT-toolkit analysis is released under the GPL v3.0 licence. See the [LICENSE](LICENSE) file.
64+
## Installation
65+
LMT-toolkit works thanks to 3 different servers:
66+
- a Django server with a REST API (Python)
67+
- a Nuxt server for the frontend (the interface) (JavaScript - Vue)
68+
- a Celery server to manage asynchronous tasks between the frontend and the Django server (Python)
6669

67-
Copyright (C) 2022 CNRS - INSERM - UNISTRA - ICS - IGBMC
70+
![alt LMT-toolkit schema](https://github.com/ntorquet/lmt_toolkit_analysis/blob/main/lmt_toolkit_analysis/media/uploaded/img/lmt-toolkit_schema.png?raw=true)
6871

69-
LMT-toolkit uses the LMT-analysis code provided on [GitHub](https://github.com/fdechaumont/lmt-analysis). This code is also under the GPL v3.0 licence.
72+
It is recommended to create a [python virtual environment](https://docs.python.org/3/library/venv.html) into the root folder of the application to
73+
install the python required packages.
74+
[To run the 3 servers, we need 3 command prompts.](##How-to-launch-the-application-on-a-Windows-computer)
7075

71-
## Python Requirements (See [requirements.txt](requirements.txt))
76+
### Python Requirements (See [requirements.txt](requirements.txt))
7277
- Django>=4.0.2
7378
- djangorestframework==3.14
7479
- django-filter==21.1
7580
- djoser==2.1.0
7681
- django-cors-headers==3.11.0
82+
- Celery
7783
- django-celery
7884
- django-celery-results
7985
- celery-progress==0.1.2
@@ -95,16 +101,22 @@ Install this list with the command:
95101
pip install -r requirements.txt
96102
```
97103

98-
## Django installation
99-
Create the Django project
104+
### Database migration
100105
```
101-
django-admin startproject lmt_toolkit_analysis
106+
python manage.py makemigrations
107+
python manage.py migrate
102108
```
103109

110+
### Load data for documentation and versions
111+
```
112+
python manage.py loaddata fixtures/datatostart.json
113+
```
104114

105115

106116

107-
## Javascript Requirements and installations
117+
### Javascript Requirements and installations
118+
First, you need to install a JavaScript runtime environment like [Node.js](https://nodejs.org/en).
119+
Then you will have to install these packages using npm or yarn package managers:
108120
- nuxt
109121
- axios
110122
@@ -113,118 +125,55 @@ django-admin startproject lmt_toolkit_analysis
113125
- chart.js (for plots)
114126
- vue-chartjs (for plots)
115127
- vue-json-csv
128+
129+
It is recommended to first rename the nuxt-frontend folder to first create a new nuxt application and
130+
then copy / past files from the previous nuxt-frontend to the new one.
131+
116132
```
117133
npx nuxi@latest init nuxt-frontend
134+
```
135+
The above command will create a new nuxt application in a new nuxt-frontend folder.
136+
You can then copy / paste all the folders and files from the previous nuxt-folder, except the .nuxt
137+
and the node_modules folders.
138+
```
118139
cd nuxt-frontend
119140
npm i
120141
```
121142
Nuxt is now installed.
122143

123-
144+
Then install the packages (example with npm):
124145
```
125146
npm install pinia @pinia/nuxt
126-
npm i vuetify@next sass
147+
npm i vuetify sass
127148
npm i @mdi/font
128149
npm install axios
129150
npm install vue-chartjs chart.js
130-
npm run dev
151+
npm install vue-json-csv
131152
```
132153

133-
In the nuxt package.json, add the following:
134-
```
135-
"overrides": {
136-
"vue": "latest"
137-
}
138-
```
139-
and add the following to the nuxt.config.js file:
140-
```
141-
// nuxt.config.js
142-
export default defineNuxtConfig({
143-
// ... other options
144-
modules: [
145-
// ...
146-
'@pinia/nuxt',
147-
],
148-
})
149-
```
150154

155+
### Celery
156+
Celery is used to make asynchronous tasks.
157+
We need a broker to make a pip between Celery and Django. It is possible to use [RabbitMQ](https://www.rabbitmq.com/).
158+
On windows, RabbitMQ needs erlang to work:
151159

152-
## Django configuration
153-
### Django settings
154-
```
155-
import os
156-
157-
INSTALLED_APPS = [
158-
'django.contrib.admin',
159-
'django.contrib.auth',
160-
'django.contrib.contenttypes',
161-
'django.contrib.sessions',
162-
'django.contrib.messages',
163-
'django.contrib.staticfiles',
164-
'lmttoolkitanalysis',
165-
'rest_framework',
166-
'rest_framework.authtoken',
167-
'corsheaders',
168-
'djoser',
169-
'django_celery_results',
170-
'celery_progress',
171-
]
172-
173-
MIDDLEWARE = [
174-
'django.middleware.security.SecurityMiddleware',
175-
'django.contrib.sessions.middleware.SessionMiddleware',
176-
'corsheaders.middleware.CorsMiddleware',
177-
'django.middleware.common.CommonMiddleware',
178-
'django.middleware.csrf.CsrfViewMiddleware',
179-
'django.contrib.auth.middleware.AuthenticationMiddleware',
180-
'django.contrib.messages.middleware.MessageMiddleware',
181-
'django.middleware.clickjacking.XFrameOptionsMiddleware',
182-
]
183-
```
160+
https://erlang.org/download/otp_versions_tree.html
184161

185-
At the end of the settings.py file, add:
186-
```
187-
broker_url = 'amqp://guest:guest@localhost:5672//'
188-
CELERY_ACCEPT_CONTENT = ['json']
189-
CELERY_TASK_SERIALIZER = 'json'
190-
CELERY_TIMEZONE = "Europe/Paris"
191-
CELERY_IMPORTS = 'lmttoolkitanalysis.tasks'
192-
CELERY_RESULT_BACKEND = 'django-db'
193-
CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
194-
195-
# To upload
196-
MEDIA_URL = '/media/temp/'
197-
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/temp/')
198-
PRIVATE_STORAGE_ROOT = os.path.join(BASE_DIR, 'media/temp/')
199-
```
162+
Download the latest version of erlang and install it.
200163

201-
### Database migration
202-
```
203-
python manage.py makemigrations
204-
python manage.py migrate
205-
```
164+
Download RabbitMq and install it:
206165

207-
### Load data for documentation and versions
208-
```
209-
python manage.py loaddata datatostart.json
210-
```
166+
https://rabbitmq.com/install-windows.html
211167

212-
### Start the server Django
213-
```
214-
python manage.py runserver
215-
```
168+
Once RabbitMQ is installed, it runs by itself and it is possible to access its terminal via the start menu (RabbitMQ Command Prompt).
216169

217-
## Celery
218-
Celery is used to make asynchronous tasks.
170+
If needed (normally it is created by default), create a new RabbitMQ user from this Command Prompt:
219171

220-
To start Celery, in the console, go to the application folder
221-
```
222-
cd lmt_toolkit_analysis
223-
```
224-
and then write this command:
225-
```
226-
celery -A lmt_toolkit_analysis worker -l info -P solo
227-
```
172+
```rabbitmqctl add_user guest```
173+
174+
The two guests (user and password) are the ones found in the settings.py file of the Django application (already added)
175+
176+
```broker_url = 'amqp://guest:guest@localhost:5672//'```
228177

229178

230179
## How to launch the application on a Windows computer
@@ -336,7 +285,15 @@ Nuxt 3.4.1 with Nitro 2.3.3
336285
Use one of these url in your internet browser to use LMT-toolkit.
337286

338287

339-
## Features attributions:
288+
### Licence
289+
LMT-toolkit analysis is released under the GPL v3.0 licence. See the [LICENSE](LICENSE) file.
290+
291+
Copyright (C) 2022 CNRS - INSERM - UNISTRA - ICS - IGBMC
292+
293+
LMT-toolkit uses the LMT-analysis code provided on [GitHub](https://github.com/fdechaumont/lmt-analysis). This code is also under the GPL v3.0 licence.
294+
295+
296+
### Features attributions:
340297
Code for LMT analysis on [GitHub](https://github.com/fdechaumont/lmt-analysis)
341298

342299
Mice in the different behavioural events drawn by P. Dugast (from the [Live Mouse Tracker publication](https://www.nature.com/articles/s41551-019-0396-1.epdf?shared_access_token=8wpLBUUytAaGAtXL96vwIdRgN0jAjWel9jnR3ZoTv0MWp3GqbF86Gf14i30j-gtSG2ayVLmU-s57ZbhM2WJjw18inKlRYt31Cg_hLJbPCqlKdjWBImyT1OrH5tewfPqUthmWceoct6RVAL_Vt8H-Og%3D%3D), DOI: [10.1038/s41551-019-0396-1](https://doi.org/10.1038/s41551-019-0396-1))

lmt_toolkit_analysis/db.sqlite3

100 KB
Binary file not shown.
119 KB
Loading

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ djangorestframework==3.14
44
django-filter==21.1
55
djoser==2.1.0
66
django-cors-headers==3.11.0
7+
Celery
78
django-celery
89
django-celery-results
910
celery-progress==0.1.2

0 commit comments

Comments
 (0)