amaGama settings

amaGama has some settings to allow tuning its behaviour. Below you can see a detailed description for each setting and its default values.

amaGama settings are stored in amagama/settings.py.

Alternatively you can specify settings in a separate file to override the built-in settings in amagama/settings.py. This avoids having to edit a file that is tracked in the version control system. To use these settings, set the environment variable AMAGAMA_CONFIG to the full path of your file. This should be used as overrides to the default settings, so whatever is specified in this file will take precedence over the file settings.py.

Global settings

Settings to define amaGama server behavior.

DEBUG

Default: False

Indicates if debug mode is enabled.

SECRET_KEY

Default: foobar

The secret key to use for keeping the sessions secure. Choose a long random string and keep this secret. amaGama logs a warning at startup while it is still the default.

ENABLE_WEB_UI

Default: False

Enables the web interface: a page for looking up translations, in the language of its ?lang= argument or else the browser’s, as the sources list is.

The page is translated in amagama/po/web/: one <lang>.po per language, from the template web.pot, as block titles are. After changing the page’s text, regenerate the template; the tests fail while it’s out of date:

$ amagama-manage web_pot
ENABLE_DATA_ALTERING_API

Default: False

Enables the operations of the amaGama API that alters data. If set to False, the system can be considered read-only.

This doesn’t affect to the part of the API that is used to perform queries that don’t alter the data. For example retrieving translations is always enabled.

Database settings

Settings used for connecting to the amaGama database.

DB_HOST

Default: "localhost"

Hostname of the server where the amaGama database is located.

DB_NAME

Default: "amagama"

amaGama database name.

DB_PASSWORD

Default: ""

Password for the amaGama database user.

DB_PORT

Default: "5432"

Port number where the database server holding the amaGama database is listening.

DB_USER

Default: "postgres"

User name for connecting to the amaGama database.

Database pool settings

Settings for the database pool.

DB_MAX_CONNECTIONS

Default: 20

Maximum number of connections in the database pool.

DB_MIN_CONNECTIONS

Default: 2

Minimum number of connections in the database pool.

Cache settings

amaGama uses Flask-Caching to cache source-id lookups. Any of Flask-Caching’s CACHE_* settings can be set here to configure it.

CACHE_TYPE

Default: SimpleCache

The Flask-Caching backend to use. The default is a simple per-process in-memory cache. For a deployment running multiple worker processes, a shared backend such as RedisCache (with CACHE_REDIS_URL) gives a better cache hit rate.

Updater settings

Settings for fetching translations to import, see Translation sources.

UPDATER_CACHE_DIR

Default: ~/.cache/amagama-updater

Where fetched translations are kept, one directory per block. Each translation file is kept zstd-compressed (.zst, about a fifth of its size) and decompressed only while it is imported; templates are kept as they are. .repos holds the git repositories the blocks fetch from, which the commands writing blocks also read when the cache exists.

UPDATER_EXCLUDE_TAGS

Default: []

Blocks with any of these tags are left out of fetching and building, such as ["trial"].

UPDATER_FIRST_FETCHES

Default: 100

How many blocks one run of fetch_sources or update fetches for the first time, picked at random, so an empty cache fills over several days instead of in one burst on every source. A block whose first fetch failed is retried without counting. None is no limit.

UPDATER_SOURCES

Default: None

The sources file to use instead of amagama/updater/sources.toml.

UPDATER_TAGS

Default: None

The tags of the blocks this server fetches and builds: blocks with any of them, such as ["core", "platform"]. None is every block.

UPDATER_WORKERS

Default: 4

How many files update imports at once, each in its own process with its own database connection.

Levenshtein settings

Settings for Levenshtein algorithm. See Levenshtein distance for more information.

MAX_CANDIDATES

Default: 5

The maximum number of results returned. This can be overridden by providing another value using a query string.

MAX_LENGTH

Default: 2000

Maximum length of source strings. If a string is longer, then it won’t be matched or returned in the results. This setting is also used during import to filter out source strings. It is therefore not very meaningful to increase this after importing translations. Note that a value above 3000 characters (or even less for CJK languages) might give problems, and is less likely to be useful to users. It is after all about a whole page of text in one string!

MIN_SIMILARITY

Default: 70

The minimum similarity between the query string and the candidate strings.

This can be overridden by providing a higher value using a query string, but the setting is considered a lower limit. This setting is used during database deployment to determine optimal settings for the database indexes. It will be detrimental to performance to lower this setting after deploying the database, up to the point of possibly enabling denial of service attacks.