plain.jobs 0.36.3__tar.gz → 0.37.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of plain.jobs might be problematic. Click here for more details.
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/PKG-INFO +1 -1
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/CHANGELOG.md +11 -0
- plain_jobs-0.37.0/plain/jobs/__init__.py +5 -0
- plain_jobs-0.37.0/plain/jobs/middleware.py +42 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/workers.py +2 -2
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/pyproject.toml +1 -1
- plain_jobs-0.36.3/plain/jobs/__init__.py +0 -4
- plain_jobs-0.36.3/plain/jobs/middleware.py +0 -20
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/.gitignore +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/LICENSE +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/README.md +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/README.md +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/admin.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/chores.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/cli.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/config.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/default_settings.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/jobs.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0001_initial.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0002_job_span_id_job_trace_id_jobrequest_span_id_and_more.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0003_rename_job_jobprocess_and_more.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0004_rename_tables_to_plainjobs.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0005_rename_constraints_and_indexes.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0006_alter_jobprocess_table_alter_jobrequest_table_and_more.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/__init__.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/models.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/parameters.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/registry.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/scheduling.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/templates/admin/plainqueue/jobresult_detail.html +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/tests/app/settings.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/tests/test_parameters.py +0 -0
- {plain_jobs-0.36.3 → plain_jobs-0.37.0}/tests/test_scheduling.py +0 -0
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# plain-jobs changelog
|
|
2
2
|
|
|
3
|
+
## [0.37.0](https://github.com/dropseed/plain/releases/plain-jobs@0.37.0) (2025-10-22)
|
|
4
|
+
|
|
5
|
+
### What's changed
|
|
6
|
+
|
|
7
|
+
- Added `JobMiddleware` abstract base class for creating custom job middleware ([29e5c6df1a](https://github.com/dropseed/plain/commit/29e5c6df1a))
|
|
8
|
+
- Changed "preparing to execute job" log message from `logger.info` to `logger.debug` to reduce log noise ([8e25856639](https://github.com/dropseed/plain/commit/8e25856639))
|
|
9
|
+
|
|
10
|
+
### Upgrade instructions
|
|
11
|
+
|
|
12
|
+
- If you have custom job middleware, update them to inherit from `JobMiddleware` and implement the `process_job()` method instead of `__call__()`
|
|
13
|
+
|
|
3
14
|
## [0.36.3](https://github.com/dropseed/plain/releases/plain-jobs@0.36.3) (2025-10-20)
|
|
4
15
|
|
|
5
16
|
### What's changed
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from collections.abc import Callable
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from plain.logs import app_logger
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .models import JobProcess, JobResult
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class JobMiddleware(ABC):
|
|
14
|
+
"""
|
|
15
|
+
Abstract base class for job middleware.
|
|
16
|
+
|
|
17
|
+
Subclasses must implement process_job() to handle the job execution cycle.
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
class MyJobMiddleware(JobMiddleware):
|
|
21
|
+
def process_job(self, job: JobProcess) -> JobResult:
|
|
22
|
+
# Pre-processing
|
|
23
|
+
result = self.run_job(job)
|
|
24
|
+
# Post-processing
|
|
25
|
+
return result
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, run_job: Callable[[JobProcess], JobResult]):
|
|
29
|
+
self.run_job = run_job
|
|
30
|
+
|
|
31
|
+
@abstractmethod
|
|
32
|
+
def process_job(self, job: JobProcess) -> JobResult:
|
|
33
|
+
"""Process the job and return a result. Must be implemented by subclasses."""
|
|
34
|
+
...
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class AppLoggerMiddleware(JobMiddleware):
|
|
38
|
+
def process_job(self, job: JobProcess) -> JobResult:
|
|
39
|
+
with app_logger.include_context(
|
|
40
|
+
job_request_uuid=str(job.job_request_uuid), job_process_uuid=str(job.uuid)
|
|
41
|
+
):
|
|
42
|
+
return self.run_job(job)
|
|
@@ -144,7 +144,7 @@ class Worker:
|
|
|
144
144
|
time.sleep(1)
|
|
145
145
|
continue
|
|
146
146
|
|
|
147
|
-
logger.
|
|
147
|
+
logger.debug(
|
|
148
148
|
'Preparing to execute job job_class=%s job_request_uuid=%s job_priority=%s job_source="%s" job_queues="%s"',
|
|
149
149
|
job_request.job_class,
|
|
150
150
|
job_request.uuid,
|
|
@@ -327,7 +327,7 @@ def process_job(job_process_uuid: str) -> None:
|
|
|
327
327
|
for middleware_path in reversed(settings.JOBS_MIDDLEWARE):
|
|
328
328
|
middleware_class = import_string(middleware_path)
|
|
329
329
|
middleware_instance = middleware_class(middleware_chain)
|
|
330
|
-
middleware_chain = middleware_instance
|
|
330
|
+
middleware_chain = middleware_instance.process_job
|
|
331
331
|
|
|
332
332
|
job_result = middleware_chain(job_process)
|
|
333
333
|
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from collections.abc import Callable
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
5
|
-
|
|
6
|
-
from plain.logs import app_logger
|
|
7
|
-
|
|
8
|
-
if TYPE_CHECKING:
|
|
9
|
-
from .models import JobProcess, JobResult
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class AppLoggerMiddleware:
|
|
13
|
-
def __init__(self, run_job: Callable[[JobProcess], JobResult]) -> None:
|
|
14
|
-
self.run_job = run_job
|
|
15
|
-
|
|
16
|
-
def __call__(self, job: JobProcess) -> JobResult:
|
|
17
|
-
with app_logger.include_context(
|
|
18
|
-
job_request_uuid=str(job.job_request_uuid), job_process_uuid=str(job.uuid)
|
|
19
|
-
):
|
|
20
|
-
return self.run_job(job)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0003_rename_job_jobprocess_and_more.py
RENAMED
|
File without changes
|
{plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0004_rename_tables_to_plainjobs.py
RENAMED
|
File without changes
|
{plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/migrations/0005_rename_constraints_and_indexes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{plain_jobs-0.36.3 → plain_jobs-0.37.0}/plain/jobs/templates/admin/plainqueue/jobresult_detail.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|