Skip to content
Mahesh Maan edited this page Mar 13, 2024 · 4 revisions

Local deployment instructions for PQAI

Step 0: Prerequisites

In the following instructions I assume you are deploying PQAI on a Linux based operating system such as Ubuntu. While the steps for Windows or MacOS should mostly be similar, some of the commands may differ, plus you may need to install some more packages to get it all working.

Before you start, you need to:

  1. have git on your system, which you can verify with the following command on a terminal (don't worry if the version number on your system is different)

    $ git --version
    git version 2.25.1

    If the above command gives you an error, you can install git by:

    $ sudo apt install git
  2. have Python 3 on your system, which you can verify by running:

    $ python --version
    Python 3.8.13

    If the above command does not work, try with python3 and if that works, then in all the subsequent commands, just use python3 in place of python

    $ python3 --version
    Python 3.8.13

    If none of the above commands work, you will need to install Python: instructions

  3. have pip on your system. Check with:

    $ pip --version
    pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
    

If you don't see a version of pip already installed, run the following commands to install it:

$ sudo apt update
$ sudo apt install python3-pip
  1. have Mongo DB installed and running. Installation instructions can be found here.

  2. a few other packages installed, which you can do by running the following command:

    sudo apt-get update && sudo apt-get install unzip gcc g++ libgl1-mesa-glx libglib2.0-0 libsm6 libxrender1 libxext6 -y

    Now you are ready to begin setting up PQAI on your local system.

Step 1: Get the code

Clone the PQAI repository

git clone https://github.com/pqaidevteam/pqai.git
cd pqai

Step 2: Create Python environment

PQAI uses Poetry to manage dependencies. We'll install it first and then use it to install rest of the dependencies.

pip install poetry==1.7.1

Install Python packages required by PQAI:

poetry install

Step 3: Get the assets

Download files required by PQAI and extract them to the pqai/assets folder

curl -o pqai-assets-latest.zip "https://s3.amazonaws.com/pqai.s3/public/pqai-assets-latest.zip"
unzip pqai-assets-latest.zip -d models/

Step 4: Set up patent database

Download a MongoDB dump, decompress and restore it

curl -o mongodump.tar.gz "https://s3.amazonaws.com/pqai.s3/public/pqai-mongo-dump.tar.gz"
tar -x --use-compress-program=pigz -f mongodump.tar.gz
mongorestore

Step 5: Get some indexes

Download sample indexes for testing (later you can create your own indexes, for details, see scripts/mongo2faiss.py)

curl -o index.zip "https://s3.amazonaws.com/pqai.s3/public/sample-index.zip"
unzip index.zip -d indexes/

Step 6: Configure your setup

Create a copy of env file and name it .env

cp env .env

Give suitable values to the environment variables in .env

Now you should be able to run the PQAI service with poetry run python server.py

Step 7: Clean up

Remove files that are no longer needed

rm pqai-assets-latest.zip
rm sample-index.zip
rm pqai-mongo-dump.tar.gz