Skip to main content

Open WebUI Bootstrap - A tool to bootstrap Open WebUI deployments by writing configuration directly to the database

Project description

Open WebUI Bootstrap

A Python library and command-line tool to bootstrap Open WebUI deployments by writing configuration directly to the Open WebUI database.

Status

This is early-stage software and not intended for production use. The API and functionality are subject to change without notice. Use at your own risk for development and testing purposes only.

Features

  • Database Configuration: Write users, groups, models, and connections directly to the Open WebUI SQLite database
  • Upsert Functionality: Update existing records or add new ones
  • Reset Capability: Clear managed tables before applying new configuration
  • Dry Run Mode: Test configuration without making database changes
  • Comprehensive Logging: Color-formatted logging with configurable verbosity
  • Extensible Design: Abstract database interface for future database support

Installation

uv add openwebui-bootstrap

Usage

Command Line Interface

Basic Usage

openwebui-bootstrap --config config.yaml

Reset Database Before Applying Configuration

openwebui-bootstrap --config config.yaml --reset

Dry Run (Test Without Changes)

openwebui-bootstrap --config config.yaml --dry-run

Set Log Level

openwebui-bootstrap --config config.yaml --log-level debug

Python Library Usage

The package can also be used as a Python library in third-party applications. The public API provides the same functionality as the CLI tool.

Basic Bootstrap

from openwebui_bootstrap import bootstrap_openwebui

# Bootstrap Open WebUI with configuration
bootstrap_openwebui(
    config_path="config.yaml",
    database_path="/path/to/webui.db",  # Optional, defaults to config
    reset=True,                         # Reset database before applying
    dry_run=False,                      # Make actual changes
    log_level="info"                    # Log level
)

Load and Apply Configuration Separately

from openwebui_bootstrap import load_config, apply_config

# Load configuration
config = load_config("config.yaml")

# Apply configuration to database
apply_config(
    config=config,
    database_path="/path/to/webui.db",
    dry_run=False
)

Reset Database Only

from openwebui_bootstrap import reset_database

# Reset database (clear managed tables)
reset_database(
    database_path="/path/to/webui.db",
    dry_run=False
)

Advanced Usage with ConfigManager

from openwebui_bootstrap import ConfigManager, SQLiteDatabase

# Create database interface
database = SQLiteDatabase("/path/to/webui.db")

# Create configuration manager
config_manager = ConfigManager(database)
config_manager.set_dry_run(False)

# Load and apply configuration
config = config_manager.load_config("config.yaml")
config_manager.apply_config(config)

Public API Reference

Functions

  • bootstrap_openwebui(config_path, database_path=None, reset=False, dry_run=False, log_level="info")

    • Complete bootstrap operation (load config + apply config + optional reset)
    • Equivalent to CLI command with all options
  • load_config(config_path)

    • Load and validate configuration from YAML file
    • Returns OpenWebUIConfig object
    • Raises ConfigurationFileError or ConfigurationValidationError
  • apply_config(config, database_path, dry_run=False)

    • Apply configuration to database
    • Raises DatabaseError or DryRunError
  • reset_database(database_path, dry_run=False)

    • Clear all managed tables in database
    • Raises DatabaseError or DryRunError

Classes

  • ConfigManager(database) - Main configuration manager
  • SQLiteDatabase(database_path) - SQLite database interface
  • OpenWebUIConfig - Main configuration model
  • UserConfig, GroupConfig, ModelConfig, etc. - Configuration sub-models

Exceptions

  • OpenWebUIBootstrapError - Base exception
  • ConfigurationError - Configuration-related errors
  • DatabaseError - Database-related errors
  • DryRunError - Dry run mode errors

Public API Design Philosophy

The public API is designed to:

  1. Mirror CLI functionality - All CLI operations are available as Python functions
  2. Provide flexibility - Functions can be used individually or combined
  3. Maintain simplicity - Simple, intuitive function signatures
  4. Ensure type safety - Full type hints for IDE support
  5. Offer comprehensive error handling - Clear exception hierarchy

The API reuses existing components (ConfigManager, SQLiteDatabase) to ensure consistency and reduce code duplication.

Configuration File

Create a YAML configuration file (see example-config.yaml for reference):

database:
  type: sqlite
  database_location: /path/to/webui.db

users:
  - name: Admin User
    email: admin@example.com
    role: Admin

groups:
  - name: developers
    description: Development team
    permissions:
      - import_models
      - export_models
    members:
      - admin@example.com

connections:
  type: openai
  url: https://api.example.com/v1
  bearer: your-api-key
  model_ids:
    - gpt-4
    - gpt-3.5-turbo

models:
  prompt_path: /path/to/prompts
  icon_path: /path/to/icons

Project Structure

openwebui_bootstrap/
├── cli.py                  # Command-line interface
├── config_manager.py       # Configuration management
├── database/
│   ├── base.py             # Abstract database interface
│   └── sqlite.py           # SQLite implementation
├── exceptions.py           # Custom exceptions
├── logging_config.py       # Logging configuration
├── models.py               # Data models
└── __init__.py

Development

Setup

uv sync --dev

Running Tests

uv run pytest

Running Tests with Coverage

uv run pytest --cov=openwebui_bootstrap --cov-report=term-missing

Code Formatting

uv run ruff format
uv run ruff check

License

MIT

Disclaimer

This code is provided "as is" without warranty of any kind, express or implied. The authors shall not be held liable for any damages arising from the use of this software. Use at your own risk.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openwebui_bootstrap-0.3.7.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openwebui_bootstrap-0.3.7-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file openwebui_bootstrap-0.3.7.tar.gz.

File metadata

  • Download URL: openwebui_bootstrap-0.3.7.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for openwebui_bootstrap-0.3.7.tar.gz
Algorithm Hash digest
SHA256 5336a6308c03ca8efdf5d83a8e25a0fae6a4694548fd92ded97237e1e330c9af
MD5 2b029553834a15cb8ce9a864af521d8b
BLAKE2b-256 7dac978cb04a100775af1fcbcb6f48345dc929baa535c8ed6e39b1c97b292efb

See more details on using hashes here.

File details

Details for the file openwebui_bootstrap-0.3.7-py3-none-any.whl.

File metadata

File hashes

Hashes for openwebui_bootstrap-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 81a9273c43540d8625d97ea3ef4557cb603f339863d3a52590c8490e41fc5b39
MD5 0c77a59d5a426f9374d879c56fe3f843
BLAKE2b-256 fa23ce9ec81b10209a1d31b84b78effd0a141350e1afab1516e1a7603cd7f1a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page