Skip to content

Settings

aana.configs

DbSettings

Bases: BaseSettings

Database configuration.

ATTRIBUTE DESCRIPTION
datastore_type

The type of the datastore. Default is DbType.SQLITE.

TYPE: DbType | str

datastore_config

The configuration for the datastore. Default is SQLiteConfig(path="/var/lib/aana_data").

TYPE: SQLiteConfig | PostgreSQLConfig

pool_size

The number of connections to keep in the pool. Default is 5.

TYPE: int

max_overflow

The number of connections that can be created when the pool is exhausted. Default is 10.

TYPE: int

pool_recycle

The number of seconds a connection can be idle in the pool before it is invalidated. Default is 3600.

TYPE: int

get_engine

get_engine()

Gets engine. Each instance of DbSettings will create a max.of 1 engine.

Source code in aana/configs/db.py
def get_engine(self):
    """Gets engine. Each instance of DbSettings will create a max.of 1 engine."""
    if not self._engine:
        self._engine = create_database_engine(self)
    return self._engine

PostgreSQLConfig

Bases: TypedDict

Config values for PostgreSQL.

ATTRIBUTE DESCRIPTION
host

The host of the PostgreSQL server.

TYPE: str

port

The port of the PostgreSQL server.

TYPE: int

user

The user to connect to the PostgreSQL server.

TYPE: str

password

The password to connect to the PostgreSQL server.

TYPE: str

database

The database name.

TYPE: str

SQLiteConfig

Bases: TypedDict

Config values for SQLite.

ATTRIBUTE DESCRIPTION
path

The path to the SQLite database file.

TYPE: PathLike

Settings

Bases: BaseSettings

A pydantic model for SDK settings.

ATTRIBUTE DESCRIPTION
tmp_data_dir

The temporary data directory.

TYPE: Path

image_dir

The temporary image directory.

TYPE: Path

video_dir

The temporary video directory.

TYPE: Path

audio_dir

The temporary audio directory.

TYPE: Path

model_dir

The temporary model directory.

TYPE: Path

num_workers

The number of web workers.

TYPE: int

openai_endpoint_enabled

Flag indicating if the OpenAI-compatible endpoint is enabled. Enabled by default.

TYPE: bool

include_stacktrace

Flag indicating if stacktrace should be included in error messages. Enabled by default.

TYPE: bool

task_queue

The task queue settings.

TYPE: TaskQueueSettings

db_config

The database configuration.

TYPE: DbSettings

test

The test settings.

TYPE: TestSettings

setup_resource_directories

setup_resource_directories()

Create the resource directories if they do not exist.

Source code in aana/configs/settings.py
@model_validator(mode="after")
def setup_resource_directories(self):
    """Create the resource directories if they do not exist."""
    if self.image_dir is None:
        self.image_dir = self.tmp_data_dir / "images"
    if self.video_dir is None:
        self.video_dir = self.tmp_data_dir / "videos"
    if self.audio_dir is None:
        self.audio_dir = self.tmp_data_dir / "audios"
    if self.model_dir is None:
        self.model_dir = self.tmp_data_dir / "models"

    self.tmp_data_dir.mkdir(parents=True, exist_ok=True)
    self.image_dir.mkdir(parents=True, exist_ok=True)
    self.video_dir.mkdir(parents=True, exist_ok=True)
    self.audio_dir.mkdir(parents=True, exist_ok=True)
    self.model_dir.mkdir(parents=True, exist_ok=True)
    return self

TaskQueueSettings

Bases: BaseModel

A pydantic model for task queue settings.

ATTRIBUTE DESCRIPTION
enabled

Flag indicating if the task queue is enabled.

TYPE: bool

num_workers

The number of workers in the task queue.

TYPE: int

execution_timeout

The maximum execution time for a task in seconds. After this time, if the task is still running, it will be considered as stuck and will be reassign to another worker.

TYPE: int

heartbeat_timeout

The maximum time between heartbeats in seconds.

TYPE: int

max_retries

The maximum number of retries for a task.

TYPE: int

maximum_active_tasks_per_user

The maximum number of active tasks per user (only applicable in the API service).

TYPE: int

TestSettings

Bases: BaseModel

A pydantic model for test settings.

ATTRIBUTE DESCRIPTION
test_mode

Flag indicating if the SDK is in test mode.

TYPE: bool

save_expected_output

Flag indicating if the expected output should be saved (to create test cases).

TYPE: bool

DbType

Bases: str, Enum

Engine types for relational database.

ATTRIBUTE DESCRIPTION
POSTGRESQL

PostgreSQL database.

SQLITE

SQLite database.