Skip to content

Commit 05c2a02

Browse files
committed
Change show-schedule command to table, add schedule name and derive source
1 parent db068cd commit 05c2a02

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

orchestrator/cli/scheduler.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,30 @@ def show_schedule() -> None:
6767
6868
in cli underscore is replaced by a dash `show-schedule`
6969
"""
70-
for task in get_all_scheduler_tasks():
71-
typer.echo(f"[{task.id}] Next run: {task.next_run_time} | Trigger: {task.trigger}")
70+
from rich.console import Console
71+
from rich.table import Table
72+
73+
from orchestrator.schedules.service import get_linker_entries_by_schedule_ids
74+
75+
console = Console()
76+
77+
table = Table(title="Scheduled Tasks")
78+
table.add_column("id", no_wrap=True)
79+
table.add_column("name")
80+
table.add_column("source")
81+
table.add_column("next run time")
82+
table.add_column("trigger")
83+
84+
scheduled_tasks = get_all_scheduler_tasks()
85+
_schedule_ids = [task.id for task in scheduled_tasks]
86+
api_managed = {str(i.schedule_id) for i in get_linker_entries_by_schedule_ids(_schedule_ids)}
87+
88+
for task in scheduled_tasks:
89+
source = "API" if task.id in api_managed else "decorator"
90+
run_time = str(task.next_run_time.replace(microsecond=0))
91+
table.add_row(task.id, task.name, source, str(run_time), str(task.trigger))
92+
93+
console.print(table)
7294

7395

7496
@app.command()

0 commit comments

Comments
 (0)