-
Notifications
You must be signed in to change notification settings - Fork 544
Open
Description
Context
Discussion #1412 and PR #1394 (shipped in v0.9.1) introduced the project-level
.guardrails/hub_registry.json registry. Currently guardrails hub install dual-writes:
it appends an import line to hub/__init__.py in site-packages AND writes to the JSON
registry.
The __init__.py mutation approach is fragile: it breaks on virtualenv changes, pip
upgrades, and concurrent installs. The registry was built to replace it.
@CalebCourier noted on Discussion #1412 (Mar 2): "If you have the bandwidth to open a
PR for Phase 2 it would be much appreciated."
Proposed Changes
- Replace
guardrails/hub/__init__.pybarrel imports with PEP 562__getattr__that
reads fromhub_registry.json, caches the export map, and resolves validators lazily - Remove the
add_to_hub_inits()call from the install path (registry becomes sole
source of truth) - Add
unregister_validator()for clean removal on uninstall - Rewrite
guardrails hub listto read from registry instead of regex-parsing
__init__.py
Backward Compatibility
from guardrails.hub import DetectPIIworks identically via__getattr__- Existing registry entries from v0.9.1 installs are used as-is
add_to_hub_inits()andremove_from_hub_inits()stay in the codebase but are no
longer called- No migration command needed: reinstalling validators auto-populates the registry
Related
- Discussion Guardrails Hub CLI: uv support + other qol improvements #1412
- PR docs: Add MLflow integration guide #1394 (Phase 1)
- PR Add uv package manager support and project-level validator registry #1416 (Phase 1 follow-up)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels