print run time

This commit is contained in:
hjlarry 2025-12-17 10:10:40 +08:00
parent 774286797d
commit b819552a7c
2 changed files with 26 additions and 3 deletions

View File

@ -887,7 +887,10 @@ def clean_workflow_runs(
if (start_after is None) ^ (end_before is None):
raise click.UsageError("--start-after and --end-before must be provided together.")
click.echo(click.style("Starting workflow run cleanup.", fg="white"))
start_time = datetime.datetime.now(datetime.UTC)
click.echo(
click.style(f"Starting workflow run cleanup at {start_time.isoformat()}.", fg="white")
)
WorkflowRunCleanup(
days=days,
@ -897,7 +900,15 @@ def clean_workflow_runs(
dry_run=dry_run,
).run()
click.echo(click.style("Workflow run cleanup completed.", fg="green"))
end_time = datetime.datetime.now(datetime.UTC)
elapsed = end_time - start_time
click.echo(
click.style(
f"Workflow run cleanup completed. start={start_time.isoformat()} "
f"end={end_time.isoformat()} duration={elapsed}",
fg="green",
)
)
@click.option("-f", "--force", is_flag=True, help="Skip user confirmation and force the command to execute.")

View File

@ -1,3 +1,5 @@
from datetime import UTC, datetime
import click
import app
@ -18,6 +20,8 @@ def clean_workflow_runs_task() -> None:
)
)
start_time = datetime.now(UTC)
WorkflowRunCleanup(
days=dify_config.WORKFLOW_LOG_RETENTION_DAYS,
batch_size=dify_config.WORKFLOW_LOG_CLEANUP_BATCH_SIZE,
@ -25,4 +29,12 @@ def clean_workflow_runs_task() -> None:
end_before=None,
).run()
click.echo(click.style("Scheduled workflow run cleanup finished.", fg="green"))
end_time = datetime.now(UTC)
elapsed = end_time - start_time
click.echo(
click.style(
f"Scheduled workflow run cleanup finished. start={start_time.isoformat()} "
f"end={end_time.isoformat()} duration={elapsed}",
fg="green",
)
)