mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 17:18:29 +00:00
* feat: Start migrating to UV * feat: add uv to flows * feat: update docs on Poetry -> uv * feat: update docs and uv.locl * feat: update tests and github CI * feat: run ruff format * feat: update typechecking * feat: fix type checking * feat: update python version * feat: type checking gic * feat: adapt uv command to run the tool repo * Adapt tool build command to uv * feat: update logic to let only projects with crew to be deployed * feat: add uv to tools * fix; tests * fix: remove breakpoint * fix :test * feat: add crewai update to migrate from poetry to uv * fix: tests * feat: add validation for ˆ character on pyproject * feat: add run_crew to pyproject if doesnt exist * feat: add validation for poetry migration * fix: warning --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
33 lines
980 B
Python
33 lines
980 B
Python
import subprocess
|
|
|
|
import click
|
|
|
|
|
|
def train_crew(n_iterations: int, filename: str) -> None:
|
|
"""
|
|
Train the crew by running a command in the UV environment.
|
|
|
|
Args:
|
|
n_iterations (int): The number of iterations to train the crew.
|
|
"""
|
|
command = ["uv", "run", "train", str(n_iterations), filename]
|
|
|
|
try:
|
|
if n_iterations <= 0:
|
|
raise ValueError("The number of iterations must be a positive integer.")
|
|
|
|
if not filename.endswith(".pkl"):
|
|
raise ValueError("The filename must not end with .pkl")
|
|
|
|
result = subprocess.run(command, capture_output=False, text=True, check=True)
|
|
|
|
if result.stderr:
|
|
click.echo(result.stderr, err=True)
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
click.echo(f"An error occurred while training 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)
|