From version 1.3.4 onwards we have a new way to use environmental variables in both SAGA and the Python-Bridge, to make the deployment of these assets way more easier and convenient.

Step-by-step guide (SAGA)

To use environmental variables dynamically in SAGA you need to do these steps:

  1. Get a copy of the SAGA config file (config.json) or open an existing config file.
    1. This file can be found in the "config" folder of the SAGA binaries or from here:
      1. SAGA config file
        {
          "config": {
            "apiPort": 8080,
            "secureApiPort": 443,
            "host": "0.0.0.0",
            "allow-domains": "localhost",
        	"serverTimeout": 30000,
            "disableHTTPSSLVerification": false,
            "maxRequestPayloadSize": 1000000,
            "cors": {
              "allow_origins": [
                "http://localhost:8080",
                "https://localhost",
                "https://login.microsoftonline.com"
              ],
              "allow_credentials": "true",
              "allow_methods": ["*"],
              "allow_headers": ["*"],
              "expose_headers": ["*"]
            },
            "security": {
              "enable": false,
              "encryptionKeyFile" : "./bin/saga.ek",
              "inactiveInterval": 600,
              "defaultRole": "admin",
              "users": [{
                "username": "admin",
                "password": "notpassword",
                "roles": "admin"
              }],
              "type": "none",
        
              "openid": {
                "serverURL": "http://localhost:8080",
                "clientId": "clientId",
                "discoveryURI": "discoveryURI"
              }
            },
            "ssl": {
              "enable": false,
              "keyStore": "./bin/saga.jks",
              "keyStorePassword": "encrypted:KCe8RrPQ8MV3po8NqHo0G7q7sa6T6yzf1JrTQ5VD0uty0elmrqRuybaAmrEHJ37d"
            },
            "libraryJars": [
              "./lib"
            ],
            "exportSettings" : {
              "maxSize" : 40,
              "batchSize" : 5000
            },
            "restHandlers": [],
            "models": [],
            "uiHandlers": [],
            "providers": [
              {
                "name": "filesystem-provider",
                "type": "FileSystem",
                "baseDir": "./config"
              },
              {
                "name": "saga-provider",
                "type": "Elastic",
                "nodeUrls": ["http://localhost:9200"],
                "timestamp": "updatedAt",
                "indexName": "saga",
                "encryptionKeyFile" : "./bin/saga.ek",
                "authentication": "none",
                "caFilePath": "",
                "trustAllSSL": false,
                "timeout": 90,
                "delay": 5,
                "retries": 3,
                "exclude": [ ]
              }
            ],
            "logging_provider": {
              "name": "saga-logging-provider",
              "type": "Elastic",
              "nodeUrls": ["http://localhost:9200"],
              "timestamp": "updatedAt",
              "indexName": "saga",
              "encryptionKeyFile" : "./bin/saga.ek",
              "authentication": "none",
              "caFilePath": "",
              "trustAllSSL": false,
              "timeout": 90,
              "delay": 5,
              "retries": 3,
              "exclude": [ ]
            },
            "gpt3": {
              "key": "",
              "openAIHost": "https://api.openai.com",
              "openAIAPIVersion": "v1"
            }
          }
        }
  2. The next step is to add your environmental variables in, you can enter any number of variables, the only condition is that the environment where SAGA is going to be executed has the same env variables with the same names.
    1. SAGA config file
      {
        "config": {
          "apiPort": ${PORT},
          "secureApiPort": ${SECURE_PORT),
          "host": "${HOST}", // OR add the quotes to the env var
          ...<REST_OF_THE_CONFIG>
      }

      IMPORTANT

      For the values in the config file that comes with quotes, you need to add env variable replace value inside those quotes or add the quotes to the env var.

  3. Replace the default config file with the new one with the env variables and run SAGA.


Step-by-step guide (Python Bridge)

To use environmental variables dynamically in the Python Bridge you need to do these steps:

  1. Get a copy of the PB config file (config.json) or open an existing config file.
    1. This file can be found in the "config" folder of the Python Bridge binaries or from here:
      1. PB config file
        {
            "host": "0.0.0.0",
            "port": 5000,
            "ssl": {
                "enabled": false,
                "secure_port": 5443,
                "certificate": {
                    "cert": "cert.pem",
                    "key": "key.pem"
                }
            },
            "authentication": {
                "enabled": false,
                "credentials": {
                    "user": "admin",
                    "password": "password"
                }
            },
            "threads": 30,
            "logging": {
                "level": "info",
                "loggers": {
                    "werkzeug": "info",
                    "gensim.utils": "warn",
                    "pytorch_pretrained_bert.modeling": "warn",
                    "pytorch_pretrained_bert.tokenization": "warn"
                }
            },
            "models_data_dir": "models_data",
            "model_types": {
                "Classification_watcher_example": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": ["Classification_watcher_example"],
                    "default_model": "Classification_watcher_example"
                },
                "LatentSemanticIndexing" : {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": ["lsi"]
                },
                "Bert": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": ["bert-base-uncased"],
                    "default_model": "bert-base-uncased"
                },
        	"BioBert": {
                     "enabled": false,
                     "input_data_as_tokens": false,
                     "model_names": ["biobert-base-cased-v1.2"],
                     "default_model": "biobert-base-cased-v1.2"
                },
                "BertQA": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": ["bert-large-uncased-whole-word-masking-finetuned-squad"],
                    "default_model": "bert-large-uncased-whole-word-masking-finetuned-squad"
                },
                "SBert": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": ["bert-base-nli-stsb-mean-tokens", "bert-base-nli-mean-tokens", "distilbert-base-nli-stsb-mean-tokens"],
                    "default_model": "bert-base-nli-stsb-mean-tokens"
                },
                "SentimentAnalysisVader": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": ["vader"]
                },
                "SentimentAnalysisTextBlob": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": ["textBlob"]
                },
                "TfidfVectorizer": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": ["Tfidf"]
                },
                "GTRT5": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": [
                        "gtr-t5-base",
        		        "gtr-t5-xl"
                    ],
        	        "default_model": "gtr-t5-base"
                },
                "T5": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": [
                        "sentence-t5-base"
                    ]
                },
        	    "MiniLM": {
                    "enabled": false,
                    "input_data_as_tokens": false,
                    "model_names": [
                        "all-MiniLM-L12-v2"
                    ]
                }
            }
        }
  2. The next step is to add your environmental variables in, you can enter any number of variables, the only condition is that the environment where the Python Bridge is going to be executed has the same env variables with the same names.
    1. PB config file
      {
          "host": "${HOST}",
          "port": ${PORT},
          "ssl": {
              "enabled": ${SSL_ENABLED},
              "secure_port": ${SECURE_PORT},
      	... <REST_OF_CONFIG>
      }

      IMPORTANT

      For the values in the config file that comes with quotes, you need to add env variable replace value inside those quotes or add the quotes to the env var.

  3. Replace the default config file with the new one with the env variables and run the Python Bridge.