Skip to main content

SAGE Core Common Utilities

Project description

SAGE Common

Core utilities and shared components for the SAGE framework

Python Version License

๐Ÿ“‹ Overview

SAGE Common provides essential shared utilities and components used across all SAGE packages. This is the foundation layer that provides:

  • Configuration management for YAML/TOML files
  • Logging framework with custom formatters and handlers
  • Network utilities for TCP/UDP communication
  • Serialization tools with dill and pickle support
  • System utilities for environment and process management
  • Embedding services (sage_embedding, sage_llm)

This package ensures consistency and reduces code duplication across the SAGE ecosystem.

โœจ Key Features

  • Unified Configuration: YAML/TOML configuration loading and validation
  • Advanced Logging: Colored output, structured logging, and custom formatters
  • Network Utilities: TCP client/server, network helpers
  • Flexible Serialization: Multiple backends (dill, pickle, JSON)
  • System Management: Environment detection, process control
  • LLM Integration: Embedding and VLLM services

Core Modules

  • utils.config: Configuration management utilities
  • utils.logging: Logging framework and formatters
  • utils.network: Network utilities and TCP clients/servers
  • utils.serialization: Serialization utilities including dill support
  • utils.system: System utilities for environment and process management
  • _version: Version management

๐Ÿ“ฆ Package Structure

sage-common/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ sage/
โ”‚       โ””โ”€โ”€ common/
โ”‚           โ”œโ”€โ”€ __init__.py
โ”‚           โ”œโ”€โ”€ _version.py
โ”‚           โ”œโ”€โ”€ utils/                  # Core utilities
โ”‚           โ”‚   โ”œโ”€โ”€ config/            # Configuration management
โ”‚           โ”‚   โ”œโ”€โ”€ logging/           # Logging framework
โ”‚           โ”‚   โ”œโ”€โ”€ network/           # Network utilities
โ”‚           โ”‚   โ”œโ”€โ”€ serialization/     # Serialization tools
โ”‚           โ”‚   โ””โ”€โ”€ system/            # System utilities
โ”‚           โ””โ”€โ”€ components/            # Shared components
โ”‚               โ”œโ”€โ”€ sage_embedding/    # Embedding service
โ”‚               โ””โ”€โ”€ sage_llm/         # VLLM service
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ README.md

๐Ÿš€ Installation

Basic Installation

pip install sage-common

Development Installation

cd packages/sage-common
pip install -e .

With Optional Dependencies

# With embedding support
pip install sage-common[embedding]

# With VLLM support
pip install sage-common[vllm]

# Full installation
pip install sage-common[all]

๐Ÿ“– Quick Start

Configuration Management

from sage.common.utils.config.loader import ConfigLoader

# Load configuration
config = ConfigLoader("config.yaml")

# Access configuration
model_name = config.get("model.name", default="default-model")

Logging

from sage.common.utils.logging.custom_logger import get_logger

# Get logger
logger = get_logger(__name__)

# Use logger
logger.info("Application started")
logger.debug("Debug information")
logger.error("Error occurred", exc_info=True)

Network Utilities

from sage.common.utils.network import TCPClient, TCPServer

# Create TCP server
server = TCPServer(host="localhost", port=8080)
server.start()

# Create TCP client
client = TCPClient(host="localhost", port=8080)
client.connect()
client.send(b"Hello, Server!")

Serialization

from sage.common.utils.serialization import serialize, deserialize

# Serialize data
data = {"key": "value", "numbers": [1, 2, 3]}
serialized = serialize(data, format="dill")

# Deserialize data
restored = deserialize(serialized, format="dill")

๐Ÿ”ง Configuration

Configuration files are typically in YAML or TOML format:

# config.yaml
logging:
  level: INFO
  format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"

network:
  host: localhost
  port: 8080
  timeout: 30

embedding:
  model: sentence-transformers/all-MiniLM-L6-v2
  device: cuda

๐Ÿงช Testing

# Run unit tests
pytest tests/unit

# Run integration tests
pytest tests/integration

# Run with coverage
pytest --cov=sage.common --cov-report=html

๐Ÿ“š Documentation

  • User Guide: See docs-public
  • API Reference: See package docstrings and type hints
  • Examples: See examples/ directory in each module

๐Ÿค Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

๐Ÿ“„ License

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

๐Ÿ”— Related Packages

  • sage-kernel: Uses common utilities for runtime management
  • sage-libs: Builds on common components for libraries
  • sage-middleware: Uses network and serialization utilities
  • sage-tools: Uses configuration and logging utilities

๐Ÿ“ฎ Support


Part of the SAGE Framework | Main Repository

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

isage_common-0.2.3-py3-none-any.whl (580.6 kB view details)

Uploaded Python 3

File details

Details for the file isage_common-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: isage_common-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 580.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for isage_common-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 053f31cbc7b0c99a677a6fcfdc2d985f94eace7d399e9d901e25122151e62a29
MD5 83879ada27877f01ef1e3d08999addf5
BLAKE2b-256 9861e1d892af0dad75f4ecc50b24dd7af7537680e2cddf28949c78fb095f0265

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