From f29f4abdd7ea4d3b4afeb8e1b403360ad7309ace Mon Sep 17 00:00:00 2001 From: Vini Brasil Date: Fri, 25 Oct 2024 11:20:41 -0300 Subject: [PATCH] Forward install command options to `uv sync` (#1510) Allow passing additional options from `crewai install` directly to `uv sync`. This enables commands like `crewai install --locked` to work as expected by forwarding all flags and options to the underlying uv command. --- src/crewai/cli/cli.py | 10 +++++++--- src/crewai/cli/install_crew.py | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/crewai/cli/cli.py b/src/crewai/cli/cli.py index 460128634..1ea2ef4e2 100644 --- a/src/crewai/cli/cli.py +++ b/src/crewai/cli/cli.py @@ -178,10 +178,14 @@ def test(n_iterations: int, model: str): evaluate_crew(n_iterations, model) -@crewai.command() -def install(): +@crewai.command(context_settings=dict( + ignore_unknown_options=True, + allow_extra_args=True, +)) +@click.pass_context +def install(context): """Install the Crew.""" - install_crew() + install_crew(context.args) @crewai.command() diff --git a/src/crewai/cli/install_crew.py b/src/crewai/cli/install_crew.py index 35206e5eb..d1d0ab9da 100644 --- a/src/crewai/cli/install_crew.py +++ b/src/crewai/cli/install_crew.py @@ -3,12 +3,13 @@ import subprocess import click -def install_crew() -> None: +def install_crew(proxy_options: list[str]) -> None: """ Install the crew by running the UV command to lock and install. """ try: - subprocess.run(["uv", "sync"], check=True, capture_output=False, text=True) + command = ["uv", "sync"] + proxy_options + subprocess.run(command, check=True, capture_output=False, text=True) except subprocess.CalledProcessError as e: click.echo(f"An error occurred while running the crew: {e}", err=True)