tdp-lib

Python Version Code style: ruff

TDP Lib

tdp-lib is a Python library built on top of Ansible. It is designed for managing TDP clusters, offering advanced tools to extend Ansible’s capabilities. Key features include:

tdp-lib can be utilized in various ways: as a Python library, through an admin CLI, via a REST API (see tdp-server), or through a web interface (see tdp-ui).

Pre-requisites

To use tdp-lib, ensure you have the following prerequisites:

Optional dependencies for DAG visualization:

Installation

Set the following environment variables:

Ensure Ansible is configured to use the tosit.tdp.inventory plugin. Example ansible.cfg:

[defaults]
inventory=your_inventory,..,~/tdp_vars

[inventory]
enable_plugins = tosit.tdp.inventory,..,your_plugins

Install the library:

# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate
# Install the dependencies
pip install "tdp-lib[visualization]@https://github.com/TOSIT-IO/tdp-lib/tarball/1.0.0"
# Initialize the database and tdp_vars
tdp init

Supported databases

tdp-lib uses SQLite by default. Other backends are supported:

CLI Usage

[!NOTE] This section is a work in progress.

tdp --help

Contributing

Contributions are welcome! Here are some guidelines specific to this project:

Dev environment

Use uv for development:

# Install dependencies
uv sync --all-extras

Testing

Tests are based on Pytest:

uv run pytest

tdp-lib is supporting SQLite, PostgreSQL and MariaDB. A compose.yaml is provided to run test accross all suported environments:

docker compose -f dev/docker-compose.yaml up -d
uv run pytest tests --database-dsn 'postgresql+psycopg2://postgres:postgres@localhost:5432/tdp' --database-dsn 'mysql+pymysql://mysql:mysql@localhost:3306/tdp' --database-dsn 'mysql+pymysql://mariadb:mariadb@localhost:3307/tdp'
docker compose -f dev/docker-compose.yaml down -v

Contributions

Commit messages must adhere to the Conventional Commits standard.

Code must be formated and ensure the linting rules before being merged. This project use Ruff:

# Format the code and reorder imports
uv run ruff check --select I --fix && uv run ruff format
# Check the code for linting issues
uv run ruff check
# Lint the code
uv run ruff check --fix