Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions guardrails/cli/hub/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
from guardrails.cli.version import version_warnings_if_applicable


@hub_command.command()
# Quick note: This is the command for `guardrails hub install`. We change the name of
# the function def to prevent confusion, lest people import it directly and calling it
# with a string for package_uris instead of a list, which behaves oddly. If you need to
# call install from a script, please consider importing install from guardrails,
# not guardrails.cli.hub.install.
@hub_command.command(name="install")
@trace(name="guardrails-cli/hub/install")
def install(
def install_cli(
package_uris: List[str] = typer.Argument(
...,
help="URIs to the packages to install. Example: hub://guardrails/regex_match hub://guardrails/toxic_language",
Expand All @@ -33,6 +38,17 @@ def install(
),
):
try:
if isinstance(package_uris, str):
logger.error(
f"`install` in {__file__} was called with a string instead of "
"a list! This can happen if it is invoked directly instead of "
"being run via the CLI. Did you mean to import `from guardrails import "
"install` instead? Recovering..."
)
package_uris = [
package_uris,
]

from guardrails.hub.install import install_multiple

def confirm():
Expand Down
2 changes: 1 addition & 1 deletion guardrails/hub/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def install(
Examples:
>>> RegexMatch = install("hub://guardrails/regex_match").RegexMatch

>>> install("hub://guardrails/regex_match);
>>> install("hub://guardrails/regex_match")
>>> import guardrails.hub.regex_match as regex_match
"""

Expand Down
Loading