Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: create command #876

Merged
merged 6 commits into from
Jul 1, 2024
Merged

Feature: create command #876

merged 6 commits into from
Jul 1, 2024

Conversation

JosephCatrambone
Copy link
Contributor

@JosephCatrambone JosephCatrambone commented Jul 1, 2024

Adds a command to create the guardrails config file.

Per specification:

  • Defaults to config.py and will prompt on overwrite.
  • Fills installed guards with TODO for parameters and notifies user.

Departures from specification:

  • It was nice to have --dry-run as an option to see what would be created and written. This will not save a config file but will sanity check that the validators exist and will print the config file to the console.

Examples:

Simple Happy Path:

% guardrails create --validators hub:https://guardrails/valid_length,hub:https://guardrails/lowercase
Checking validators...
Success!
Installing...
Success!
Generating config file...
Saved configuration to config.py
Replace TODOs in config.py and run with `guardrails start --config config.py`

% cat config.py
from guardrails import Guard
from guardrails.hub import (
        ValidLength,
        LowerCase
)
guard = Guard()
guard.use_many(
        ValidLength( TODO Fill these parameters ),
        LowerCase( TODO Fill these parameters )
)

Dry Run:

% guardrails create --validators hub:https://guardrails/detect_pii --dry-run
Checking validators...
Success!
Installing...
Fake installing guardrails/detect_pii
Success!
Generating config file...
Not actually saving output to config.py
The following would have been written:

from guardrails import Guard
from guardrails.hub import DetectPII
guard = Guard()
guard.use(DetectPII( TODO Fill these parameters ))

@JosephCatrambone JosephCatrambone marked this pull request as ready for review July 1, 2024 22:10
@zsimjee
Copy link
Collaborator

zsimjee commented Jul 1, 2024

As per convo, we'll remove auto-incrementation of config-x.py as a filename. Instead, prompt to overwrite

@zsimjee zsimjee merged commit 5a12ecd into 0.5.0-dev Jul 1, 2024
12 checks passed
@zsimjee zsimjee deleted the jc/feat-create-command branch July 1, 2024 23:39
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.

2 participants