A Python library for common features in application development.
Project description
dtPyAppFramework
dtPyAppFramework is a comprehensive Python framework library designed as the foundation for creating robust Python applications. It provides enterprise-grade features including layered configuration management, multi-cloud secrets storage, advanced multi-processing task management, sophisticated logging with nested support for spawned processes, singleton pattern utilities, and application path management.
๐ Key Features
- ๐ณ Container Mode: Full containerization support with
--containerflag for Docker, Kubernetes, and container orchestration - โ๏ธ Layered Configuration: Multi-tier configuration system with working directory, user, and system-level settings
- ๐ Multi-Cloud Secrets: Seamless integration with AWS Secrets Manager, Azure Key Vault, and local encrypted storage
- ๐ฑ AbstractApp Foundation: Complete application framework with command-line parsing, logging, and lifecycle management
- ๐ Advanced Multiprocessing: Process spawning, task coordination, and nested logging for parallel execution
- ๐ Sophisticated Logging: Cross-process synchronized logging with color coding and automatic rotation
- ๐ก๏ธ Security Framework: Comprehensive validation, encryption, and secure file handling
- ๐ Path Management: Automatic application directory structure and resource management
- ๐ง Singleton Utilities: Thread-safe singleton pattern implementation with parameter support
๐ฆ Installation
From PyPI (Future)
pip install dtPyAppFramework
Development Installation
# Clone the repository
git clone <repository-url>
cd dtPyAppFramework
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
๐ Quick Start
Basic Application
Create a simple application using the AbstractApp foundation:
from dtPyAppFramework.application import AbstractApp
import logging
class MyApplication(AbstractApp):
def define_args(self, arg_parser):
"""Define custom command-line arguments"""
arg_parser.add_argument('--task', default='hello',
help='Task to perform')
def main(self, args):
"""Main application logic"""
logging.info(f"Running task: {args.task}")
# Access configuration
app_name = self.settings.get('app.name', 'MyApp')
logging.info(f"Application: {app_name}")
# Your application logic here
# Create and run the application
if __name__ == "__main__":
app = MyApplication(
description="My Sample Application",
version="1.0.0",
short_name="my-app",
full_name="My Sample Application",
console_app=True
)
app.run()
Container Mode
For containerized deployments (Docker, Kubernetes):
# Enable container mode with simplified directory structure
app.run() # Use --container flag or set CONTAINER_MODE=true
# Or detect container environment automatically
if os.path.exists('/.dockerenv'):
os.environ['CONTAINER_MODE'] = 'True'
๐ง Core Framework Components
๐ณ Container Mode
Full support for containerized deployments with simplified directory structure:
- Simplified Paths: All directories (
config/,data/,logs/,temp/) in working directory - Single Config Layer: No multi-tier configuration in container mode
- Environment Detection: Automatic detection of Docker/Kubernetes environments
- Volume Mounting: Designed for persistent volume mounting
# Enable container mode
python app.py --container
# or
export CONTAINER_MODE=true && python app.py
โ๏ธ Layered Configuration Management
Multi-tier configuration system with automatic merging:
- Working Directory:
./config/config.yaml - User Level: User-specific configurations
- System Level: System-wide configurations (standard mode only)
# config.yaml example
app:
name: "MyApp"
debug: false
secrets:
azure:
vault_url: "https://vault.vault.azure.net/"
logging:
level: "INFO"
console_colors: true
๐ Multi-Cloud Secrets Management
Unified interface for multiple secret storage backends:
- AWS Secrets Manager: Full boto3 integration
- Azure Key Vault: azure-keyvault-secrets support
- Local Encrypted Storage: cryptography-based local secrets
- Environment Variables: SEC/ prefix resolution
# Usage example
settings = Settings()
api_key = settings.get('SEC/api_key', 'default-key')
settings.secret_manager.set_secret('db_password', 'secret123')
๐ Advanced Logging System
Sophisticated logging with cross-process support:
- Nested Logging: Each spawned process gets its own namespace
- Color Coding: Console output with colorlog integration
- Log Rotation: Automatic file rotation and management
- Cross-Process Sync: Synchronized logging between parent/child processes
๐ Multiprocessing Framework
Advanced process management and task coordination:
- Process Spawning: Managed subprocess creation with psutil
- Task Coordination: Process pool management and task distribution
- Resource Monitoring: Memory and CPU usage tracking
- Cleanup Handling: Automatic process cleanup and resource management
๐ก๏ธ Security Features
Comprehensive security framework:
- File Validation: Secure file operations and path validation
- Encryption: Local secret encryption with cryptography
- Access Control: Platform-specific permission handling
- Error Handling: Secure error reporting without information leakage
๐ Samples and Examples
Comprehensive samples are available in the ./samples/ directory:
- Container Mode - Complete Docker/Kubernetes example with deployment files
- Simple App - Basic application structure and development mode
- Multiprocessing - Advanced parallel processing examples
Each sample includes detailed README documentation with setup instructions, usage examples, and best practices.
๐๏ธ Project Structure
dtPyAppFramework/
โโโ src/
โ โโโ dtPyAppFramework/ # Main framework source
โ โโโ application.py # AbstractApp base class
โ โโโ paths/ # Application path management
โ โโโ settings/ # Configuration and secrets
โ โโโ security/ # Security framework
โ โโโ logging/ # Advanced logging system
โ โโโ decorators/ # Singleton and utilities
โ โโโ process/ # Multiprocessing framework
โ โโโ resources/ # Resource management
โโโ samples/ # Usage examples
โโโ tests/ # Comprehensive test suite
โโโ docs/ # Documentation (RST format)
โโโ requirements.txt # Core dependencies
๐ง Development
Running Tests
# Run full test suite
pytest
# Run with coverage
pytest --cov=src/dtPyAppFramework
# Watch mode for development
pytest-watch
Core Dependencies
PyYAML~=6.0.2 # Configuration parsing
colorlog~=6.9.0 # Console color coding
psutil~=6.1.0 # Process management
cryptography~=44.0.0 # Local encryption
boto3~=1.35.54 # AWS integration
azure-identity # Azure authentication
azure-keyvault-secrets # Azure Key Vault
pytest~=8.3.3 # Testing framework
InquirerPy # Interactive CLI prompts
๐ Documentation
- Getting Started - Framework introduction and basic usage
- Application Framework - Container mode and application lifecycle
- Configuration Management - Settings and layered config
- Secrets Management - Multi-cloud secret handling
- API Reference - Complete API documentation
๐ค Contributing
We welcome contributions! Please see our contributing guidelines for:
- Code style and standards (Python 3.12+)
- Testing requirements (pytest with full coverage)
- Documentation standards (RST format)
- Sample creation guidelines
๐ License
This project is licensed under the MIT License.
๐ง Support
For questions, bug reports, or feature requests:
- Issues: GitHub Issues
- Email: dev@digital-thought.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dtpyappframework-4.4.0.tar.gz.
File metadata
- Download URL: dtpyappframework-4.4.0.tar.gz
- Upload date:
- Size: 116.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57b915b1175a3b403427a0ada24abb8f0fcad5d55775a4a756016af4b9298dfd
|
|
| MD5 |
08b7b33a590c8273b3a7c5e4a7c47f73
|
|
| BLAKE2b-256 |
bc8a05136bf9a40e4d0463a7826d76f283493ab56464887b3c13e5ead8acb618
|
Provenance
The following attestation bundles were made for dtpyappframework-4.4.0.tar.gz:
Publisher:
publish-to-pypi.yml on Digital-Thought/dtPyAppFramework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dtpyappframework-4.4.0.tar.gz -
Subject digest:
57b915b1175a3b403427a0ada24abb8f0fcad5d55775a4a756016af4b9298dfd - Sigstore transparency entry: 1053969816
- Sigstore integration time:
-
Permalink:
Digital-Thought/dtPyAppFramework@77cc0a15b42c779fe966942e6883818c98df82cc -
Branch / Tag:
refs/tags/v4.4.0 - Owner: https://github.com/Digital-Thought
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@77cc0a15b42c779fe966942e6883818c98df82cc -
Trigger Event:
push
-
Statement type:
File details
Details for the file dtpyappframework-4.4.0-py3-none-any.whl.
File metadata
- Download URL: dtpyappframework-4.4.0-py3-none-any.whl
- Upload date:
- Size: 70.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ae486a8b2df7d32a95fa2eedd9a8aa11861201f0750c2dc9ea3aaccaf92b804
|
|
| MD5 |
08bbfb6097ce9d0a0859533c34c1c9a4
|
|
| BLAKE2b-256 |
aee61d9c02665aa76af4dcf14e05351e84512c8940d014fb4d107ec56771548f
|
Provenance
The following attestation bundles were made for dtpyappframework-4.4.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on Digital-Thought/dtPyAppFramework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dtpyappframework-4.4.0-py3-none-any.whl -
Subject digest:
6ae486a8b2df7d32a95fa2eedd9a8aa11861201f0750c2dc9ea3aaccaf92b804 - Sigstore transparency entry: 1053969817
- Sigstore integration time:
-
Permalink:
Digital-Thought/dtPyAppFramework@77cc0a15b42c779fe966942e6883818c98df82cc -
Branch / Tag:
refs/tags/v4.4.0 - Owner: https://github.com/Digital-Thought
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@77cc0a15b42c779fe966942e6883818c98df82cc -
Trigger Event:
push
-
Statement type: