Development environment

Starting HiCognition in development mode

We provide a docker-compose file that sets up the local development environment. This file uses the same containers as the production compose file, so if you haven’t done so, follow the instructions for building the containers.

When you start a development HiCognition instance, the front-end files will be served by a node.js development server with enabled hot reload. You can then also use the Vue.js devtools Chrome extension for debugging. The back-end server that is started in the development instance is a flask development server, also with hot reload.

To get information about how to configure the environment variables for the development instance, see the configuration chapter.

The production HiCognition container copies the server code into the container during the build process and runs the server from there. In contrast, the development setup mounts the local code repository into the container to enable fast editing and hot-reload.

You can start the development instance with the following command inside the cloned HiCognition repository:

docker-compose -f docker_dev.yml up

After that, the app is available on http://localhost:8080

Get shell access to the server

To get access to the HiCognition flask server to run tests or interact with the MySQL database through our database models, attach a shell to the flask-server container. This can be done with the following command:

docker exec -it flask-server bash

Once you have the shell inside the container, you have access to the command line convenience methods that allow quick interactions with the database. You can, for example, get a python shell with the database models loaded using:

flask shell

Additionally, you can add new users using the flask user define subcommand:

Usage: flask user define [OPTIONS] NAME

Creates a new user either with a defined password or password prompt. If user with the name exists already, the password is redefined.

Options:

-p, –password TEXT

–help Show this message and exit.

An example workflow for creating a dummy user with an unsafe password is:

docker exec -it flask-server bash
flask user define dummy -p 1234

To add datasets, you can use the flask dataset add command:

Usage: flask dataset add [OPTIONS] JSON_PATH USER PASSWORD

Adds datasets defined in a JSON to database and uploads it.

Options:

–help Show this message and exit.