From 57c990c9a08385731112e5529caaa8bd81dcbd05 Mon Sep 17 00:00:00 2001 From: Kai Schlamp Date: Mon, 19 Aug 2024 18:36:01 +0000 Subject: [PATCH] Rename remove_error and include_error to remove_failed and include_failed --- docs/howto/production/delete_finished_jobs.md | 2 +- procrastinate/builtin_tasks.py | 6 +++--- procrastinate/manager.py | 6 +++--- tests/integration/test_manager.py | 8 ++++---- tests/unit/test_builtin_tasks.py | 2 +- tests/unit/test_manager.py | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/howto/production/delete_finished_jobs.md b/docs/howto/production/delete_finished_jobs.md index 14a7502a7..eadcedc17 100644 --- a/docs/howto/production/delete_finished_jobs.md +++ b/docs/howto/production/delete_finished_jobs.md @@ -87,7 +87,7 @@ async def remove_old_jobs(context, timestamp): return await builtin_tasks.remove_old_jobs( context, max_hours=72, - remove_error=True, + remove_failed=True, remove_cancelled=True, remove_aborted=True, ) diff --git a/procrastinate/builtin_tasks.py b/procrastinate/builtin_tasks.py index ca7fb3e29..358459af5 100644 --- a/procrastinate/builtin_tasks.py +++ b/procrastinate/builtin_tasks.py @@ -11,7 +11,7 @@ async def remove_old_jobs( *, max_hours: int, queue: str | None = None, - remove_error: bool | None = False, + remove_failed: bool | None = False, remove_cancelled: bool | None = False, remove_aborted: bool | None = False, ) -> None: @@ -26,7 +26,7 @@ async def remove_old_jobs( queue : The name of the queue in which jobs will be deleted. If not specified, the task will delete jobs from all queues. - remove_error: + remove_failed: By default only successful jobs will be removed. When this parameter is True failed jobs will also be deleted. remove_cancelled: @@ -39,7 +39,7 @@ async def remove_old_jobs( await context.app.job_manager.delete_old_jobs( nb_hours=max_hours, queue=queue, - include_error=remove_error, + include_failed=remove_failed, include_cancelled=remove_cancelled, include_aborted=remove_aborted, ) diff --git a/procrastinate/manager.py b/procrastinate/manager.py index d2f4db67d..7fc360d0e 100644 --- a/procrastinate/manager.py +++ b/procrastinate/manager.py @@ -177,7 +177,7 @@ async def delete_old_jobs( self, nb_hours: int, queue: str | None = None, - include_error: bool | None = False, + include_failed: bool | None = False, include_cancelled: bool | None = False, include_aborted: bool | None = False, ) -> None: @@ -192,7 +192,7 @@ async def delete_old_jobs( Consider jobs that been in a final state for more than ``nb_hours`` queue: Filter by job queue name - include_error: + include_failed: If ``True``, also consider errored jobs. ``False`` by default include_cancelled: If ``True``, also consider cancelled jobs. ``False`` by default. @@ -201,7 +201,7 @@ async def delete_old_jobs( """ # We only consider finished jobs by default statuses = [jobs.Status.SUCCEEDED.value] - if include_error: + if include_failed: statuses.append(jobs.Status.FAILED.value) if include_cancelled: statuses.append(jobs.Status.CANCELLED.value) diff --git a/tests/integration/test_manager.py b/tests/integration/test_manager.py index 48656bf32..19b07d8db 100644 --- a/tests/integration/test_manager.py +++ b/tests/integration/test_manager.py @@ -198,7 +198,7 @@ async def test_delete_old_jobs_job_doing( @pytest.mark.parametrize( - "status, nb_hours, queue, include_error, expected_job_count", + "status, nb_hours, queue, include_failed, expected_job_count", [ # nb_hours (jobs.Status.SUCCEEDED, 1, None, False, 0), @@ -208,7 +208,7 @@ async def test_delete_old_jobs_job_doing( (jobs.Status.SUCCEEDED, 3, "queue_a", False, 1), (jobs.Status.SUCCEEDED, 1, "queue_b", False, 1), (jobs.Status.SUCCEEDED, 1, "queue_b", False, 1), - # include_error + # include_failed (jobs.Status.FAILED, 1, None, False, 1), (jobs.Status.FAILED, 1, None, True, 0), ], @@ -220,7 +220,7 @@ async def test_delete_old_jobs_parameters( status, nb_hours, queue, - include_error, + include_failed, expected_job_count, fetched_job_factory, ): @@ -236,7 +236,7 @@ async def test_delete_old_jobs_parameters( ) await pg_job_manager.delete_old_jobs( - nb_hours=nb_hours, queue=queue, include_error=include_error + nb_hours=nb_hours, queue=queue, include_failed=include_failed ) jobs_count = len(await get_all("procrastinate_jobs", "id")) assert jobs_count == expected_job_count diff --git a/tests/unit/test_builtin_tasks.py b/tests/unit/test_builtin_tasks.py index e25d253c7..d9d17de65 100644 --- a/tests/unit/test_builtin_tasks.py +++ b/tests/unit/test_builtin_tasks.py @@ -13,7 +13,7 @@ async def test_remove_old_jobs(app: App, job_factory): job_context.JobContext(app=app, job=job), max_hours=2, queue="queue_a", - remove_error=True, + remove_failed=True, remove_cancelled=True, remove_aborted=True, ) diff --git a/tests/unit/test_manager.py b/tests/unit/test_manager.py index 27d296330..ef8c8c32d 100644 --- a/tests/unit/test_manager.py +++ b/tests/unit/test_manager.py @@ -132,14 +132,14 @@ async def test_get_stalled_jobs_stalled(job_manager, job_factory, connector): @pytest.mark.parametrize( - "include_error, statuses", + "include_failed, statuses", [(False, ["succeeded"]), (True, ["succeeded", "failed"])], ) async def test_delete_old_jobs( - job_manager, job_factory, connector, include_error, statuses, mocker + job_manager, job_factory, connector, include_failed, statuses, mocker ): await job_manager.delete_old_jobs( - nb_hours=5, queue="marsupilami", include_error=include_error + nb_hours=5, queue="marsupilami", include_failed=include_failed ) assert connector.queries == [ (