From 3e9cffe740cd830bd48c6a4ef62dfb55ab4b9919 Mon Sep 17 00:00:00 2001 From: Eduardo Chiarotti Date: Fri, 16 Aug 2024 22:05:01 -0300 Subject: [PATCH] feat: Add crewai install CLI command --- src/crewai/cli/cli.py | 11 +++++++++-- src/crewai/cli/install_crew.py | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/crewai/cli/install_crew.py diff --git a/src/crewai/cli/cli.py b/src/crewai/cli/cli.py index bc6d5c21d..2ca400000 100644 --- a/src/crewai/cli/cli.py +++ b/src/crewai/cli/cli.py @@ -8,6 +8,7 @@ from crewai.memory.storage.kickoff_task_outputs_storage import ( ) from .evaluate_crew import evaluate_crew +from .install_crew import install_crew from .replay_from_task import replay_task_command from .reset_memories_command import reset_memories_command from .run_crew import run_crew @@ -165,10 +166,16 @@ def test(n_iterations: int, model: str): evaluate_crew(n_iterations, model) +@crewai.command() +def install(): + """Install the Crew.""" + install_crew() + + @crewai.command() def run(): - """Run the crew.""" - click.echo("Running the crew") + """Run the Crew.""" + click.echo("Running the Crew") run_crew() diff --git a/src/crewai/cli/install_crew.py b/src/crewai/cli/install_crew.py new file mode 100644 index 000000000..bbafdad6f --- /dev/null +++ b/src/crewai/cli/install_crew.py @@ -0,0 +1,21 @@ +import subprocess + +import click + + +def install_crew() -> None: + """ + Install the crew by running the Poetry command to lock and install. + """ + try: + subprocess.run(["poetry", "lock"], check=True, capture_output=False, text=True) + subprocess.run( + ["poetry", "install"], 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) + click.echo(e.output, err=True) + + except Exception as e: + click.echo(f"An unexpected error occurred: {e}", err=True)