Skip to main content

Shared foundation utilities for the KR-Labs analytics platform

Project description


© 2025 KR-Labs. All rights reserved.
KR-Labs™ is a trademark of Quipu Research Labs, LLC, a subsidiary of Sudiata Giddasira, Inc.

SPDX-License-Identifier: MIT

KRL Core Utilities

License: MIT Python Code style: black Tests Coverage

Shared foundation utilities for the KR-Labs analytics platform

krl-core provides common utilities, configuration management, logging, caching, and base classes used across all KRL packages. It serves as the foundational layer for the entire KR-Labs ecosystem.

Features

  • 🔧 Configuration Management: Environment variable and YAML-based configuration
  • 📝 Structured Logging: JSON-formatted logging with context and correlation IDs
  • Caching: File-based and Redis caching with TTL support
  • 🌐 API Client Base: Reusable HTTP client with retry logic and rate limiting
  • 🛠️ Utilities: Date parsing, validation, decorators, and common helpers

Installation

pip install krl-core

Quick Start

Logging

from krl_core import get_logger

logger = get_logger(__name__)
logger.info("Application started", extra={"user_id": 123})

Configuration

from krl_core import ConfigManager

config = ConfigManager()
api_key = config.get("FRED_API_KEY")  # From environment or config file

Caching

from krl_core import FileCache

cache = FileCache(cache_dir="./cache", ttl=3600)
data = cache.get("my_key")
if data is None:
    data = expensive_operation()
    cache.set("my_key", data)

Documentation

Full documentation is available at krl-core.readthedocs.io

Development

Setup

# Clone the repository
git clone https://github.com/KR-Labs/krl-open-core.git
cd krl-open-core

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install development dependencies
pip install -e ".[dev,test]"

# Install pre-commit hooks
pre-commit install

Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=src --cov-report=html

# Run specific test
pytest tests/unit/test_logging.py

Code Quality

# Format code
black src/ tests/

# Check imports
isort src/ tests/

# Lint
flake8 src/ tests/

# Type check
mypy src/

Architecture

krl-core/
├── logging/       # Structured logging with JSON formatting
├── config/        # Configuration management (env vars, YAML)
├── cache/         # File and Redis caching with TTL
├── api/           # Base HTTP client with retry/rate limiting
└── utils/         # Common utilities (dates, validators, decorators)

Dependencies

Core Dependencies:

  • Python 3.9+
  • pyyaml - Configuration file parsing
  • python-json-logger - Structured JSON logging
  • requests - HTTP client
  • redis (optional) - Redis caching support

Development Dependencies:

  • pytest - Testing framework
  • pytest-cov - Coverage reporting
  • black - Code formatting
  • flake8 - Linting
  • mypy - Type checking
  • isort - Import sorting

Related Packages

krl-core is the foundation for these KRL packages:

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Contributor License Agreement

Before we can accept your contributions, you'll need to sign our CLA:

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Citation

If you use KRL Core in your research, please cite:

@software{krl_core_2025,
  title = {KRL Core: Shared Utilities for KR-Labs Analytics Platform},
  author = {{KR-Labs Foundation}},
  year = {2025},
  url = {https://github.com/KR-Labs/krl-open-core},
  license = {MIT}
}

KRL™ is a trademark of KR-Labs Foundation.
Copyright © 2025 KR-Labs Foundation. All rights reserved.

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

krl_core-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

krl_core-0.1.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file krl_core-0.1.0.tar.gz.

File metadata

  • Download URL: krl_core-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for krl_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 97a9ed23a44ee65cedb787d4b895866ec5bf29ccab16102a5262bd4c7950dcce
MD5 b7f92a3daf4194106c2acbda415dc54f
BLAKE2b-256 a55c70b44162733f0f995035f4938ab57b7d38c00de1352a8349b2ad10e4a15c

See more details on using hashes here.

File details

Details for the file krl_core-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: krl_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for krl_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aecb257a33888770c933797b09500c818b4f91c8d3ac43a5dc8faec6f86cb5bb
MD5 3cac6ce956db5b12d26f0e142da5b2cb
BLAKE2b-256 5cbe3711038d147529ac1fdd6e05e8d25be4680ab2a418a3bfbb5b3d00e5596f

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