Skip to content

ezpz.__init__ยถ

Main entry point for the ezpz package.

Overviewยถ

The ezpz.__init__ module serves as the main entry point for the ezpz package, importing and exposing the most commonly used functions and classes.

Imported Modulesยถ

The module imports and re-exports functionality from several submodules:

  • ezpz.configs: Configuration management
  • ezpz.dist: Distributed computing utilities
  • ezpz.history: Training history and metrics tracking
  • ezpz.jobs: Job management utilities
  • ezpz.log: Logging utilities
  • ezpz.tp: Tensor parallel computing
  • ezpz.utils: General utility functions

Key Exportsยถ

Lightweight package initializer for ezpz.

The goal is to keep import ezpz fast and side-effect free while still exposing the familiar helpers at the package level. Submodules are imported on demand the first time one of their attributes is requested.

__getattr__(name) ยถ

Dynamically resolve attributes from submodules on first access.

Source code in src/ezpz/__init__.py
def __getattr__(name: str) -> Any:  # pragma: no cover - exercised via tests
    """Dynamically resolve attributes from submodules on first access."""

    if name in _LAZY_MODULES:
        module = _load_module(_LAZY_MODULES[name])
        if module is None:
            raise AttributeError(f"Module {_LAZY_MODULES[name]!r} cannot be imported")
        globals()[name] = module
        return module

    for module_name in _MODULE_SEARCH_ORDER:
        module = _load_module(module_name)
        if module is None:
            continue
        if hasattr(module, name):
            value = getattr(module, name)
            globals()[name] = value
            return value
    raise AttributeError(f"module 'ezpz' has no attribute {name!r}")

Usage Examplesยถ

Basic Setupยถ

1
2
3
4
5
6
7
8
import ezpz

# Initialize distributed training
ezpz.setup_torch()

# Get logger
logger = ezpz.get_logger(__name__)
logger.info("ezpz initialized successfully")

Distributed Computingยถ

1
2
3
4
5
6
7
8
9
import ezpz

# Get process information
rank = ezpz.get_rank()
world_size = ezpz.get_world_size()

# Get device information
device = ezpz.get_torch_device()
device_type = ezpz.get_torch_device_type()

Loggingยถ

import ezpz

# Get a logger with proper configuration
logger = ezpz.get_logger("my_module")

# Log messages with different levels
logger.debug("Debug message")
logger.info("Info message")
logger.warning("Warning message")
logger.error("Error message")

History Trackingยถ

1
2
3
4
5
6
7
8
9
import ezpz

# Create a history tracker
history = ezpz.History()

# Add metrics
metrics = {"loss": 0.5, "accuracy": 0.8}
summary = history.update(metrics)
print(summary)  # Formatted summary string