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.

Configure Guardrail AI

Configure Guardrails AI. You can get your API key from the Guardrails Hub website.

Guardrails has to be configured to add Guardrails validators from the Hub.

uv-guard configure

Passes all arguments and options to guardrails configure.

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 arguments and options 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 arguments and options 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 arguments and options to uv sync.

Other uv Commands

All other uv commands are explicitly forwarded to the underlying uv executable. This allows you to use uv-guard as a drop-in replacement for uv in your daily workflow.

Examples:

# Update the lockfile
uv-guard lock

# View the dependency tree
uv-guard tree

# Manage python versions
uv-guard python install 3.12

Supported commands include: auth, lock, export, tree, format, tool, python, pip, venv, build, publish, cache, and self.

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.1.tar.gz (228.8 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.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file uv_guard-0.1.1.tar.gz.

File metadata

  • Download URL: uv_guard-0.1.1.tar.gz
  • Upload date:
  • Size: 228.8 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.1.tar.gz
Algorithm Hash digest
SHA256 df98f62a799a8db46041bf8ac09774b8f235cccc4a7a9e1c664031d8e0e94e12
MD5 cd6aa8e273854e7c85097a69d6f81508
BLAKE2b-256 27ebeb2598e5273cfb2dc92e060d18be46c71a06d4d84a26c9ca79e631435900

See more details on using hashes here.

Provenance

The following attestation bundles were made for uv_guard-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: uv_guard-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5fa78cdf5e27779c3e51991d05090e0678ee88b85ad0eddd03808f852bcc532
MD5 60585169739f908cfb339850da12ed79
BLAKE2b-256 31c028d137fa273964d4267e090ff90d581d1b358782a846e07d070329ab9f84

See more details on using hashes here.

Provenance

The following attestation bundles were made for uv_guard-0.1.1-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