2019-03-10 23:17:43 +00:00
|
|
|
# cjvt-valency
|
2019-03-17 16:25:59 +00:00
|
|
|
Required submodules:
|
|
|
|
|
|
|
|
* `https://gitea.cjvt.si/kristjan/cjvt-corpusparser.git`
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ git submodule init
|
2019-03-23 19:27:23 +00:00
|
|
|
$ git submodule update
|
2019-03-17 16:25:59 +00:00
|
|
|
```
|
2019-03-07 08:00:01 +00:00
|
|
|
|
|
|
|
## Components
|
|
|
|
|
2019-04-15 15:03:39 +00:00
|
|
|
### Credentials
|
|
|
|
Copy `env.default` to `env.local` (gitignored).
|
|
|
|
Modify database credentials in `env.local`.
|
|
|
|
The file is used by `make`.
|
|
|
|
|
2019-03-07 08:00:01 +00:00
|
|
|
|
|
|
|
### Database (2 containers)
|
2019-03-24 01:08:22 +00:00
|
|
|
Set db admin, user, pass, etc in 'Makefile'.
|
2019-03-23 19:27:23 +00:00
|
|
|
Spin up the database service and create users:
|
2019-04-05 14:45:40 +00:00
|
|
|
Make sure you create a folder for the data on host machine (see `mongodb-stack.yml` `volumes`.
|
2019-03-17 16:25:59 +00:00
|
|
|
```bash
|
2019-04-05 14:45:40 +00:00
|
|
|
$ mkdir -p ${HOME}/mongo_container/data/ # default one
|
2019-04-04 22:46:19 +00:00
|
|
|
# $ make database-clean # opt, removes docker services, not data
|
2019-03-17 16:25:59 +00:00
|
|
|
$ make database-service
|
2019-04-04 22:46:19 +00:00
|
|
|
$ make database-users # only first time; user data persists too
|
2019-03-17 16:25:59 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Populate the database with data form files:
|
2019-03-07 08:00:01 +00:00
|
|
|
|
|
|
|
* ssj500k.xml
|
|
|
|
* kres.xml
|
|
|
|
* kres_SRL.json
|
|
|
|
|
2019-03-17 16:25:59 +00:00
|
|
|
Set path to files in `Makefile`.
|
|
|
|
```bash
|
|
|
|
# spin up a container with python env
|
|
|
|
$ make python-env
|
2019-03-07 08:00:01 +00:00
|
|
|
|
2019-03-17 16:25:59 +00:00
|
|
|
# install our packages
|
|
|
|
$ make python-env-install
|
2019-03-07 08:00:01 +00:00
|
|
|
|
2019-03-17 16:25:59 +00:00
|
|
|
# run the code
|
2019-04-13 22:26:15 +00:00
|
|
|
# beforehand, set the data files in Makefile
|
2019-04-21 11:42:17 +00:00
|
|
|
# instead of mounting directories into the container, you can
|
|
|
|
# create a link inside ./data, that points to the desired location
|
2019-04-21 17:18:40 +00:00
|
|
|
|
|
|
|
# I've separated the processes for better memory management
|
|
|
|
$ make fill-database-ssj
|
|
|
|
|
|
|
|
$ make fill-database-kres
|
|
|
|
# You can detach from the running process using Ctrl-p + Ctrl-q
|
|
|
|
|
2019-04-21 11:14:34 +00:00
|
|
|
# this is a long operation
|
|
|
|
# if running on a remote server, use nohup:
|
|
|
|
$ nohup $(make fill-database > fill-database.log) &
|
2019-03-17 16:25:59 +00:00
|
|
|
```
|
2019-03-07 08:00:01 +00:00
|
|
|
|
2019-03-24 01:08:22 +00:00
|
|
|
If all goes well, we should be able to inspect the database, filled with corpora, on `0.0.0.0:8087`.
|
2019-03-07 08:00:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
### Flask backend (1 container)
|
2019-03-24 01:08:22 +00:00
|
|
|
Relies heavily on the database. Set that up first.
|
|
|
|
```bash
|
2019-04-15 00:35:50 +00:00
|
|
|
# spin up container
|
2019-03-28 18:17:45 +00:00
|
|
|
$ make python-env
|
|
|
|
|
2019-04-15 00:35:50 +00:00
|
|
|
# install our packages
|
|
|
|
$ make python-env-install
|
|
|
|
|
|
|
|
# needs to be ran once to modify a new database
|
|
|
|
$ make backend-prepare-db
|
2019-04-13 22:26:15 +00:00
|
|
|
|
2019-04-28 19:59:20 +00:00
|
|
|
# if you have the file prepared (sskj_senses.json), you can
|
|
|
|
# fill the database with some senses
|
|
|
|
$ make sskj-senses
|
|
|
|
|
2019-04-15 00:35:50 +00:00
|
|
|
# with debugger
|
|
|
|
$ make backend-dev
|
2019-04-06 17:38:36 +00:00
|
|
|
|
|
|
|
# production
|
2019-03-24 01:08:22 +00:00
|
|
|
$ make backend-prod
|
|
|
|
```
|
2019-03-07 08:00:01 +00:00
|
|
|
|
|
|
|
API endpoints:
|
|
|
|
|
|
|
|
* GET word list (pre-cached)
|
|
|
|
* GET reduced frames (pre-cached)
|
|
|
|
* POST senses
|
|
|
|
* User auth logic
|
|
|
|
|
|
|
|
|
|
|
|
### Vue frontend (1 container)
|
2019-03-24 01:08:22 +00:00
|
|
|
Relies on Flask backend.
|
|
|
|
Before running `make`, you might need to set the correct api address.
|
|
|
|
Check `./src/frontend_vue/config/config_prod.json`.
|
|
|
|
bash
|
|
|
|
```
|
|
|
|
# $ make frontend-dev # development
|
|
|
|
$ make frontend-prod
|
|
|
|
```
|
2019-03-07 08:00:01 +00:00
|
|
|
|
2019-03-24 01:08:22 +00:00
|
|
|
App available on: `http://0.0.0.0:8080`.
|