Skip to content

01 Setup

Zdenek Kasner edited this page Oct 4, 2024 · 8 revisions

Setup

🔧 Manual installation

Installing the package locally is simple:

  1. Make sure you have Python>=3.10 and pip.
  2. Clone the repository.
  3. Install the factgenie as an editable Python package:
pip install -e .
  1. Activate the configuration file:
cp factgenie/config/config_TEMPLATE.yml factgenie/config/config.yml

# do not forget to set up username and password (see below for instructions)
  1. Start the local web server:
factgenie run --host=127.0.0.1 --port 8890
  1. Fire up the web interface: open http://127.0.0.1:8890 in your browser and log in 🔥

If everything worked as expected, you should be able to see the front page:

Main screen

🚢 Using Docker

The Dockerfile included in the project will run factgenie using Python 3.10 exposing the app on port 80. You can run the server by executing

# Build the factgenie Docker image
docker build --tag 'factgenie' .
# Run the image in detached mode with in-container port 80 exposed as localhost:8080
docker run -p 8080:80 --detach 'factgenie'

You can then access the server by navigating to localhost:8080 in your browser.

The included docker-compose.yml file can be used to launch the server using docker compose up if you so desire. Simply drop docker-compose.yml one directory up from the root directory for the repository, navigate to that directory, and run the command. For example, if you haven't moved the file yet and you're in the root of the repo, you can run:

# Copy the folder one level up
cp docker-compose.yml ../.
# Navigate one level up
cd ..
# Run docker compose in detached mode
docker compose up -d

⚙️ Configuration file

The configuration of factgenie is stored in factgenie/config/config.yml. This file is loaded when factgenie is started.

Here is an example configuration file:

---
debug: false
host_prefix: ""
logging_level: INFO
login:
  active: true
  username: admin
  password: factgenie

Login

The login field contains the username and password needed for accessing the web interface. Having a password-protected app is necessary when running the human crowdsourcing campaign.

❗️ Make sure to change the default username and password before deploying the app.

You can disable the password protection if you do not plan to run a crowdsourcing campaign.

Host prefix

host_prefix contains a URL prefix that will be used by the frontend.

Most of the times, you can keep this value empty.

However, if your app is deployed behind a reverse proxy, you may need to manually set the subdirectory here.

Example: factgenie is deployed at https://public-server.com/demos/factgenie. In that case, you need to set the host_prefix to /demos/factgenie.

⚡️ Deployment

For deploying factgenie, you can use gunicorn:

gunicorn -b :9989 -w 1 --threads 8 factgenie.cli:create_app

If you are using nginx, we recommend you to set proxy_buffering to off (see this discussion) for the live updates to work.

Make sure you specify a sufficient number of threads (--threads) for servicing the web server and running the campaigns.

❗️ Do not use multiple Gunicorn workers: doing that may introduce race conditions, which may result in corrupted data.