This guide explains how to setup your Python Bridge to begin using with be used by Saga. It includes information on prerequisites, installing Python, and installing the dependencies.
Currently the only way to get a copy of Python Bridge is by requesting it to the Saga Team, for this please talk with your Accenture consultant for assistance.
You can get the Python Bridge server as part of Saga deliverables which are stored in Artifactory repository here. At the time of writing the latest version of Saga available is 1.3.4.
(SAGA 1.3.1) The current version of Python Bridge was developed and tested using Python 3.9.5The current versions of Python Bridge where develop and test using Python 3.7.2, but any Python 3.79.x version will suffice. At the moment of writing this guide the released version of 3.7 9 is Python 3.79.7 5 which you can download from here https://www.python.org/downloads/release/python-377/here Python Release Python 3.9.5 | Python.org, please remember to download the 64-bit version of Python, some libraries are no compatible with the 32-bit version and will not work.
(SAGA 1.3.3) The python version has been updated to 3.11.4 which you can download from here Python 3.11.4, download the 64-bit version.
(SAGA 1.3.4) The python version has been updated to 3.11.9 which you can download from here Python 3.11.9, download the 64-bit version.
Tip |
---|
Remember to create a environment variable PYTHON_HOME, pointing to you current installation folder of Python |
Warning |
Python Bridge does not support Python 3.8.x |
Once Python 3.7.x is installed, and poses a copy of Python Bridge, proceed to access the Python Bridge folder via console. Once there we will create a python virtual environment using the following command
...
This will create a folder names named venv in our Python Bridge folder, a self-contained directory tree that contains a Python installation for a particular version of Python, plus a number of additional packages.
To be able to use this environment, we need to execute the active activate script for this execute using the following command:
For Linux
Code Block | ||||
---|---|---|---|---|
| ||||
source venv/bin/activate |
...
Code Block | ||||
---|---|---|---|---|
| ||||
(venv) C:\Python Bridge> |
Once in the virtual environment proceed to install the Python Bridge dependencies, all the dependencies should be listed in a file called requirements.txt inside the Python Bridge folder. Install the dependencies by executing the following command:
...
Code Block | ||||
---|---|---|---|---|
| ||||
python -m pip install -r requirements.txt |
Info |
---|
This process may take a few minutes, since pip needs to download and install every dependency |
Tip |
---|
You may see a trusted or SSL certificate error message when trying to install dependencies. This because some of the hosts are not trusted by the pip tool. Try with the next command: pip install --trusted-host download.pytorch.org -r requirements.txt If this doesn't work either you can tell pip to trust those hosts by adding them to a text file called "pip.ini" which you place in the "venv" folder. And then, try running the following command: pip config set global.trusted-host "pypi.org files.pythonhosted.org download.pytorch.org" |
We have now a pyproject.toml file, so we can install libraries from there instead of using the requirements.txt. This method has multiple advantages, such as: optional dependencies, easy control over all the installed libraries, addition of advanced setup configurations and more.
To install the dependencies using this new method, you need to use:
Code Block | ||||
---|---|---|---|---|
| ||||
pip install -e . |
This will install all the required dependencies needed to start the server without any model.
To install extra optional dependencies, you can use this other command:
Code Block | ||||
---|---|---|---|---|
| ||||
pip install -e .[all] |
Where [all] is the name of the optional dependencies to install. They need to be added to the correct section on the pyproject file.
If you do not know how to do this, here is a page with all you need to know about the pyproject file and its optional dependencies.
Info |
---|
This process may take a few minutes, since pip needs to download and install every dependency |
...
Finally to start the Python Bridge server, all you need to do is to choose one of the following options:
For local testing only.
Code Block | ||||
---|---|---|---|---|
| ||||
python server.py <Port Number> |
Note |
---|
You must specify the port number, usually 5000. |
For production environments. Supports https and basic authentication.
Code Block | ||
---|---|---|
| ||
python server-cherrypy.py |
Note |
---|
For security configuration refer to Python Bridge Configuration. |
Note |
---|
If it's the first time starting Python Bridge, it will download a couple of models, among them BERT base uncased model, which has a size of roughly 4Gb. Python Bridge will not be ready until all the models are downloaded. Once downloaded, next time you start Python Bridge it will be pretty fast. |
Tip |
---|
If you do not wish to download the BERT model, go the the config.json file in the config folder and remove the Bert entry under model_types. If you want to keep the model around for future usage, you can just disabled it by setting the 'enable' flag to false: "enabled": false |
Tip |
---|
If you want to use Python Bridge with Saga you can check Recognizers documentation. |