plain.jobs 0.36.3__tar.gz → 0.37.1__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.

Files changed (33) hide show
  1. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/PKG-INFO +1 -1
  2. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/CHANGELOG.md +21 -0
  3. plain_jobs-0.37.1/plain/jobs/__init__.py +5 -0
  4. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/admin.py +6 -6
  5. plain_jobs-0.37.1/plain/jobs/middleware.py +42 -0
  6. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/workers.py +2 -2
  7. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/pyproject.toml +1 -1
  8. plain_jobs-0.36.3/plain/jobs/__init__.py +0 -4
  9. plain_jobs-0.36.3/plain/jobs/middleware.py +0 -20
  10. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/.gitignore +0 -0
  11. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/LICENSE +0 -0
  12. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/README.md +0 -0
  13. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/README.md +0 -0
  14. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/chores.py +0 -0
  15. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/cli.py +0 -0
  16. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/config.py +0 -0
  17. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/default_settings.py +0 -0
  18. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/jobs.py +0 -0
  19. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/migrations/0001_initial.py +0 -0
  20. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/migrations/0002_job_span_id_job_trace_id_jobrequest_span_id_and_more.py +0 -0
  21. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/migrations/0003_rename_job_jobprocess_and_more.py +0 -0
  22. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/migrations/0004_rename_tables_to_plainjobs.py +0 -0
  23. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/migrations/0005_rename_constraints_and_indexes.py +0 -0
  24. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/migrations/0006_alter_jobprocess_table_alter_jobrequest_table_and_more.py +0 -0
  25. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/migrations/__init__.py +0 -0
  26. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/models.py +0 -0
  27. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/parameters.py +0 -0
  28. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/registry.py +0 -0
  29. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/scheduling.py +0 -0
  30. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/plain/jobs/templates/admin/plainqueue/jobresult_detail.html +0 -0
  31. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/tests/app/settings.py +0 -0
  32. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/tests/test_parameters.py +0 -0
  33. {plain_jobs-0.36.3 → plain_jobs-0.37.1}/tests/test_scheduling.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.jobs
3
- Version: 0.36.3
3
+ Version: 0.37.1
4
4
  Summary: Process background jobs with a database-driven job queue.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -1,5 +1,26 @@
1
1
  # plain-jobs changelog
2
2
 
3
+ ## [0.37.1](https://github.com/dropseed/plain/releases/plain-jobs@0.37.1) (2025-10-24)
4
+
5
+ ### What's changed
6
+
7
+ - Fixed admin interface filter functionality to correctly use `preset` instead of `display` for filtering job results ([26fde7d562](https://github.com/dropseed/plain/commit/26fde7d562))
8
+
9
+ ### Upgrade instructions
10
+
11
+ - No changes required
12
+
13
+ ## [0.37.0](https://github.com/dropseed/plain/releases/plain-jobs@0.37.0) (2025-10-22)
14
+
15
+ ### What's changed
16
+
17
+ - Added `JobMiddleware` abstract base class for creating custom job middleware ([29e5c6df1a](https://github.com/dropseed/plain/commit/29e5c6df1a))
18
+ - 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))
19
+
20
+ ### Upgrade instructions
21
+
22
+ - If you have custom job middleware, update them to inherit from `JobMiddleware` and implement the `process_job()` method instead of `__call__()`
23
+
3
24
  ## [0.36.3](https://github.com/dropseed/plain/releases/plain-jobs@0.36.3) (2025-10-20)
4
25
 
5
26
  ### What's changed
@@ -0,0 +1,5 @@
1
+ from .jobs import Job
2
+ from .middleware import JobMiddleware
3
+ from .registry import register_job
4
+
5
+ __all__ = ["Job", "JobMiddleware", "register_job"]
@@ -204,21 +204,21 @@ class JobResultViewset(AdminViewset):
204
204
  output_field=models.BooleanField(),
205
205
  ),
206
206
  )
207
- if self.display == "Successful":
207
+ if self.preset == "Successful":
208
208
  return queryset.successful()
209
- if self.display == "Errored":
209
+ if self.preset == "Errored":
210
210
  return queryset.errored()
211
- if self.display == "Cancelled":
211
+ if self.preset == "Cancelled":
212
212
  return queryset.cancelled()
213
- if self.display == "Lost":
213
+ if self.preset == "Lost":
214
214
  return queryset.lost()
215
- if self.display == "Retried":
215
+ if self.preset == "Retried":
216
216
  return queryset.retried()
217
217
  return queryset
218
218
 
219
219
  def get_fields(self) -> list[str]:
220
220
  fields = super().get_fields()
221
- if self.display == "Retried":
221
+ if self.preset == "Retried":
222
222
  fields.append("retries")
223
223
  fields.append("retry_attempt")
224
224
  return fields
@@ -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.info(
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,6 +1,6 @@
1
1
  [project]
2
2
  name = "plain.jobs"
3
- version = "0.36.3"
3
+ version = "0.37.1"
4
4
  description = "Process background jobs with a database-driven job queue."
5
5
  authors = [{name = "Dave Gaeddert", email = "dave.gaeddert@dropseed.dev"}]
6
6
  readme = "README.md"
@@ -1,4 +0,0 @@
1
- from .jobs import Job
2
- from .registry import register_job
3
-
4
- __all__ = ["Job", "register_job"]
@@ -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