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

Suppress verbose pip install #897

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
11 changes: 6 additions & 5 deletions guardrails/cli/hub/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ def install(
"--install-local-models/--no-install-local-models",
help="Install local models",
),
quiet: bool = typer.Option(
verbose: bool = typer.Option(
False,
"-q",
"--quiet",
help="Run the command in quiet mode to reduce output verbosity.",
"-v",
"--verbose",
help="Run the command in verbose mode to increase output verbosity.",
),
):
try:
Expand All @@ -211,10 +211,11 @@ def confirm():
" local models for local inference?",
)

is_quiet = not verbose
install(
package_uri,
install_local_models=local_models,
quiet=quiet,
quiet=is_quiet,
install_local_models_confirm=confirm,
)
except Exception as e:
Expand Down
12 changes: 6 additions & 6 deletions tests/unit_tests/cli/hub/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_install_local_models__false(self, mocker):
mock_install.assert_called_once_with(
"hub://guardrails/test-validator",
install_local_models=False,
quiet=False,
quiet=True,
install_local_models_confirm=ANY,
)

Expand All @@ -46,7 +46,7 @@ def test_install_local_models__true(self, mocker):
mock_install.assert_called_once_with(
"hub://guardrails/test-validator",
install_local_models=True,
quiet=False,
quiet=True,
install_local_models_confirm=ANY,
)

Expand All @@ -62,23 +62,23 @@ def test_install_local_models__none(self, mocker):
mock_install.assert_called_once_with(
"hub://guardrails/test-validator",
install_local_models=None,
quiet=False,
quiet=True,
install_local_models_confirm=ANY,
)

assert result.exit_code == 0

def test_install_quiet(self, mocker):
def test_install_verbose(self, mocker):
mock_install = mocker.patch("guardrails.hub.install.install")
runner = CliRunner()
result = runner.invoke(
hub_command, ["install", "hub://guardrails/test-validator", "--quiet"]
hub_command, ["install", "hub://guardrails/test-validator", "--verbose"]
)

mock_install.assert_called_once_with(
"hub://guardrails/test-validator",
install_local_models=None,
quiet=True,
quiet=False,
install_local_models_confirm=ANY,
)

Expand Down
Loading