cjvt-valency/Makefile

135 lines
4.2 KiB
Makefile
Raw Permalink Normal View History

2019-03-10 21:11:18 +00:00
# All required components, to create and fill a database,
# instantiate backend and frontend.
MAKE_ROOT = $(shell pwd)
### Input data
# I received ssj500k in one .xml file,
# kres is composed of many .xml files
# I generated srl tags for kres in separate .json files
# (for each kres.xml file there is a kres.json file with srl tags)
2019-04-21 19:04:07 +00:00
# SSJ_FILE = "$(MAKE_ROOT)/data/samples/ssj_xml/ssj500k-sl.body.sample.xml"
SSJ_FILE = "$(MAKE_ROOT)/data/ssj_file_link"
2019-04-22 07:06:53 +00:00
# KRES_FOLDER = "$(MAKE_ROOT)/data/samples/kres_xml"
2019-04-27 18:24:11 +00:00
# KRES_FOLDER = "$(MAKE_ROOT)/data/kres_xml_folder_link"
KRES_FOLDER = "/home/kristjan/kres_data/payload/kres_xml"
2019-04-22 07:06:53 +00:00
# KRES_SRL_FOLDER = "$(MAKE_ROOT)/data/samples/kres_srl_json"
2019-04-27 18:24:11 +00:00
# KRES_SRL_FOLDER = "$(MAKE_ROOT)/data/kres_json_folder_link"
KRES_SRL_FOLDER = "/home/kristjan/kres_data/payload/kres_json"
# This file comes with the source code. Make sure you unpack it and name it right.
SSKJ_WORDLIST = "$(MAKE_ROOT)/data/wordlist.json"
2019-04-27 23:03:44 +00:00
SSKJ_JSON = "$(MAKE_ROOT)/data/sskj_senses.json"
2019-04-05 14:45:40 +00:00
2019-03-17 16:25:59 +00:00
OUTPUT = "db"
# OUTPUT = "file"
2019-04-14 22:26:08 +00:00
OUTDIR = "/tmp/three" # if you're running this in docker, make sure to mount the volume
2019-03-17 16:25:59 +00:00
DBADDR = "0.0.0.0:27017" # don't use localhost
2019-03-14 18:49:01 +00:00
# credentials from .gitignored file
# create it from env.default
include env.local
2019-04-27 18:24:11 +00:00
N_CORES = 3
2019-04-21 19:53:46 +00:00
# insert kres files into database in chunks, for fewer connections
2019-04-22 07:06:53 +00:00
KRES_CHUNK_SIZE = 30
# Backend parameters found in conf file (see make backend)
2019-03-10 21:11:18 +00:00
export
2019-03-23 19:27:23 +00:00
.PHONY: python-env fill-database
2019-03-10 21:11:18 +00:00
all:
echo "Select an argument"
2019-03-17 16:25:59 +00:00
# create database (run from host):
# !!! might need to run several times, so the containers come online
# Successful if you see the lines:
# Successfully added user: { "user" : "testuser", "roles" : [ "readWrite" ] }
# bye
database-service:
cd dockerfiles/database; $(MAKE) build_run
2019-03-10 21:11:18 +00:00
2019-03-17 16:25:59 +00:00
database-users:
cd dockerfiles/database; $(MAKE) create_users
# also useful, if we want to restart the db
database-clean:
cd dockerfiles/database; $(MAKE) clean_stack
# create python-env container
python-env:
cd dockerfiles/python-env; $(MAKE)
# inside the container, install our packages
python-env-install:
pip3 install -e src/pkg/cjvt-corpusparser/.
2019-03-28 18:17:45 +00:00
pip3 install -e src/pkg/valency/.
2019-04-27 18:24:11 +00:00
pip3 install -e src/pkg/seqparser/.
2019-03-17 16:25:59 +00:00
# from inside python-env container:
2019-03-10 21:11:18 +00:00
data/samples:
cd data; tar xzvf samples.tar.gz
2019-03-17 16:25:59 +00:00
# from inside python-env container:
2019-04-14 22:26:08 +00:00
# you can set OUTPUT = "file" and a valid OUTDIR to test writing to json files instead of DB
2019-04-21 17:18:40 +00:00
fill-database-ssj: data/samples
2019-03-17 16:25:59 +00:00
python3 src/pkg/cjvt-corpusparser/corpusparser/main.py --kres-folder $(KRES_FOLDER) \
2019-04-21 17:18:40 +00:00
--corpus="ssj" \
2019-03-17 16:25:59 +00:00
--ssj-file $(SSJ_FILE) --kres-srl-folder $(KRES_SRL_FOLDER) \
--output $(OUTPUT) --outdir $(OUTDIR) --dbaddr $(DBADDR) \
2019-04-14 22:26:08 +00:00
--dbuser $(DB_USR_USER) --dbpass $(DB_USR_PASS) \
--cores $(N_CORES)
2019-03-14 18:49:01 +00:00
2019-04-21 17:18:40 +00:00
fill-database-kres: data/samples
python3 src/pkg/cjvt-corpusparser/corpusparser/main.py --kres-folder $(KRES_FOLDER) \
--corpus="kres" \
--ssj-file $(SSJ_FILE) --kres-srl-folder $(KRES_SRL_FOLDER) \
--output $(OUTPUT) --outdir $(OUTDIR) --dbaddr $(DBADDR) \
--dbuser $(DB_USR_USER) --dbpass $(DB_USR_PASS) \
2019-04-21 19:53:46 +00:00
--chunk-size $(KRES_CHUNK_SIZE) \
2019-04-21 17:18:40 +00:00
--cores $(N_CORES)
2019-03-19 07:11:26 +00:00
## Frontend
2019-03-19 07:11:26 +00:00
## Run from host
## See src/frontend_vue/README.md for port settings etc.
frontend-dev:
cd src/frontend_vue/; $(MAKE) dev
frontend-prod:
cd src/frontend_vue/; $(MAKE) prod
2019-03-22 13:50:47 +00:00
## Backend
# runs once and exits before the app starts
2019-04-27 23:03:44 +00:00
# need to extract ./data/sskj_data.tar.gz first
backend-prepare-db:
2019-04-06 17:38:36 +00:00
cd ./src/backend_flask; python3 app.py \
--config-file ./conf_files/dev_conf.yaml \
--dbuser $(DB_USR_USER) --dbpass $(DB_USR_PASS) --dbaddr $(DBADDR) \
2019-04-27 18:24:11 +00:00
--sskj-wordlist $(SSKJ_WORDLIST) \
--prepare-db
2019-03-22 13:50:47 +00:00
backend-dev:
2019-03-23 19:27:23 +00:00
cd ./src/backend_flask; python3 app.py \
--config-file ./conf_files/dev_conf.yaml \
--dbuser $(DB_USR_USER) --dbpass $(DB_USR_PASS) --dbaddr $(DBADDR)
backend-prod:
cd ./src/backend_flask; python3 app.py \
--config-file ./conf_files/prod_conf.yaml \
--dbuser $(DB_USR_USER) --dbpass $(DB_USR_PASS) --dbaddr $(DBADDR)
2019-04-27 23:03:44 +00:00
## add sskj senses to db (generated with pkg/seqparser)
sskj-senses:
python3 ./src/pkg/seqparser/seqparser/main.py \
--sskj-json $(SSKJ_JSON) \
--operation "senses_to_db" \
--dbaddr $(DBADDR) \
--dbuser $(DB_USR_USER) \
--dbpass $(DB_USR_PASS)