mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-06 22:58:30 +00:00
created cli command for listing completed tasks ids
This commit is contained in:
@@ -5,6 +5,7 @@ import pkg_resources
|
||||
from .create_crew import create_crew
|
||||
from .train_crew import train_crew
|
||||
from .replay_from_task import replay_task_command
|
||||
from .list_task_outputs import show_task_outputs
|
||||
|
||||
|
||||
@click.group()
|
||||
@@ -71,5 +72,11 @@ def replay(task_id: str) -> None:
|
||||
click.echo(f"An error occurred while replaying: {e}", err=True)
|
||||
|
||||
|
||||
@crewai.command()
|
||||
def list_completed_tasks_ids():
|
||||
"""List all task outputs saved from crew_tasks_output.json."""
|
||||
show_task_outputs()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
crewai()
|
||||
|
||||
34
src/crewai/cli/list_task_outputs.py
Normal file
34
src/crewai/cli/list_task_outputs.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import subprocess
|
||||
import click
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
|
||||
def show_task_outputs() -> None:
|
||||
"""
|
||||
Replay the crew execution from a specific task.
|
||||
|
||||
Args:
|
||||
task_id (str): The ID of the task to replay from.
|
||||
"""
|
||||
|
||||
try:
|
||||
file_path = Path("crew_tasks_output.json")
|
||||
if not file_path.exists():
|
||||
click.echo("crew_tasks_output.json not found.")
|
||||
return
|
||||
|
||||
with open(file_path, "r") as f:
|
||||
tasks = json.load(f)
|
||||
|
||||
for index, task in enumerate(tasks):
|
||||
click.echo(f"Task {index}: {task['task_id']}")
|
||||
click.echo(f"Description: {task['output']['description']}")
|
||||
click.echo("---")
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
click.echo(f"An error occurred while replaying the task: {e}", err=True)
|
||||
click.echo(e.output, err=True)
|
||||
|
||||
except Exception as e:
|
||||
click.echo(f"An unexpected error occurred: {e}", err=True)
|
||||
Reference in New Issue
Block a user