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.

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.0a3.tar.gz (225.7 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.0a3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uv_guard-0.1.0a3.tar.gz
  • Upload date:
  • Size: 225.7 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.0a3.tar.gz
Algorithm Hash digest
SHA256 92c09ad540f2c725663e6ca2f51230c996b29ca36d54da87f5f01e309d2d78a1
MD5 d3e967ca8bd2cf56bd2b7bc261564a4c
BLAKE2b-256 8c1b697e9d00f9ffd376618fc9cc2c8c6a8af87aa73cd0e56229318374519a1d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: uv_guard-0.1.0a3-py3-none-any.whl
  • Upload date:
  • Size: 10.1 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.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a6185c1000c6225746ebf9fee1a2404650ed8faf626060f93f6fc988b2e2cf1
MD5 45cf74f137da0e60190ec89653b635aa
BLAKE2b-256 3fe61884b7cae539d6ad9ff89e09ebf32740bc8b2a8d682947d6f4175ccba1d2

See more details on using hashes here.

Provenance

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