Karp backend
Project description
Karp TNG backend
This in the version 6 of Karp backend, for the legacy version (v5).
Setup
This project uses poetry and MariaDB.
-
Run
make install
ormake install-dev
for a develop-install (VENV_NAME defaults to .venv) -
Install MariaDB and create a database
-
Setup environment variables (can be placed in a
.env
file in the root and then ?pipenv run
sets those):export MARIADB_DATABASE=<name of database> export MARIADB_USER=<database user> export MARIADB_PASSWORD=<user's password> export MARIADB_HOST=localhost export AUTH_JWT_PUBKEY_PATH=/path/to/pubkey
-
Activate the virtual environment by running:
source <VENV_NAME>/bin/activate
(VENV_NAME defaults to .venv) -
Run
make init-db
to initialize database orsource <VENV_NAME>/bin/activate
and thenalembic upgrade head
-
Run
make run-dev
to start development serveror
source <VENV_NAME>/bin/activate
and thenpython wsgi.py
-
To setup Elasticsearch, download Elasticsearch 6.x or 7.x and start it
-
Install elasticsearch python libs for the right version
- If you use Elasticsearch 6.x, run
source <VENV_NAME>/bin/activate
andpip install -e .[elasticsearch6]
- If you use Elasticsearch 7.x, run
source <VENV_NAME>/bin/activate
andpip install -e .[elasticsearch7]
- If you use Elasticsearch 6.x, run
-
Add environment variables
export ES_ENABLED=true
export ELASTICSEARCH_HOST=localhost:9200
Create test resources
source <VENV_NAME>/bin/activate
and then:karp-cli create --config tests/data/config/places.json
karp-cli import --resource_id places --version 1 --data tests/data/places.jsonl
- Do the same for
municipalities
karp-cli publish --resource_id places --version 1
karp-cli publish --resource_id municipalities --version 1
Pre-processing data before publishing
Can be used to have less downtime, because sometimes the preprocessing may
be faster on another machine than the machine that talks to Elasticsearch.
Do create
and import
on both machines, with the same data. Use
machine 1 to preprocess and use result on machine 2.
-
Create resource and import data as usual.
-
Run
karp-cli preprocess --resource_id places --version 2 --filename places_preprocessed
places_preprocessed
will contain a pickled dataset containing everything that is needed -
Run
karp-cli publish_preprocessed --resource_id places --version 2 --data places_preprocessed
-
Alternatively run
karp-cli reindex_preprocessed --resource_id places --data places_preprocessed
, if the resource was already published.
Technologies
Python
- Pipenv
- Flask
- SQLAlchemy
- Click
- Elasticsearch
- Elasticsearch DSL
Databases
- MariaDB
- Elasticsearch
Development
Version handling
Version can be bumped with bumpversion
.
Usage:
- Increase patch number
a.b.X => a.b.(X+1)
:bumpversion patch
- Increase minor number
a.X.c => a.(X+1).c
:bumpversion minor
- Increase major number
X.b.c => (X+1).b.c
:bumpversion major
- To custom version
a.b.c => X.Y.Z
:bumpversion --new-version X.Y.Z
bumpversion
is configured in .bumpversion.cfg
.
The version is changed in the following files:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for karp_backend-6.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaa0db082cd756a868496f4827a5d647eb3e5ea67cdd988ad4ce5e4d646077a8 |
|
MD5 | b9e32ffb94a86fcbf6bf4d3c6d468249 |
|
BLAKE2b-256 | 51597c76423d864f36a687f9a35ccadc247b501d8dfe46fadbc257899fca7b4e |