namespace.py engine.py cached.py lyth.py
register_cached_callable(
ns, db_path, gref, nsref,
min_ttl=0.5, max_ttl=2.0
)
db_path at definition time_setup_file_logging(storage.log_file)
# hardcoded DEBUG level
# no per-category control
# only triggered by CLI start
lyth start# 1. Define (declarative, no storage needed)
ns = Namespace.from_dict(config)
# 2. Mount (activates persistence + logging)
ns.mount(storage)
register_cached_callable removed entirely@mountable # benefits from mount (DAGs get real provenance)
@mount_required # needs mount (cache nodes fail without DB)
ns.is_mounted # True after mount() called
ns.requires_mount # True if cache config, triggers, or @mount_required
ns.has_mountable # True if DAGs or @mountable present
Detection logic checks:
NsCacheConfig → requires mount@mount_required callable → requires mount@mountable callable → has mountablenamespace:
- nsref: "market:fetch_prices"
gref: "myapp:fetch_prices"
type: cache
min_ttl: 0.5
max_ttl: 2.0
from_dict dispatches on type field via _CONFIG_TYPES dict
storage:
cache_db: cache.db
dag_db: dags.db
log_file: lyth.log
log_level: INFO
loggers:
lythonic.compose.cached: DEBUG
lythonic.compose.dag_runner: WARNING
LogConfig.setup_logging()class LogConfig(BaseModel):
log_file: Path | None = None
log_level: str = "DEBUG"
loggers: dict[str, str] = {}
def setup_logging(self) -> None: ...
class StorageConfig(LogConfig):
cache_db: Path | None = None
dag_db: Path | None = None
trigger_db: Path | None = None
Logging lives on LogConfig — usable independently of mount:
LogConfig(...).setup_logging() works standalonemount() calls storage.setup_logging() (inherited)FileHandler with NodeRunLogFilter (adds run_id, node_label)# Imperative, 6 calls to register
register_cached_callable(ns, db, ...)
register_cached_callable(ns, db, ...)
_setup_file_logging(storage.log_file)
ns = Namespace.from_dict(
[e.model_dump() for e in cfg.namespace]
)
ns.mount(cfg.storage)
Two lines. All persistence wiring happens inside mount().
mount()requires_mount / has_mountable introspection for toolingLogConfig.setup_logging() — standalone or via mount()register_cached_callable, _setup_file_logging