abstract-block-dumper 0.0.4__tar.gz → 0.0.6__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.
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/CHANGELOG.md +5 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/PKG-INFO +10 -7
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/README.md +8 -5
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/tasks.py +25 -6
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/noxfile.py +4 -1
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/pyproject.toml +2 -2
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_version.py +2 -2
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/v1/decorators.py +34 -12
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/integration/test_registered_celery_tasks.py +1 -2
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/integration/test_scheduler.py +4 -4
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/uv.lock +1 -1
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/.cruft.json +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/.github/dependabot.yml +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/.github/workflows/ci.yml +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/.github/workflows/publish.yml +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/.gitignore +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/.pre-commit-config.yaml +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/.shellcheckrc +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/SECURITY.md +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/docs/3rd_party/cookiecutter-rt-pkg/CHANGELOG.md +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/.dockerignore +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/.gitignore +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/Dockerfile +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/README.md +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/admin.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/apps.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/management/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/management/commands/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/management/commands/create_admin.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/migrations/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/models.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/tests.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/views.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/docker-compose.yml +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/asgi.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/celery.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/settings.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/urls.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/wsgi.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/main.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/manage.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/pyproject.toml +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/pytest.ini +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/uv.lock +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/dal/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/dal/django_dal.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/dal/memory_registry.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/discovery.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/exceptions.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/services/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/services/block_processor.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/services/executor.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/services/scheduler.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_internal/services/utils.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/admin.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/apps.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/management/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/management/commands/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/management/commands/block_tasks_v1.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/migrations/0001_initial.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/migrations/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/models.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/py.typed +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/v1/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/v1/celery.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/v1/tasks.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/conftest.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/django_fixtures.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/fatories.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/integration/__init__.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/integration/test_block_processor.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/integration/test_concurrent_processing.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/integration/test_multi_arguments_tasks.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/integration/test_task_registration.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/settings.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/unit/test_celery_integration.py +0 -0
- {abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/unit/test_decorator.py +0 -0
|
@@ -9,6 +9,11 @@ upcoming release can be found in [changelog.d](changelog.d).
|
|
|
9
9
|
|
|
10
10
|
<!-- towncrier release notes start -->
|
|
11
11
|
|
|
12
|
+
## [0.0.6](https://github.com/bactensor/abstract-block-dumper/releases/tag/v0.0.6) - 2025-11-26
|
|
13
|
+
|
|
14
|
+
No significant changes.
|
|
15
|
+
|
|
16
|
+
|
|
12
17
|
## [0.0.4](https://github.com/bactensor/abstract-block-dumper/releases/tag/v0.0.4) - 2025-11-17
|
|
13
18
|
|
|
14
19
|
No significant changes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: abstract-block-dumper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Project-URL: Source, https://github.com/bactensor/abstract-block-dumper
|
|
5
5
|
Project-URL: Issue Tracker, https://github.com/bactensor/abstract-block-dumper/issues
|
|
6
6
|
Author-email: Reef Technologies <opensource@reef.pl>
|
|
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
15
15
|
Classifier: Topic :: Software Development :: Libraries
|
|
16
16
|
Requires-Python: >=3.11
|
|
17
17
|
Requires-Dist: bittensor>=9.10.1
|
|
18
|
-
Requires-Dist: celery>=5.
|
|
18
|
+
Requires-Dist: celery>=5.3
|
|
19
19
|
Requires-Dist: django<6.0,>=3.2
|
|
20
20
|
Requires-Dist: structlog>=25.4.0
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
@@ -104,18 +104,21 @@ In your project's `celery.py` file, add the following to ensure Celery workers c
|
|
|
104
104
|
|
|
105
105
|
```python
|
|
106
106
|
from celery import Celery
|
|
107
|
-
from celery.signals import
|
|
107
|
+
from celery.signals import celeryd_init
|
|
108
108
|
from django.conf import settings
|
|
109
109
|
|
|
110
110
|
app = Celery('your_project')
|
|
111
111
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
|
112
112
|
app.autodiscover_tasks()
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@celeryd_init.connect
|
|
117
|
+
def on_worker_init(**kwargs) -> None:
|
|
118
|
+
"""Load block tasks when worker initializes."""
|
|
117
119
|
from abstract_block_dumper.v1.celery import setup_celery_tasks
|
|
118
120
|
setup_celery_tasks()
|
|
121
|
+
|
|
119
122
|
```
|
|
120
123
|
|
|
121
124
|
> **Important:** Without this step, Celery workers will not recognize your `@block_task` decorated functions, and you'll see "Received unregistered task" errors.
|
|
@@ -154,7 +157,7 @@ from abstract_block_dumper.v1.decorators import block_task
|
|
|
154
157
|
|
|
155
158
|
|
|
156
159
|
# Process every block
|
|
157
|
-
@block_task
|
|
160
|
+
@block_task
|
|
158
161
|
def process_every_block(block_number: int):
|
|
159
162
|
print(f"Processing every block: {block_number}")
|
|
160
163
|
|
|
@@ -82,18 +82,21 @@ In your project's `celery.py` file, add the following to ensure Celery workers c
|
|
|
82
82
|
|
|
83
83
|
```python
|
|
84
84
|
from celery import Celery
|
|
85
|
-
from celery.signals import
|
|
85
|
+
from celery.signals import celeryd_init
|
|
86
86
|
from django.conf import settings
|
|
87
87
|
|
|
88
88
|
app = Celery('your_project')
|
|
89
89
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
|
90
90
|
app.autodiscover_tasks()
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@celeryd_init.connect
|
|
95
|
+
def on_worker_init(**kwargs) -> None:
|
|
96
|
+
"""Load block tasks when worker initializes."""
|
|
95
97
|
from abstract_block_dumper.v1.celery import setup_celery_tasks
|
|
96
98
|
setup_celery_tasks()
|
|
99
|
+
|
|
97
100
|
```
|
|
98
101
|
|
|
99
102
|
> **Important:** Without this step, Celery workers will not recognize your `@block_task` decorated functions, and you'll see "Received unregistered task" errors.
|
|
@@ -132,7 +135,7 @@ from abstract_block_dumper.v1.decorators import block_task
|
|
|
132
135
|
|
|
133
136
|
|
|
134
137
|
# Process every block
|
|
135
|
-
@block_task
|
|
138
|
+
@block_task
|
|
136
139
|
def process_every_block(block_number: int):
|
|
137
140
|
print(f"Processing every block: {block_number}")
|
|
138
141
|
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/tasks.py
RENAMED
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
from abstract_block_dumper.v1.decorators import block_task
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
@block_task
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
@block_task
|
|
5
|
+
def process_every_block(block_number: int, netuid: int | None = None) -> str:
|
|
6
|
+
"""
|
|
7
|
+
Example task that processes every block.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
block_number (int): The block number to process.
|
|
11
|
+
netuid (int | None): The NetUID to process, if applicable.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
str: A message indicating the block has been processed.
|
|
15
|
+
|
|
16
|
+
"""
|
|
8
17
|
return f"Processed block {block_number} for NetUID {netuid}"
|
|
9
18
|
|
|
10
19
|
|
|
11
20
|
@block_task(
|
|
12
|
-
condition=lambda bn: True,
|
|
13
21
|
backfilling_lookback=100,
|
|
14
22
|
)
|
|
15
|
-
def backfill_previous_100_blocks(block_number: int, netuid: int | None = None):
|
|
23
|
+
def backfill_previous_100_blocks(block_number: int, netuid: int | None = None) -> str:
|
|
24
|
+
"""
|
|
25
|
+
Example task that backfills the previous 100 blocks.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
block_number (int): The block number to process.
|
|
29
|
+
netuid (int | None): The NetUID to process, if applicable.
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
str: A message indicating the block has been processed.
|
|
33
|
+
|
|
34
|
+
"""
|
|
16
35
|
return f"Processed block {block_number} for NetUID {netuid}"
|
|
17
36
|
|
|
18
37
|
|
|
@@ -18,6 +18,7 @@ MAIN_BRANCH_NAME = "master"
|
|
|
18
18
|
PYTHON_VERSIONS = ["3.11", "3.12"]
|
|
19
19
|
PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-1]
|
|
20
20
|
DJANGO_VERSIONS = ["3.2", "4.2"]
|
|
21
|
+
CELERY_VERSIONS = ["5.3", "5.4", "5.5"]
|
|
21
22
|
DEMO_APP_DIR = ROOT / "demo"
|
|
22
23
|
|
|
23
24
|
nox.options.default_venv_backend = "venv"
|
|
@@ -152,9 +153,11 @@ def lint(session):
|
|
|
152
153
|
|
|
153
154
|
@nox.session(python=PYTHON_VERSIONS, tags=["test", "check"])
|
|
154
155
|
@nox.parametrize("django", DJANGO_VERSIONS)
|
|
155
|
-
|
|
156
|
+
@nox.parametrize("celery", CELERY_VERSIONS)
|
|
157
|
+
def test(session, django: str, celery: str):
|
|
156
158
|
install(session, "test", editable=True)
|
|
157
159
|
session.run("pip", "install", f"django~={django}.0")
|
|
160
|
+
session.run("pip", "install", f"celery~={celery}.0")
|
|
158
161
|
session.run("pytest", "-vv", "-n", "auto", *session.posargs)
|
|
159
162
|
|
|
160
163
|
|
|
@@ -22,7 +22,7 @@ dynamic = [
|
|
|
22
22
|
]
|
|
23
23
|
dependencies = [
|
|
24
24
|
"bittensor>=9.10.1",
|
|
25
|
-
"celery>=5.
|
|
25
|
+
"celery>=5.3",
|
|
26
26
|
"django>=3.2,<6.0",
|
|
27
27
|
"structlog>=25.4.0",
|
|
28
28
|
]
|
|
@@ -91,7 +91,7 @@ ignore = [
|
|
|
91
91
|
|
|
92
92
|
[tool.ruff.lint.per-file-ignores]
|
|
93
93
|
"__init__.py" = ["F401"]
|
|
94
|
-
"
|
|
94
|
+
"tests/**" = ["D", "ANN", "F403", "F405", "S101"]
|
|
95
95
|
|
|
96
96
|
[tool.codespell]
|
|
97
97
|
skip = "*.min.js,uv.lock"
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/_version.py
RENAMED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.0.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 0,
|
|
31
|
+
__version__ = version = '0.0.6'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 0, 6)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -134,24 +134,39 @@ def _celery_task_wrapper(
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
def block_task(
|
|
137
|
-
|
|
137
|
+
func: Callable[..., Any] | None = None,
|
|
138
|
+
*,
|
|
139
|
+
condition: Callable[..., bool] | None = None,
|
|
138
140
|
args: list[dict[str, Any]] | None = None,
|
|
139
141
|
backfilling_lookback: int | None = None,
|
|
140
142
|
celery_kwargs: dict[str, Any] | None = None,
|
|
141
143
|
) -> Callable[..., Any]:
|
|
142
144
|
"""
|
|
143
|
-
|
|
145
|
+
Decorator to register a function as a block task.
|
|
146
|
+
|
|
147
|
+
Block task is a function that will be executed conditionally on each new block.
|
|
148
|
+
The condition is a callable that takes the block number and any additional arguments,
|
|
149
|
+
and returns a boolean indicating whether to execute the task.
|
|
144
150
|
|
|
145
151
|
Args:
|
|
146
|
-
|
|
152
|
+
func: The function to decorate (used when decorator is applied without parentheses)
|
|
153
|
+
condition: Lambda function that determines when to execute the task. It should accept
|
|
154
|
+
block_number and any additional args as parameters and return a boolean.
|
|
155
|
+
Defaults to always True (run on every block).
|
|
147
156
|
args: List of argument dictionaries for multi-execution
|
|
148
157
|
backfilling_lookback: Number of blocks to backfill
|
|
149
158
|
celery_kwargs: Additional Celery task parameters
|
|
150
159
|
|
|
151
160
|
Examples:
|
|
152
|
-
@block_task
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
@block_task
|
|
162
|
+
def run_on_every_block(block_number: int):
|
|
163
|
+
pass
|
|
164
|
+
|
|
165
|
+
@block_task()
|
|
166
|
+
def also_runs_on_every_block(block_number: int):
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
@block_task(condition=lambda bn: bn % 100 == 0)
|
|
155
170
|
def simple_task(block_number: int):
|
|
156
171
|
pass
|
|
157
172
|
|
|
@@ -165,9 +180,11 @@ def block_task(
|
|
|
165
180
|
pass
|
|
166
181
|
|
|
167
182
|
"""
|
|
183
|
+
# Default condition: always run
|
|
184
|
+
effective_condition = condition if condition is not None else (lambda *_args, **_kwargs: True)
|
|
168
185
|
|
|
169
|
-
def decorator(
|
|
170
|
-
if not callable(
|
|
186
|
+
def decorator(fn: Callable[..., Any]) -> Any:
|
|
187
|
+
if not callable(effective_condition):
|
|
171
188
|
msg = "condition must be a callable."
|
|
172
189
|
raise TypeError(msg)
|
|
173
190
|
|
|
@@ -179,22 +196,22 @@ def block_task(
|
|
|
179
196
|
|
|
180
197
|
This entire wrapper becomes a Celery task.
|
|
181
198
|
"""
|
|
182
|
-
return _celery_task_wrapper(
|
|
199
|
+
return _celery_task_wrapper(fn, block_number, **kwargs)
|
|
183
200
|
|
|
184
201
|
# Wrap with celery shared_task
|
|
185
202
|
celery_task = shared_task(
|
|
186
|
-
name=abd_utils.get_executable_path(
|
|
203
|
+
name=abd_utils.get_executable_path(fn),
|
|
187
204
|
bind=False,
|
|
188
205
|
**celery_kwargs or {},
|
|
189
206
|
)(shared_celery_task)
|
|
190
207
|
|
|
191
208
|
# Store original function referefence for introspection
|
|
192
|
-
celery_task._original_func =
|
|
209
|
+
celery_task._original_func = fn # noqa: SLF001
|
|
193
210
|
|
|
194
211
|
# Register the Celery task
|
|
195
212
|
task_registry.register_item(
|
|
196
213
|
RegistryItem(
|
|
197
|
-
condition=
|
|
214
|
+
condition=effective_condition,
|
|
198
215
|
function=cast("Task", celery_task),
|
|
199
216
|
args=args,
|
|
200
217
|
backfilling_lookback=backfilling_lookback,
|
|
@@ -203,4 +220,9 @@ def block_task(
|
|
|
203
220
|
)
|
|
204
221
|
return celery_task
|
|
205
222
|
|
|
223
|
+
# If func is provided, decorator was used without parentheses: @block_task
|
|
224
|
+
if func is not None:
|
|
225
|
+
return decorator(func)
|
|
226
|
+
|
|
227
|
+
# Otherwise, decorator was used with parentheses: @block_task() or @block_task(condition=...)
|
|
206
228
|
return decorator
|
|
@@ -47,7 +47,7 @@ def test_task_execution_failure_and_retry():
|
|
|
47
47
|
executable_path=executable_path,
|
|
48
48
|
)
|
|
49
49
|
|
|
50
|
-
block_task(
|
|
50
|
+
block_task()(failing_task_func)
|
|
51
51
|
|
|
52
52
|
registry_item = task_registry.get_by_executable_path(task_attempt.executable_path)
|
|
53
53
|
assert registry_item is not None
|
|
@@ -68,7 +68,6 @@ def test_process_backfill():
|
|
|
68
68
|
backfill_amount = 10
|
|
69
69
|
|
|
70
70
|
block_task(
|
|
71
|
-
condition=lambda bn: True,
|
|
72
71
|
backfilling_lookback=backfill_amount,
|
|
73
72
|
)(backfill_task)
|
|
74
73
|
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/integration/test_scheduler.py
RENAMED
|
@@ -41,7 +41,7 @@ def test_task_failure_triggers_retry():
|
|
|
41
41
|
executable_path = abd_utils.get_executable_path(failing_task)
|
|
42
42
|
task_attempt, _ = abd_dal.task_create_or_get_pending(block_number, executable_path)
|
|
43
43
|
|
|
44
|
-
block_task(
|
|
44
|
+
block_task(failing_task)
|
|
45
45
|
|
|
46
46
|
registry_item = task_registry.get_by_executable_path(executable_path)
|
|
47
47
|
|
|
@@ -68,7 +68,7 @@ def test_successful_retry_completes_task() -> None:
|
|
|
68
68
|
executable_path = abd_utils.get_executable_path(flaky_function)
|
|
69
69
|
task_attempt, _ = abd_dal.task_create_or_get_pending(current_block, executable_path)
|
|
70
70
|
|
|
71
|
-
block_task(
|
|
71
|
+
block_task(flaky_function)
|
|
72
72
|
|
|
73
73
|
registry_item = task_registry.get_by_executable_path(executable_path)
|
|
74
74
|
assert registry_item is not None
|
|
@@ -90,7 +90,7 @@ def test_restry_schedules_celery_task_with_eta():
|
|
|
90
90
|
executable_path = abd_utils.get_executable_path(failing_task)
|
|
91
91
|
task_attempt, _ = abd_dal.task_create_or_get_pending(current_block, executable_path)
|
|
92
92
|
|
|
93
|
-
block_task(
|
|
93
|
+
block_task(failing_task)
|
|
94
94
|
|
|
95
95
|
registry_item = task_registry.get_by_executable_path(executable_path)
|
|
96
96
|
assert registry_item is not None
|
|
@@ -137,7 +137,7 @@ def test_retry_recover_mechanism():
|
|
|
137
137
|
size=batch_size, is_success=True, executable_path=executable_path, next_retry_at=past_time, attempt_count=1
|
|
138
138
|
)
|
|
139
139
|
|
|
140
|
-
block_task(
|
|
140
|
+
block_task(successful_task)
|
|
141
141
|
|
|
142
142
|
task_registry.get_by_executable_path(executable_path)
|
|
143
143
|
|
|
@@ -42,7 +42,7 @@ test = [
|
|
|
42
42
|
[package.metadata]
|
|
43
43
|
requires-dist = [
|
|
44
44
|
{ name = "bittensor", specifier = ">=9.10.1" },
|
|
45
|
-
{ name = "celery", specifier = ">=5.
|
|
45
|
+
{ name = "celery", specifier = ">=5.3" },
|
|
46
46
|
{ name = "django", specifier = ">=3.2,<6.0" },
|
|
47
47
|
{ name = "structlog", specifier = ">=25.4.0" },
|
|
48
48
|
]
|
|
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
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/admin.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/apps.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/models.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/tests.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/block_explorer/views.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/docker-compose.yml
RENAMED
|
File without changes
|
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/asgi.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/urls.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/example_project/example_project/wsgi.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/__init__.py
RENAMED
|
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
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/admin.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/apps.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/models.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/py.typed
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/v1/__init__.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/v1/celery.py
RENAMED
|
File without changes
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/src/abstract_block_dumper/v1/tasks.py
RENAMED
|
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
|
{abstract_block_dumper-0.0.4 → abstract_block_dumper-0.0.6}/tests/unit/test_celery_integration.py
RENAMED
|
File without changes
|
|
File without changes
|