Skip to main content

uv-guard is a CLI tool that harmonizes the uv package manager with the Guardrails AI ecosystem.

Project description

uv-guard

uv-guard is a CLI tool that harmonizes the uv package manager with the Guardrails AI ecosystem.

While uv excels at strict environment locking, its synchronization process often identifies and removes Guardrails' static assets as extraneous files. uv-guard resolves this conflict by wrapping both tools into a unified workflow. It maintains a persistent record of installed validators, tracks their dependencies, and automatically triggers post-installation scripts whenever the environment is updated—ensuring your validation logic remains intact without manual intervention.

Configuration & Persistence

To track Guardrails Hub URIs, uv-guard extends the standard pyproject.toml configuration. When a validator is added, uv-guard creates a dedicated guardrails list within the configuration file, functioning alongside standard dependencies.

This ensures that the pyproject.toml file remains the project's source of truth, tracking both standard Python packages and Guardrails Hub URIs in one place.

Example pyproject.toml structure:

[project]
name = "my-project"
dependencies = [
    "guardrails-ai",
    "guardrails-grhub-regex-match",  # The underlying Python package resolved by uv-guard
]
# uv-guard tracks the specific Hub URIs here
guardrails = [
    "hub://guardrails/regex_match"
]

Prerequisites

Installation

You can install uv-guard using pip, pipx, or uv tool:

# Recommended: Install as a standalone tool via uv
uv tool install uv-guard

Usage

uv-guard mirrors the uv commands but extends them to support Guardrails Hub URIs (hub://).

Initialize a Project

Initializes a new uv project and automatically adds the guardrails-ai core dependency.

uv-guard init

The command passes all arguments and options to uv init. For example:

uv-guard init --name my-project

forwards the --name my-project option.

Add Dependencies

Adds a package to the project. This command intelligently handles both standard PyPI packages and Guardrails Hub URIs.

When adding a Guardrails Hub URI:

  1. It adds the URI to the guardrails list in pyproject.toml.
  2. It resolves the underlying Python package required by the validator and adds it to the standard dependencies.
  3. It executes the Guardrails post-installation script to set up the validator.
# Add a standard Python package
uv-guard add pandas

# Add a Guardrails validator
uv-guard add hub://guardrails/regex_match

Passes all standard arguments to uv add.

Remove Dependencies

Uninstall the guardrails, removes the package from the uv environment and cleans up the pyproject.toml.

uv-guard remove hub://guardrails/regex_match

Passes all standard arguments to uv remove.

Sync Environment

Updates the project environment. This is the critical operation that ensures compatibility.

When syncing, uv-guard:

  1. Reads the guardrails list from pyproject.toml.
  2. Ensures underlying Python packages are present in the uv dependency tree.
  3. Executes uv sync to update the environment.
  4. Re-runs Guardrails installation scripts to restore any assets removed during the sync process.
uv-guard sync

Passes all standard arguments to uv sync.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uv_guard-0.1.0a1.tar.gz (225.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uv_guard-0.1.0a1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file uv_guard-0.1.0a1.tar.gz.

File metadata

  • Download URL: uv_guard-0.1.0a1.tar.gz
  • Upload date:
  • Size: 225.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for uv_guard-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 e2e068c3f882eef1e715bf210bda5e815e2a52ac835453a974164ac3e2fdf7dd
MD5 0eec1e41f8fdb7d3b74a8f840f9b45ee
BLAKE2b-256 13264c2fddcaa2fbf9efed90ca80f30443031635c84fbdd5eef26a024e26a572

See more details on using hashes here.

Provenance

The following attestation bundles were made for uv_guard-0.1.0a1.tar.gz:

Publisher: cd.yml on Florian-BACHO/uv-guard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file uv_guard-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: uv_guard-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for uv_guard-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7861ac0fa53e24e4b64fc05708e2fb0e15480eeb3d8f92120994526162ebd9e
MD5 9abe518735e112bb2819a00bcc700848
BLAKE2b-256 03946f6908bbf0d3c633c5666ae0d999f73704af0b0e031eb0e2c781b86ec986

See more details on using hashes here.

Provenance

The following attestation bundles were made for uv_guard-0.1.0a1-py3-none-any.whl:

Publisher: cd.yml on Florian-BACHO/uv-guard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page