krl-core


Namekrl-core JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryShared foundation utilities for the KR-Labs analytics platform
upload_time2025-10-20 02:16:44
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords krl utilities logging configuration caching api-client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ---
Β© 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](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Tests](https://github.com/KR-Labs/krl-open-core/workflows/Tests/badge.svg)](https://github.com/KR-Labs/krl-open-core/actions)
[![Coverage](https://codecov.io/gh/KR-Labs/krl-open-core/branch/main/graph/badge.svg)](https://codecov.io/gh/KR-Labs/krl-open-core)

> **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

```bash
pip install krl-core
```

## Quick Start

### Logging

```python
from krl_core import get_logger

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

### Configuration

```python
from krl_core import ConfigManager

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

### Caching

```python
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](https://krl-core.readthedocs.io)

- [Installation Guide](https://krl-core.readthedocs.io/en/latest/quickstart.html)
- [API Reference](https://krl-core.readthedocs.io/en/latest/api.html)
- [Configuration](https://krl-core.readthedocs.io/en/latest/config.html)
- [Logging](https://krl-core.readthedocs.io/en/latest/logging.html)
- [Caching](https://krl-core.readthedocs.io/en/latest/cache.html)

## Development

### Setup

```bash
# 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

```bash
# Run all tests
pytest

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

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

### Code Quality

```bash
# 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:

- [krl-data-connectors](https://github.com/KR-Labs/krl-data-connectors) - 40+ data source connectors
- [krl-model-zoo](https://github.com/KR-Labs/krl-model-zoo) - 100+ analytical models
- [krl-dashboard](https://github.com/KR-Labs/krl-dashboard) - Interactive dashboards
- [krl-causal-policy-toolkit](https://github.com/KR-Labs/krl-causal-policy-toolkit) - Causal inference tools
- [krl-network-analysis](https://github.com/KR-Labs/krl-network-analysis) - Network analytics
- [krl-geospatial-tools](https://github.com/KR-Labs/krl-geospatial-tools) - GIS tools

## Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

### Contributor License Agreement

Before we can accept your contributions, you'll need to sign our CLA:
- [Individual CLA](https://github.com/KR-Labs/.github/blob/main/CLA/INDIVIDUAL_CLA.md)
- [Corporate CLA](https://github.com/KR-Labs/.github/blob/main/CLA/CORPORATE_CLA.md)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

- πŸ“§ Email: support@krlabs.dev
- πŸ’¬ GitHub Issues: [Report a bug](https://github.com/KR-Labs/krl-open-core/issues/new?template=bug_report.md)
- πŸ“– Documentation: [krl-core.readthedocs.io](https://krl-core.readthedocs.io)
- 🌐 Website: [krlabs.dev](https://krlabs.dev)

## Citation

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

```bibtex
@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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "krl-core",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "KR-Labs Foundation <support@krlabs.dev>",
    "keywords": "krl, utilities, logging, configuration, caching, api-client",
    "author": null,
    "author_email": "\"Quipu Research Labs, LLC\" <support@krlabs.dev>",
    "download_url": "https://files.pythonhosted.org/packages/07/e5/e1928440aa32f2c0149050f8af46f2f1d3806cb1e99a4158983fb3c7512f/krl_core-0.1.1.tar.gz",
    "platform": null,
    "description": "---\n\u00a9 2025 KR-Labs. All rights reserved.  \nKR-Labs\u2122 is a trademark of Quipu Research Labs, LLC, a subsidiary of Sudiata Giddasira, Inc.\n\nSPDX-License-Identifier: MIT\n---\n\n# KRL Core Utilities\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Tests](https://github.com/KR-Labs/krl-open-core/workflows/Tests/badge.svg)](https://github.com/KR-Labs/krl-open-core/actions)\n[![Coverage](https://codecov.io/gh/KR-Labs/krl-open-core/branch/main/graph/badge.svg)](https://codecov.io/gh/KR-Labs/krl-open-core)\n\n> **Shared foundation utilities for the KR-Labs analytics platform**\n\n`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.\n\n## Features\n\n- \ud83d\udd27 **Configuration Management**: Environment variable and YAML-based configuration\n- \ud83d\udcdd **Structured Logging**: JSON-formatted logging with context and correlation IDs\n- \u26a1 **Caching**: File-based and Redis caching with TTL support\n- \ud83c\udf10 **API Client Base**: Reusable HTTP client with retry logic and rate limiting\n- \ud83d\udee0\ufe0f **Utilities**: Date parsing, validation, decorators, and common helpers\n\n## Installation\n\n```bash\npip install krl-core\n```\n\n## Quick Start\n\n### Logging\n\n```python\nfrom krl_core import get_logger\n\nlogger = get_logger(__name__)\nlogger.info(\"Application started\", extra={\"user_id\": 123})\n```\n\n### Configuration\n\n```python\nfrom krl_core import ConfigManager\n\nconfig = ConfigManager()\napi_key = config.get(\"FRED_API_KEY\")  # From environment or config file\n```\n\n### Caching\n\n```python\nfrom krl_core import FileCache\n\ncache = FileCache(cache_dir=\"./cache\", ttl=3600)\ndata = cache.get(\"my_key\")\nif data is None:\n    data = expensive_operation()\n    cache.set(\"my_key\", data)\n```\n\n## Documentation\n\nFull documentation is available at [krl-core.readthedocs.io](https://krl-core.readthedocs.io)\n\n- [Installation Guide](https://krl-core.readthedocs.io/en/latest/quickstart.html)\n- [API Reference](https://krl-core.readthedocs.io/en/latest/api.html)\n- [Configuration](https://krl-core.readthedocs.io/en/latest/config.html)\n- [Logging](https://krl-core.readthedocs.io/en/latest/logging.html)\n- [Caching](https://krl-core.readthedocs.io/en/latest/cache.html)\n\n## Development\n\n### Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/KR-Labs/krl-open-core.git\ncd krl-open-core\n\n# Create virtual environment\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n\n# Install development dependencies\npip install -e \".[dev,test]\"\n\n# Install pre-commit hooks\npre-commit install\n```\n\n### Testing\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=src --cov-report=html\n\n# Run specific test\npytest tests/unit/test_logging.py\n```\n\n### Code Quality\n\n```bash\n# Format code\nblack src/ tests/\n\n# Check imports\nisort src/ tests/\n\n# Lint\nflake8 src/ tests/\n\n# Type check\nmypy src/\n```\n\n## Architecture\n\n```\nkrl-core/\n\u251c\u2500\u2500 logging/       # Structured logging with JSON formatting\n\u251c\u2500\u2500 config/        # Configuration management (env vars, YAML)\n\u251c\u2500\u2500 cache/         # File and Redis caching with TTL\n\u251c\u2500\u2500 api/           # Base HTTP client with retry/rate limiting\n\u2514\u2500\u2500 utils/         # Common utilities (dates, validators, decorators)\n```\n\n## Dependencies\n\n**Core Dependencies:**\n- Python 3.9+\n- `pyyaml` - Configuration file parsing\n- `python-json-logger` - Structured JSON logging\n- `requests` - HTTP client\n- `redis` (optional) - Redis caching support\n\n**Development Dependencies:**\n- `pytest` - Testing framework\n- `pytest-cov` - Coverage reporting\n- `black` - Code formatting\n- `flake8` - Linting\n- `mypy` - Type checking\n- `isort` - Import sorting\n\n## Related Packages\n\n`krl-core` is the foundation for these KRL packages:\n\n- [krl-data-connectors](https://github.com/KR-Labs/krl-data-connectors) - 40+ data source connectors\n- [krl-model-zoo](https://github.com/KR-Labs/krl-model-zoo) - 100+ analytical models\n- [krl-dashboard](https://github.com/KR-Labs/krl-dashboard) - Interactive dashboards\n- [krl-causal-policy-toolkit](https://github.com/KR-Labs/krl-causal-policy-toolkit) - Causal inference tools\n- [krl-network-analysis](https://github.com/KR-Labs/krl-network-analysis) - Network analytics\n- [krl-geospatial-tools](https://github.com/KR-Labs/krl-geospatial-tools) - GIS tools\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n### Contributor License Agreement\n\nBefore we can accept your contributions, you'll need to sign our CLA:\n- [Individual CLA](https://github.com/KR-Labs/.github/blob/main/CLA/INDIVIDUAL_CLA.md)\n- [Corporate CLA](https://github.com/KR-Labs/.github/blob/main/CLA/CORPORATE_CLA.md)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n- \ud83d\udce7 Email: support@krlabs.dev\n- \ud83d\udcac GitHub Issues: [Report a bug](https://github.com/KR-Labs/krl-open-core/issues/new?template=bug_report.md)\n- \ud83d\udcd6 Documentation: [krl-core.readthedocs.io](https://krl-core.readthedocs.io)\n- \ud83c\udf10 Website: [krlabs.dev](https://krlabs.dev)\n\n## Citation\n\nIf you use KRL Core in your research, please cite:\n\n```bibtex\n@software{krl_core_2025,\n  title = {KRL Core: Shared Utilities for KR-Labs Analytics Platform},\n  author = {{KR-Labs Foundation}},\n  year = {2025},\n  url = {https://github.com/KR-Labs/krl-open-core},\n  license = {MIT}\n}\n```\n\n---\n\n**KRL\u2122** is a trademark of KR-Labs Foundation.  \nCopyright \u00a9 2025 KR-Labs Foundation. All rights reserved.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Shared foundation utilities for the KR-Labs analytics platform",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/KR-Labs/krl-open-core/issues",
        "Changelog": "https://github.com/KR-Labs/krl-open-core/blob/main/CHANGELOG.md",
        "Documentation": "https://krl-core.readthedocs.io",
        "Homepage": "https://krlabs.dev",
        "Repository": "https://github.com/KR-Labs/krl-open-core"
    },
    "split_keywords": [
        "krl",
        " utilities",
        " logging",
        " configuration",
        " caching",
        " api-client"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e5f2cfbff06115898f9ec29b5df3139d880059502eccf21ba0ccbc92e02eea7b",
                "md5": "4cc4b2f3e35a08969e2df5c2bf4629f8",
                "sha256": "18ff100ab3eaa7537b425abbac367aa7281fbaa2b40550a7cddce1772b0a236f"
            },
            "downloads": -1,
            "filename": "krl_core-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4cc4b2f3e35a08969e2df5c2bf4629f8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 21354,
            "upload_time": "2025-10-20T02:16:43",
            "upload_time_iso_8601": "2025-10-20T02:16:43.502193Z",
            "url": "https://files.pythonhosted.org/packages/e5/f2/cfbff06115898f9ec29b5df3139d880059502eccf21ba0ccbc92e02eea7b/krl_core-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "07e5e1928440aa32f2c0149050f8af46f2f1d3806cb1e99a4158983fb3c7512f",
                "md5": "4b21653d2cf8625a154fc8dc0f21c8ec",
                "sha256": "0645a2cbea18c118e3c8cf81e08100198ea9abe2e4ec65d2bf12e0d71d810056"
            },
            "downloads": -1,
            "filename": "krl_core-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4b21653d2cf8625a154fc8dc0f21c8ec",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 18351,
            "upload_time": "2025-10-20T02:16:44",
            "upload_time_iso_8601": "2025-10-20T02:16:44.661142Z",
            "url": "https://files.pythonhosted.org/packages/07/e5/e1928440aa32f2c0149050f8af46f2f1d3806cb1e99a4158983fb3c7512f/krl_core-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-20 02:16:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "KR-Labs",
    "github_project": "krl-open-core",
    "github_not_found": true,
    "lcname": "krl-core"
}
        
Elapsed time: 0.60183s