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.
def__getattr__(name:str)->Any:# pragma: no cover - exercised via tests"""Dynamically resolve attributes from submodules on first access."""ifnamein_LAZY_MODULES:module=_load_module(_LAZY_MODULES[name])ifmoduleisNone:raiseAttributeError(f"Module {_LAZY_MODULES[name]!r} cannot be imported")globals()[name]=modulereturnmoduleformodule_namein_MODULE_SEARCH_ORDER:module=_load_module(module_name)ifmoduleisNone:continueifhasattr(module,name):value=getattr(module,name)globals()[name]=valuereturnvalueraiseAttributeError(f"module 'ezpz' has no attribute {name!r}")
importezpz# Get process informationrank=ezpz.get_rank()world_size=ezpz.get_world_size()# Get device informationdevice=ezpz.get_torch_device()device_type=ezpz.get_torch_device_type()
importezpz# Get a logger with proper configurationlogger=ezpz.get_logger("my_module")# Log messages with different levelslogger.debug("Debug message")logger.info("Info message")logger.warning("Warning message")logger.error("Error message")
importezpz# Create a history trackerhistory=ezpz.History()# Add metricsmetrics={"loss":0.5,"accuracy":0.8}summary=history.update(metrics)print(summary)# Formatted summary string