CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-tutor

The Docker-based Open edX distribution designed for peace of mind

Overview
Eval results
Files

configuration.mddocs/

Configuration Management

Centralized configuration system for Open edX platform settings with support for defaults, user overrides, environment variables, and interactive setup. The configuration system handles all aspects of platform customization including URLs, passwords, service settings, and plugin configurations.

Capabilities

Configuration Loading

Load configuration from various sources with validation and merging of defaults, user settings, and environment overrides.

def load(root: str) -> Config:
    """
    Load full configuration with complete validation and all sources merged.
    
    Args:
        root (str): Project root directory path
        
    Returns:
        Config: Complete configuration dictionary with all settings
    """

def load_defaults() -> Config:
    """
    Load only default configuration values without user customizations.
    
    Returns:
        Config: Default configuration dictionary
    """

def load_minimal(root: str) -> Config:
    """
    Load minimal config (user + base) without applying defaults.
    
    Args:
        root (str): Project root directory path
        
    Returns:
        Config: Basic configuration dictionary
    """

def load_full(root: str) -> Config:
    """
    Load complete configuration (user + base + defaults) with full validation.
    Note: This is an internal function called by load().
    
    Args:
        root (str): Project root directory path
        
    Returns:
        Config: Complete configuration dictionary
    """

Configuration Updates

Update configuration data with different sources and validation levels.

def update_with_base(config: Config) -> None:
    """
    Add base configuration settings to existing config.
    
    Args:
        config (Config): Configuration dictionary to update in-place
    """

def update_with_defaults(config: Config) -> None:
    """
    Add default values for missing configuration keys.
    
    Args:
        config (Config): Configuration dictionary to update in-place
    """

def update_with_env(config: Config) -> None:
    """
    Override configuration values from environment variables.
    Environment variables should be prefixed with TUTOR_.
    
    Args:
        config (Config): Configuration dictionary to update in-place
    """

Configuration File Operations

Save and manage configuration files on disk.

def save_config_file(root: str, config: Config) -> None:
    """
    Save configuration to config.yml file.
    
    Args:
        root (str): Project root directory path
        config (Config): Configuration dictionary to save
    """

def config_file_path(root: str) -> str:
    """
    Get the path to the config.yml file.
    
    Args:
        root (str): Project root directory path
        
    Returns:
        str: Full path to config.yml file
    """

Interactive Configuration

Interactive configuration setup with prompts and validation.

def save_config_with_prompts(root: str, config: Config, interactive: bool = False) -> Config:
    """
    Save configuration with optional interactive prompts for missing values.
    
    Args:
        root (str): Project root directory path
        config (Config): Base configuration dictionary
        interactive (bool): Whether to prompt for missing values
        
    Returns:
        Config: Updated configuration dictionary
    """

Configuration Validation

Validate configuration values and check for required settings.

def check_config(config: Config) -> None:
    """
    Validate configuration for required values and correct formats.
    
    Args:
        config (Config): Configuration dictionary to validate
        
    Raises:
        TutorError: If configuration is invalid or missing required values
    """

Configuration Structure

Core Configuration Keys

# Platform settings
PLATFORM_NAME: str  # Name of the Open edX platform
PLATFORM_DESCRIPTION: str  # Platform description
CONTACT_EMAIL: str  # Contact email address

# Domain and URL settings  
LMS_HOST: str  # Learning Management System hostname
CMS_HOST: str  # Content Management System hostname
PREVIEW_LMS_HOST: str  # Preview hostname

# Database settings
MYSQL_HOST: str  # MySQL database host
MYSQL_PORT: int  # MySQL database port
MYSQL_ROOT_USER: str  # MySQL root username
MYSQL_ROOT_PASSWORD: str  # MySQL root password

# Cache settings  
REDIS_HOST: str  # Redis cache host
REDIS_PORT: int  # Redis cache port

# Security settings
SECRET_KEY: str  # Django secret key
JWT_SECRET_KEY: str  # JWT signing key
OPENEDX_SECRET_KEY: str  # Open edX secret key

# Docker settings
DOCKER_REGISTRY: str  # Docker registry for custom images
DOCKER_IMAGE_TAG: str  # Tag for Open edX Docker images

# Plugin settings
PLUGINS: List[str]  # List of enabled plugins
PLUGIN_CONFIG: Dict[str, Any]  # Plugin-specific configuration

Environment-Specific Settings

# Local development settings
RUN_LMS: bool  # Whether to run LMS service
RUN_CMS: bool  # Whether to run CMS service
LOCAL_HOST: str  # Local development hostname

# Kubernetes settings
K8S_NAMESPACE: str  # Kubernetes namespace
K8S_ENABLE_HTTPS: bool  # Enable HTTPS in Kubernetes

# Development settings
ENABLE_HTTPS: bool  # Enable HTTPS
DEV_PROJECT_NAME: str  # Development project name

Constants

CONFIG_FILENAME = "config.yml"  # Default configuration filename

Usage Examples

Basic Configuration Loading

from tutor import config
from tutor.commands.context import Context

# Load complete configuration
context = Context("/path/to/tutor/root")
config_data = config.load(context.root)

# Access configuration values
platform_name = config_data["PLATFORM_NAME"]
lms_host = config_data["LMS_HOST"]

Configuration Updates

from tutor import config

# Load and update configuration
config_data = config.load("/path/to/tutor/root")

# Update values
config_data["PLATFORM_NAME"] = "My Custom Platform"
config_data["CONTACT_EMAIL"] = "admin@example.com"

# Save updated configuration
config.save_config_file("/path/to/tutor/root", config_data)

Environment Variable Overrides

import os
from tutor import config

# Set environment variables
os.environ["TUTOR_PLATFORM_NAME"] = "Production Platform"
os.environ["TUTOR_LMS_HOST"] = "learn.example.com"

# Load configuration with environment overrides
config_data = config.load("/path/to/tutor/root")
# Values from environment variables will override config file

Interactive Configuration

from tutor.commands.config import save
from tutor.commands.context import Context

context = Context("/path/to/tutor/root")

# Run interactive configuration
save(
    context=context,
    interactive=True,
    set_vars=[],
    append_vars=[],
    remove_vars=[],
    unset_vars=[],
    env_only=False,
    clean_env=False
)

Programmatic Configuration Changes

from tutor import config

# Load minimal config
config_data = config.load_minimal("/path/to/tutor/root")

# Add specific settings
config_data.update({
    "PLATFORM_NAME": "Development Platform",
    "ENABLE_HTTPS": False,
    "PLUGINS": ["discovery", "forum"]
})

# Apply defaults and save
config.update_with_defaults(config_data)
config.save_config_file("/path/to/tutor/root", config_data)

Install with Tessl CLI

npx tessl i tessl/pypi-tutor

docs

cli-commands.md

configuration.md

environment.md

hooks-plugins.md

index.md

task-execution.md

utilities.md

tile.json