Skip to content

Migrate to Dynamic Hub Imports#1434

Draft
CalebCourier wants to merge 8 commits intomainfrom
hub-import-tlc
Draft

Migrate to Dynamic Hub Imports#1434
CalebCourier wants to merge 8 commits intomainfrom
hub-import-tlc

Conversation

@CalebCourier
Copy link
Collaborator

@CalebCourier CalebCourier commented Mar 12, 2026

Includes

Checks

NOTE

In order for Server CI to pass we need the following fixes released: guardrails-ai/guardrails-api#105

These fixes are unrelated to this PR, but are blocking successful sync chat completions in the tests.

debu-sinha and others added 4 commits March 3, 2026 17:34
Phase 2 of the hub registry migration. Validators registered in
.guardrails/hub_registry.json are now resolved lazily via PEP 562
__getattr__ on first attribute access and cached for subsequent imports.

Changes:
- guardrails/hub/__init__.py: Replace barrel imports with __getattr__,
  __dir__, and cached export map built from hub_registry.json
- guardrails/hub/install.py: Remove add_to_hub_inits call (registry
  is now the sole source of truth)
- guardrails/hub/validator_package_service.py: Add unregister_validator
  to remove entries from the registry on uninstall
- guardrails/cli/hub/uninstall.py: Use unregister_validator instead of
  remove_from_hub_inits
- guardrails/cli/hub/list.py: Read from registry JSON instead of
  parsing hub/__init__.py with regex

Tested with 99 passing tests covering happy path, edge cases (corrupt
registry, missing exports, name collisions, missing modules), caching,
and full install/uninstall/list CLI regression.

Signed-off-by: debu-sinha <debusinha2009@gmail.com>
Replace barrel imports with dynamic registry-based loading (Phase 2)
@vercel
Copy link

vercel bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
guardrails Ready Ready Preview, Comment Mar 13, 2026 10:00pm

Request Review

@codecov-commenter
Copy link

codecov-commenter commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 95.61404% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
guardrails/validator_base.py 58.33% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@CalebCourier CalebCourier marked this pull request as draft March 12, 2026 20:48
@CalebCourier
Copy link
Collaborator Author

Notebooks show runtime issues with RAIL since the validators are not explicitly imported. Fix incoming

@CalebCourier
Copy link
Collaborator Author

Notebooks show runtime issues with RAIL since the validators are not explicitly imported. Fix incoming

Fix pushed, specific notebooks that were failing are now working. Need to address test failures due to code moving around.

@debu-sinha
Copy link
Contributor

Nice, glad #1422 is part of this. Let me know if anything comes up during the server CI validation or if the dynamic resolution needs tweaks for edge cases I didn't cover.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants