/
githubmirror
/
crewai
Обзор
Документация
Войти
/
githubmirror
/
crewai
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
lib/cli/src/crewai_cli/train_crew.py
32 строки
994 B
Greyson LaLonde
refactor: extract CLI into standalone crewai-cli package
06 май 2026, 15:46
Не верифицирован
06 май 2026, 15:46
93e786d
Код
Авторство
О чём код?
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) # noqa: S603 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)