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.1.tar.gz (18.4 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.1-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: krl_core-0.1.1.tar.gz
  • Upload date:
  • Size: 18.4 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.1.tar.gz
Algorithm Hash digest
SHA256 0645a2cbea18c118e3c8cf81e08100198ea9abe2e4ec65d2bf12e0d71d810056
MD5 4b21653d2cf8625a154fc8dc0f21c8ec
BLAKE2b-256 07e5e1928440aa32f2c0149050f8af46f2f1d3806cb1e99a4158983fb3c7512f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: krl_core-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 18ff100ab3eaa7537b425abbac367aa7281fbaa2b40550a7cddce1772b0a236f
MD5 4cc4b2f3e35a08969e2df5c2bf4629f8
BLAKE2b-256 e5f2cfbff06115898f9ec29b5df3139d880059502eccf21ba0ccbc92e02eea7b

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