weft-django 0.9.4__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.
- weft_django-0.9.4/.gitignore +85 -0
- weft_django-0.9.4/PKG-INFO +65 -0
- weft_django-0.9.4/README.md +50 -0
- weft_django-0.9.4/pyproject.toml +32 -0
- weft_django-0.9.4/weft_django/__init__.py +44 -0
- weft_django-0.9.4/weft_django/apps.py +15 -0
- weft_django-0.9.4/weft_django/channels.py +26 -0
- weft_django-0.9.4/weft_django/client.py +529 -0
- weft_django-0.9.4/weft_django/conf.py +125 -0
- weft_django-0.9.4/weft_django/decorators.py +176 -0
- weft_django-0.9.4/weft_django/management/__init__.py +1 -0
- weft_django-0.9.4/weft_django/management/commands/__init__.py +1 -0
- weft_django-0.9.4/weft_django/management/commands/weft_status.py +25 -0
- weft_django-0.9.4/weft_django/management/commands/weft_task_kill.py +19 -0
- weft_django-0.9.4/weft_django/management/commands/weft_task_status.py +23 -0
- weft_django-0.9.4/weft_django/management/commands/weft_task_stop.py +19 -0
- weft_django-0.9.4/weft_django/registry.py +87 -0
- weft_django-0.9.4/weft_django/sse.py +64 -0
- weft_django-0.9.4/weft_django/urls.py +15 -0
- weft_django-0.9.4/weft_django/views.py +35 -0
- weft_django-0.9.4/weft_django/worker.py +55 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
MANIFEST
|
|
23
|
+
.weft
|
|
24
|
+
|
|
25
|
+
# Virtual environments
|
|
26
|
+
venv/
|
|
27
|
+
ENV/
|
|
28
|
+
env/
|
|
29
|
+
.venv
|
|
30
|
+
.weft/broker.*
|
|
31
|
+
.weft/config.json
|
|
32
|
+
.weft/agents.json
|
|
33
|
+
|
|
34
|
+
# IDEs
|
|
35
|
+
.vscode/
|
|
36
|
+
.idea/
|
|
37
|
+
*.swp
|
|
38
|
+
*.swo
|
|
39
|
+
*~
|
|
40
|
+
|
|
41
|
+
# Testing
|
|
42
|
+
.coverage
|
|
43
|
+
.coverage.*
|
|
44
|
+
.pytest_cache/
|
|
45
|
+
htmlcov/
|
|
46
|
+
.tox/
|
|
47
|
+
.nox/
|
|
48
|
+
.mypy_cache/
|
|
49
|
+
.dmypy.json
|
|
50
|
+
dmypy.json
|
|
51
|
+
.ruff_cache/
|
|
52
|
+
.ruff/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
|
|
55
|
+
# SimpleBroker specific
|
|
56
|
+
*.db-shm
|
|
57
|
+
*.db-wal
|
|
58
|
+
.broker.db*
|
|
59
|
+
test.db
|
|
60
|
+
benchmark_pragma.py
|
|
61
|
+
|
|
62
|
+
# OS
|
|
63
|
+
.DS_Store
|
|
64
|
+
Thumbs.db
|
|
65
|
+
|
|
66
|
+
# Temporary files
|
|
67
|
+
*.tmp
|
|
68
|
+
*.bak
|
|
69
|
+
*.log
|
|
70
|
+
|
|
71
|
+
# Multi-agent
|
|
72
|
+
.claude
|
|
73
|
+
.mcp.json
|
|
74
|
+
agent_history/
|
|
75
|
+
.broker.db
|
|
76
|
+
.broker.db-shm
|
|
77
|
+
.broker.db-wal
|
|
78
|
+
.broker.connection.done
|
|
79
|
+
.broker.connection.lock
|
|
80
|
+
.broker.optimization.done
|
|
81
|
+
.broker.optimization.lock
|
|
82
|
+
*comments*.md
|
|
83
|
+
.code/
|
|
84
|
+
# This is in context for agents but we don't want it to check it in here
|
|
85
|
+
simplebroker/
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: weft-django
|
|
3
|
+
Version: 0.9.4
|
|
4
|
+
Summary: Django integration layer for Weft
|
|
5
|
+
Author-email: Van Lindberg <van@modelmonster.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Requires-Dist: django<6,>=4.2
|
|
9
|
+
Requires-Dist: weft<1,>=0.9.4
|
|
10
|
+
Provides-Extra: channels
|
|
11
|
+
Requires-Dist: channels<5,>=4.1; extra == 'channels'
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# weft-django
|
|
17
|
+
|
|
18
|
+
`weft-django` is the first-party Django integration for Weft.
|
|
19
|
+
|
|
20
|
+
It provides:
|
|
21
|
+
|
|
22
|
+
- `@weft_task` for Django-owned synchronous background functions
|
|
23
|
+
- transaction-safe submission helpers such as `enqueue_on_commit()`
|
|
24
|
+
- native TaskSpec, stored spec, and pipeline submission helpers
|
|
25
|
+
- read-only Django URLs for task inspection
|
|
26
|
+
- Django management commands for task status and control
|
|
27
|
+
|
|
28
|
+
Install:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
uv add weft-django
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or from the main package convenience extra:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
uv add "weft[django]"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Basic usage:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from weft_django import weft_task
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@weft_task(name="billing.send_invoice", timeout=60)
|
|
47
|
+
def send_invoice(invoice_id: int) -> None:
|
|
48
|
+
...
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
submission = send_invoice.enqueue(123)
|
|
52
|
+
submission.result(timeout=30)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Celery migration guide:
|
|
56
|
+
|
|
57
|
+
| Celery habit | `weft-django` |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `@shared_task` | `@weft_task` |
|
|
60
|
+
| `task.delay(...)` | `task.enqueue(...)` |
|
|
61
|
+
| `transaction.on_commit(lambda: task.delay(...))` | `task.enqueue_on_commit(...)` |
|
|
62
|
+
|
|
63
|
+
`delay` and `shared_task` are intentionally not shipped. They are close enough
|
|
64
|
+
to invite mechanical porting and far enough from Weft semantics to create
|
|
65
|
+
delayed failures.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# weft-django
|
|
2
|
+
|
|
3
|
+
`weft-django` is the first-party Django integration for Weft.
|
|
4
|
+
|
|
5
|
+
It provides:
|
|
6
|
+
|
|
7
|
+
- `@weft_task` for Django-owned synchronous background functions
|
|
8
|
+
- transaction-safe submission helpers such as `enqueue_on_commit()`
|
|
9
|
+
- native TaskSpec, stored spec, and pipeline submission helpers
|
|
10
|
+
- read-only Django URLs for task inspection
|
|
11
|
+
- Django management commands for task status and control
|
|
12
|
+
|
|
13
|
+
Install:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
uv add weft-django
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or from the main package convenience extra:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv add "weft[django]"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Basic usage:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from weft_django import weft_task
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@weft_task(name="billing.send_invoice", timeout=60)
|
|
32
|
+
def send_invoice(invoice_id: int) -> None:
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
submission = send_invoice.enqueue(123)
|
|
37
|
+
submission.result(timeout=30)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Celery migration guide:
|
|
41
|
+
|
|
42
|
+
| Celery habit | `weft-django` |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `@shared_task` | `@weft_task` |
|
|
45
|
+
| `task.delay(...)` | `task.enqueue(...)` |
|
|
46
|
+
| `transaction.on_commit(lambda: task.delay(...))` | `task.enqueue_on_commit(...)` |
|
|
47
|
+
|
|
48
|
+
`delay` and `shared_task` are intentionally not shipped. They are close enough
|
|
49
|
+
to invite mechanical porting and far enough from Weft semantics to create
|
|
50
|
+
delayed failures.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "weft-django"
|
|
7
|
+
version = "0.9.4"
|
|
8
|
+
description = "Django integration layer for Weft"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Van Lindberg", email = "van@modelmonster.ai"},
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"django>=4.2,<6",
|
|
17
|
+
"weft>=0.9.4,<1",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
channels = [
|
|
22
|
+
"channels>=4.1,<5",
|
|
23
|
+
]
|
|
24
|
+
dev = [
|
|
25
|
+
"pytest>=7.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[tool.hatch.build]
|
|
29
|
+
include = [
|
|
30
|
+
"weft_django/**/*.py",
|
|
31
|
+
"README.md",
|
|
32
|
+
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Public Django-facing Weft integration surface."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from weft_django.client import (
|
|
6
|
+
DjangoWeftClient,
|
|
7
|
+
WeftDeferredSubmission,
|
|
8
|
+
WeftSubmission,
|
|
9
|
+
enqueue,
|
|
10
|
+
enqueue_on_commit,
|
|
11
|
+
get_client,
|
|
12
|
+
kill,
|
|
13
|
+
result,
|
|
14
|
+
status,
|
|
15
|
+
stop,
|
|
16
|
+
submit_pipeline_reference,
|
|
17
|
+
submit_pipeline_reference_on_commit,
|
|
18
|
+
submit_spec_reference,
|
|
19
|
+
submit_spec_reference_on_commit,
|
|
20
|
+
submit_taskspec,
|
|
21
|
+
submit_taskspec_on_commit,
|
|
22
|
+
)
|
|
23
|
+
from weft_django.decorators import RegisteredWeftTask, weft_task
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"DjangoWeftClient",
|
|
27
|
+
"RegisteredWeftTask",
|
|
28
|
+
"WeftDeferredSubmission",
|
|
29
|
+
"WeftSubmission",
|
|
30
|
+
"enqueue",
|
|
31
|
+
"enqueue_on_commit",
|
|
32
|
+
"get_client",
|
|
33
|
+
"kill",
|
|
34
|
+
"result",
|
|
35
|
+
"status",
|
|
36
|
+
"stop",
|
|
37
|
+
"submit_pipeline_reference",
|
|
38
|
+
"submit_pipeline_reference_on_commit",
|
|
39
|
+
"submit_spec_reference",
|
|
40
|
+
"submit_spec_reference_on_commit",
|
|
41
|
+
"submit_taskspec",
|
|
42
|
+
"submit_taskspec_on_commit",
|
|
43
|
+
"weft_task",
|
|
44
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Django app config for the Weft integration."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from django.apps import AppConfig
|
|
6
|
+
|
|
7
|
+
from weft_django.registry import autodiscover_tasks
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class WeftDjangoConfig(AppConfig):
|
|
11
|
+
name = "weft_django"
|
|
12
|
+
verbose_name = "Weft Django"
|
|
13
|
+
|
|
14
|
+
def ready(self) -> None:
|
|
15
|
+
autodiscover_tasks()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Optional Channels integration for Weft task diagnostics."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
from channels.generic.websocket import AsyncJsonWebsocketConsumer
|
|
9
|
+
except ImportError as exc: # pragma: no cover - import guard
|
|
10
|
+
raise ImproperlyConfigured(
|
|
11
|
+
"Channels support requires installing weft-django with the 'channels' extra"
|
|
12
|
+
) from exc
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TaskEventsConsumer(AsyncJsonWebsocketConsumer): # pragma: no cover - optional
|
|
16
|
+
async def connect(self) -> None:
|
|
17
|
+
await self.accept()
|
|
18
|
+
await self.send_json(
|
|
19
|
+
{
|
|
20
|
+
"event_type": "end",
|
|
21
|
+
"payload": {
|
|
22
|
+
"detail": "Use the default SSE transport in v1 unless the project provides a custom Channels consumer."
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
await self.close()
|