Skip to content

Clean old tasks

A cleanup task for removing past runs.

remove_old_cleanup_tasks()

Find and remove runs of old cleanup tasks.

Source code in gso/workflows/tasks/clean_old_tasks.py
@step("Remove old cleanup tasks")
def remove_old_cleanup_tasks() -> None:
    """Find and remove runs of old cleanup tasks."""
    cleanup_tasks = get_all_cleanup_tasks()

    for cleanup_task in cleanup_tasks:
        tasks = get_created_and_completed_processes_by_id(cleanup_task.workflow_id)

        for task in tasks:
            db.session.delete(task)

task_clean_old_tasks()

Remove all runs of old cleanup tasks.

This will look for all past executions of the orchestrator-core built-in cleanup task, and this current cleanup task. Once they have run to completion, or are stuck in a "created" state, they serve no purpose in the database and can therefore be removed.

Source code in gso/workflows/tasks/clean_old_tasks.py
@workflow("Remove old cleanup tasks", target=Target.SYSTEM)
def task_clean_old_tasks() -> StepList:
    """Remove all runs of old cleanup tasks.

    This will look for all past executions of the ``orchestrator-core`` built-in cleanup task, and this current cleanup
    task. Once they have run to completion, or are stuck in a "created" state, they serve no purpose in the database and
    can therefore be removed.
    """
    return begin >> remove_old_cleanup_tasks >> done