Installation and Setup
This guide assumes you are familiar with Python and JSON config files.
This section shows you how to run the service from the command line, useful for testing. It also shows you how to run it as a service, best suited to a production environment.
The REST Enrichment Service along with the enrichment steps can be found in the InsightMaker.Python distribution.
Configure the Enrichment Steps
You need to activate the enrichment steps by editing the configuration.
The REST Service configuration is based on custom overrides in the folder 'config/custom'.
You can copy configuration files from 'config' and 'config/providers' into the custom folder and override the configuration parameters required for your configuration.
From The Command Line
We recommend you get the service running from the command line first so you can easily spot and resolve issues.
The following steps are required to get an instance running on the command line.
Check if you already have a version of Python running on the server. You can do this by checking the PATH and location of installed applications.
No Python Version Exists - Install Python
Install Python
Install Python 3.12.2
To run Python REST services as a Window Service you need to install Python for ‘all users’.
Create a Python Virtual Environment
Create a venv folder in the root of the RestEnrichmentService folder.
Open a command prompt, navigate to the venv folder, and create the venv with this python command:
python -m venv ./
Python versions exist - Install Python
Install Python
Install Python 3.12.2
To run Python REST services as a Window Service you need to install Python for ‘all users’.
Do not add, select add to the system variables or path as this may interfere with existing Python applications running on the server.
Open an administrator command prompt and install virtualenv:
pip install virtualenv
Create a Python Virtual Environment
Create a venv folder in the root of the RestEnrichmentService folder.
Open a command prompt, navigate to the venv folder, and create the venv with this python command:
python -m virtualenv ./ -p="C:\Program Files\Python312\python.exe"
Replace the -p parameter with the path to the Python 3.12.2 executable.
Configure and Install Prerequisites
Ensure long path support is enabled
Using Regedit:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
LongPathsEnabled
DWORD = 1
Activate Python virtual machine
Activate your virtual environment by navigating to the venv/Scripts folder and running:
activate.bat
You should now see (venv) at the start of your command line.
On the command line navigate back to InsightMaker.Python\RestEnrichmentService
Python Torch run-time prerequisites.
For Windows - Visual Studio runtime must be installed. https://visualstudio.microsoft.com/visual-cpp-build-tools/
Other Operating Systems - Check requirements https://pypi.org/project/torch/
Use ‘pip’ to install all the requirements in the latest requirements file:
Online:
pip install -r requirements_3.12.2.txt
Offline: From an internet connected machine:
Create a temporary folder.
Navigate to the temporary folder.
pip download -r requirements_3.12.2.txt
Copy the resulting contents of the temporary folder to the target server.
Run the following on the target server, replacing the path to the temporary folder as appropriate.
pip install --no-index --find-links C:/tmp/libs -r requirements_3.12.2.txt
If you do not have an internet connection, run the following commands on a machine that does, and then copy the NLTK data to the target server. Remember to also recreate the environment variable on the target server.
Install the NLTK data (models) to a location on the server:
python -m nltk.downloader all -d <DRIVE:/LOCATION>
Set an environment variable to point at the NLTK data:
NLTK_DATA=DRIVE:/LOCATION
The NLTK guide: https://www.nltk.org/data.html
Edit run.bat in the root of ‘InsightMaker.Python\RestEnrichmentService’ to point at the correct location for your virtual environment.
Exit the virtual environment and open a new command window.
Navigate to the ‘InsightMaker.Python\RestEnrichmentService’ folder.
If you are running on a server without an internet connection then you will need to disable all steps that use huggingface (hugginface NER, sentence transformers, spare vectors etc).
This can be set up once the installation has been tested. This is covered in the ‘Offline Set-up’ guide.
Execute ‘run.bat’ on the command line. You should see the output as shown below.
This should activate your virtual machine and start the service.
Make sure you are in the root folder of the RestEnrichmentService.
Once this runs correctly and you have tested it with a test enrichment pipeline then you can run the service as a Window service if you want to.
Last updated