broccoli-workers 0.1.2__tar.gz → 0.1.3__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.
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/PKG-INFO +2 -1
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/chain/chain.py +13 -2
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/chain/task_chain.py +13 -1
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/task/task.py +12 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/task/task_queue.py +2 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/base_worker.py +1 -3
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli_workers.egg-info/PKG-INFO +2 -1
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli_workers.egg-info/requires.txt +1 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/pyproject.toml +2 -1
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/LICENSE +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/README.md +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/__init__.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/cli.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/__init__.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/chain/chain_queue.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/gpu/gpu_queue.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/health.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/redis_controller.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/result.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/core/task/task_registry.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/logging_config.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/GPUAutoScalingPool.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/__init__.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/async_worker.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/auto_scale_worker.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/chain_worker.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/gpu_worker.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/hybrid_worker.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/threaded_worker.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli/workers/worker_pool.py +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli_workers.egg-info/SOURCES.txt +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli_workers.egg-info/dependency_links.txt +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli_workers.egg-info/entry_points.txt +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli_workers.egg-info/top_level.txt +0 -0
- {broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: broccoli-workers
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Distributed task queue with priorities, dependencies, and chains, backed by Redis
|
|
5
5
|
Author-email: Success Oguntuyi <oguntuyisuccess@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -37,6 +37,7 @@ Requires-Python: >=3.11
|
|
|
37
37
|
Description-Content-Type: text/markdown
|
|
38
38
|
License-File: LICENSE
|
|
39
39
|
Requires-Dist: redis>=4.0.0
|
|
40
|
+
Requires-Dist: torch>=3.0.0
|
|
40
41
|
Provides-Extra: dev
|
|
41
42
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
42
43
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
@@ -43,15 +43,26 @@ class Chain:
|
|
|
43
43
|
|
|
44
44
|
@classmethod
|
|
45
45
|
def from_dict(cls, data: dict) -> "Chain":
|
|
46
|
-
"""Create a Chain object from a dictionary."""
|
|
46
|
+
"""Create a Chain object from a dictionary, safely handling result JSON."""
|
|
47
47
|
data = cls._normalize_redis_mapping(data)
|
|
48
|
+
|
|
49
|
+
# Safely deserialize 'result' field
|
|
50
|
+
raw_result = data.get("result")
|
|
51
|
+
if raw_result and isinstance(raw_result, str) and raw_result.strip():
|
|
52
|
+
try:
|
|
53
|
+
result = json.loads(raw_result)
|
|
54
|
+
except json.JSONDecodeError:
|
|
55
|
+
result = None
|
|
56
|
+
else:
|
|
57
|
+
result = None
|
|
58
|
+
|
|
48
59
|
return cls(
|
|
49
60
|
chain_id=data.get("chain_id"),
|
|
50
61
|
completion_task=data.get("completion_task") or None,
|
|
51
62
|
status=data.get("status", "pending"),
|
|
52
63
|
completed_tasks=int(data.get("completed_tasks", 0)),
|
|
53
64
|
current_task=int(data.get("current_task", 0)),
|
|
54
|
-
result=
|
|
65
|
+
result=result,
|
|
55
66
|
failed=data.get("failed", "False") == "True",
|
|
56
67
|
total_tasks=int(data.get("total_tasks", 0))
|
|
57
68
|
if data.get("total_tasks")
|
|
@@ -5,6 +5,7 @@ import uuid
|
|
|
5
5
|
from typing import Any, Dict, List, Optional, Union
|
|
6
6
|
|
|
7
7
|
from broccoli.core.chain.chain import Chain
|
|
8
|
+
from broccoli.core.chain.chain_queue import ChainQueue
|
|
8
9
|
from broccoli.core.redis_controller import RedisController
|
|
9
10
|
from broccoli.core.task.task import Task
|
|
10
11
|
from broccoli.core.task.task_queue import TaskQueue
|
|
@@ -24,7 +25,7 @@ class TaskChain:
|
|
|
24
25
|
redis_config: dict = None,
|
|
25
26
|
):
|
|
26
27
|
redis_config = redis_config or {}
|
|
27
|
-
self.queue =
|
|
28
|
+
self.queue = ChainQueue(
|
|
28
29
|
redis_url=redis_url,
|
|
29
30
|
queue_name="chain_tasks:queue",
|
|
30
31
|
task_prefix="chain",
|
|
@@ -167,3 +168,14 @@ class TaskChain:
|
|
|
167
168
|
return {"status": "Not Found"}
|
|
168
169
|
|
|
169
170
|
return data
|
|
171
|
+
|
|
172
|
+
def get_all_chain_tasks(self, chain_id: str) -> List[Dict[str, Any]]:
|
|
173
|
+
"""Retrieve all tasks associated with a chain."""
|
|
174
|
+
tasks_json = self._redis.get(f"chain:{chain_id}:tasks")
|
|
175
|
+
if not tasks_json:
|
|
176
|
+
return []
|
|
177
|
+
try:
|
|
178
|
+
return json.loads(tasks_json)
|
|
179
|
+
except json.JSONDecodeError:
|
|
180
|
+
logger.error(f"Failed to decode tasks for chain {chain_id}")
|
|
181
|
+
return []
|
|
@@ -86,3 +86,15 @@ class Task:
|
|
|
86
86
|
created_at=data.get("created_at") or datetime.now().isoformat(),
|
|
87
87
|
updated_at=data.get("updated_at") or None,
|
|
88
88
|
)
|
|
89
|
+
|
|
90
|
+
def __post_init__(self):
|
|
91
|
+
"""Inject the task_id into the payload automatically."""
|
|
92
|
+
# Ensure payload is a dict (it is by default)
|
|
93
|
+
if self.payload is None:
|
|
94
|
+
self.payload = {}
|
|
95
|
+
# Always set the task_id in the payload to match this task's ID
|
|
96
|
+
if "task_id" not in self.payload:
|
|
97
|
+
self.payload["task_id"] = self.task_id
|
|
98
|
+
# (Optional) Ensure depends_on is a list
|
|
99
|
+
if self.depends_on is None:
|
|
100
|
+
self.depends_on = []
|
|
@@ -222,6 +222,8 @@ class TaskQueue:
|
|
|
222
222
|
"""
|
|
223
223
|
# Always persist task metadata first so workers can read it after pop().
|
|
224
224
|
self._redis.hset(f"{self.task_prefix}:{task.task_id}", mapping=task.to_dict())
|
|
225
|
+
if len(task.depends_on) == 0:
|
|
226
|
+
task.depends_on = None
|
|
225
227
|
|
|
226
228
|
if task.depends_on:
|
|
227
229
|
# Build the key list for the Lua script:
|
|
@@ -225,9 +225,7 @@ class BaseWorker(ABC):
|
|
|
225
225
|
exc_info=True,
|
|
226
226
|
)
|
|
227
227
|
if task.payload.get("__chain_id"):
|
|
228
|
-
|
|
229
|
-
f"Task {task.task_id} is part of chain {task.chain_id}; skipping result storage"
|
|
230
|
-
)
|
|
228
|
+
self.result.store_task(task)
|
|
231
229
|
if task.payload.get("__is_last_task"):
|
|
232
230
|
logger.info(
|
|
233
231
|
f"Task {task.task_id} is the last task in chain {task.chain_id}; running chain completion handlers"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: broccoli-workers
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Distributed task queue with priorities, dependencies, and chains, backed by Redis
|
|
5
5
|
Author-email: Success Oguntuyi <oguntuyisuccess@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -37,6 +37,7 @@ Requires-Python: >=3.11
|
|
|
37
37
|
Description-Content-Type: text/markdown
|
|
38
38
|
License-File: LICENSE
|
|
39
39
|
Requires-Dist: redis>=4.0.0
|
|
40
|
+
Requires-Dist: torch>=3.0.0
|
|
40
41
|
Provides-Extra: dev
|
|
41
42
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
42
43
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "broccoli-workers"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "Distributed task queue with priorities, dependencies, and chains, backed by Redis"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -24,6 +24,7 @@ classifiers = [
|
|
|
24
24
|
requires-python = ">=3.11" # ← changed from >=3.9
|
|
25
25
|
dependencies = [
|
|
26
26
|
"redis>=4.0.0",
|
|
27
|
+
"torch>=3.0.0",
|
|
27
28
|
]
|
|
28
29
|
|
|
29
30
|
[project.optional-dependencies]
|
|
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
|
|
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
|
{broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli_workers.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{broccoli_workers-0.1.2 → broccoli_workers-0.1.3}/broccoli_workers.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|