基于Django的监控huey任务队列的工具:https://github.com/coleifer/huey
项目描述
django-huey-monitor
基于Django的监控huey任务队列的工具
当前实现将仅将所有Huey任务信号存储到数据库中,并在Django管理界面中显示。
快速入门
pip install django-huey-monitor
INSTALLED_APPS = [
#...
'bx_django_utils', # https://github.com/boxine/bx_django_utils
'huey_monitor',
#...
]
注意:通常您不应该更改Huey任务。
收集主/子任务
Huey监控模型可以存储关于任务层次结构的信息。但此信息不能自动收集。您必须将这些信息存储在任务代码中。
例如。
@task(context=True)
def sub_task(task, parent_task_id, chunk_data):
# Save the task hierarchy by:
TaskModel.objects.set_parent_task(
main_task_id=parent_task_id,
sub_task_id=task.id,
)
# ... do something with e.g.: chunk_data ...
@task(context=True)
def main_task(task):
for chunk_data in something:
sub_task(parent_task_id=task.id, chunk_data=chunk_data)
工作示例可以在以下test app中找到: huey_monitor_tests/test_app/tasks.py
收集进度信息
正在运行的任务可以像tqdm一样存储进度信息。因此,可以在管理界面中看到进度。
最小示例
@task(context=True)
def foobar_task(task, list_to_process):
process_info = ProcessInfo(
task,
desc='A description of this Job',
total=len(list_to_process)
)
for item in list_to_process:
# ...to something with the {item}...
process_info.update(n=1) # add the information that one item was processed
也可以将工作分成几个任务,并收集主/子任务的处理信息。
工作示例可以在以下test app中找到: huey_monitor_tests/test_app/tasks.py
设置
覆盖列表过滤器(可选)
可以通过设置覆盖SignalInfoModelAdmin
和TaskModelAdmin
的list_filter
。例如:
HUEY_MONITOR_SIGNAL_INFO_MODEL_LIST_FILTER = ('task__name', 'signal_name')
HUEY_MONITOR_TASK_MODEL_LIST_FILTER = ('name', 'state__signal_name')
注意:这两个设置都是可选的。在这个示例中,“hostname”过滤器不存在;)
运行测试项目
注意:您可以使用测试项目快速测试Huey Monitor,例如
~/django-huey-monitor$ ./manage.sh run_testserver
或者在隔离的Docker容器中
~/django-huey-monitor$ make up
更多信息请见下文。
屏幕截图
(更多截图:boxine.github.io/django-huey-monitor/)
2021-02-22-v030-task-details.png
2021-02-22-v030-progress-info1.png
开发中
- 安装Docker
- 克隆项目
- 启动容器
要开始开发,例如:
~$ git clone https://github.com/boxine/django-huey-monitor.git
~$ cd django-huey-monitor
~/django-huey-monitor$ ./manage.py
~/django-huey-monitor$ make help
~/django-huey-monitor$ make up
将我们的浏览器指向:http://localhost:8000/
我们的Makefile包含以下目标
help List all commands
install install huey monitor package
update Update the dependencies as according to the pyproject.toml file
run-dev-server Run Django's developer server
test Run unittests
tox Run unittests via tox
makemessages Make and compile locales message files
clean Remove created files from the test project (e.g.: SQlite, static files)
build Update/Build docker services
up Start docker containers
down Stop all containers
shell-django go into a interactive bash shell in Django container
run-shell-django Build and start the Django container and go into shell
shell-huey1 go into a interactive bash shell in Huey worker container 1
shell-huey2 go into a interactive bash shell in Huey worker container 2
shell-huey3 go into a interactive bash shell in Huey worker container 3
shell-redis go into a interactive bash shell in Redis container
logs Display and follow docker logs
logs-django Display and follow docker logs only from "django" container
reload-django Reload the Django dev server
reload-huey Reload the Huey worker
restart Restart the containers
fire-test-tasks Call "fire-test-tasks" manage command to create some Huey Tasks
fire-many-test-tasks Call "fire-test-tasks" with --count 10000 to create many task entries ;)
fire-parallel-processing-task Just fire "parallel processing" Huey Task
delete-all-tasks-data Delete all Task/Signal database enties
也可以使用SQLite和Huey立即设置运行测试设置,无需Docker
~$ git clone https://github.com/boxine/django-huey-monitor.git
~$ cd django-huey-monitor
~/django-huey-monitor$ ./manage.py run_dev_server
不兼容的更改
版本兼容性
Huey Monitor | Django | Python |
---|---|---|
>v0.7.0 | v3.2, v4.1, v4.2 | v3.9, v3.10, v3.11 |
>v0.6.0 | v3.2, v4.0, v4.1 | v3.9, v3.10, v3.11 |
>v0.5.0 | v2.2, v3.1, v3.2 | v3.7, v3.8, v3.9 |
<=v0.4.0 | v2.2, v3.0, v3.1 | v3.7, v3.8, v3.9 |
v0.6.0
我们重构了项目设置:开发者必须重新初始化存储库。
v0.5.0
更改CI并删除对Django 3.0的测试,但添加Django v3.2的测试运行
v0.3.0 -> v0.4.0 - Django相关内容的外包
bx_py_utils已拆分,并将与Django相关的部分移动到:bx_django_utils
您必须更改Django设置并替换应用程序名称
INSTALLED_APPS = [
#...
- 'bx_py_utils',
+ 'bx_django_utils',
'huey_monitor',
#...
]
历史记录
- dev
- tbc
- v0.9.0 - 22.12.2023
- 修复#135 DisallowedModelAdminLookup
- 添加“线程”名称作为更改列表过滤器。
- 增强测试项目设置
- 应用manageprojects更新
- 删除Python v3.9支持
- 将Django v5.0添加到测试矩阵并删除Django 4.1
- 启用本地AUTOLOGIN作为默认值
- 使用unittest "load_tests Protocol"并拒绝测试中的任何请求
- 添加https://github.com/PyCQA/flake8-bugbear
- 更新需求
- v0.8.1 - 20.11.2023
- 修复admin中的
ZeroDivisionError
错误
- 修复admin中的
- v0.8.0 - 20.11.2023
- 使通过设置覆盖
SignalInfoModelAdmin
和TaskModelAdmin
的list_filter
成为可能 - 更新本地Docker开发设置
- 使通过设置覆盖
- v0.7.1 - 18.08.2023
- 修复#127:获取HUEY计数时的错误
- v0.7.0 - 09.08.2023
- 新功能:在管理界面中显示Huey挂起/计划/结果任务计数
- 切换到git
main
分支 - 从
pytest
切换到正常的unittests
- 从
poetry
切换到pip-tools
- 使用https://github.com/jedie/manage_django_project进行开发
- 通过删除Django 4.0并添加4.2来扩展测试矩阵
- 增强tox配置
- v0.6.0 - 09.01.2023
- 测试Django v3.2、v4.0、v4.1和Python v3.9 - v3.11
- 优化管理更改列表(《由henribru提供》)
- 在管理界面中按时间顺序排列子任务(《由Skrattoune提供》)
- 显示parent_tasks的进度(《由Skrattoune提供》)
- 将
set_parent_task
委派给ProcessInfo.__init__
(由 Skrattoune 贡献[链接]) - 修复 #27 自动裁剪过长的进程信息描述
- 新增 #102 通过更改列表对象工具链接解锁所有任务
- 修复 #81 扩展
TaskModel.desc
最大长度并使SignalInfoModel.exception_line
可选 - 更新 Docker 测试设置
- v0.5.0 - 2022.02.10
- 重构模型:删除
TaskProgressModel
并将进度信息存储到TaskModel
- 重构模型:删除
- v0.4.6 - 2022.02.03
- 在 TaskAdmin 中显示任务描述或名称(由 Skrattoune 贡献[链接])
- 更新需求
- 使用 Darker 作为代码格式化工具
- 通过 PyTest 插件检查代码风格
- v0.4.5 - 2022.01.28
- v0.4.4 - 2022.01.07
- 添加缺失的
huey_monitor.css
文件
- 添加缺失的
- v0.4.3 - 2022.01.07
- 将临时的
cumulate2parents
标志添加到ProcessInfo
(由 formacube 贡献[链接])
- 将临时的
- v0.4.2 - 2020.08.25
- 抑制 Django 3.2+ 中的默认_app_config 属性(由 Jonas Svarvaa 贡献[链接])
- v0.4.1 - 2020.06.02
- 修复
ProcessInfo.__str__()
的错误 - #27 检查
ProcessInfo
中的 'desc' 长度 - 删除针对 Django 3.0 的测试并添加 Django 3.2 的测试
- 修复本地
tox
运行并使用不同的 Python 版本
- 修复
- v0.4.0 - 2020.05.21
- 将 bx_py_utils 分离,并将与 Django 相关的内容移动到:https://github.com/boxine/bx_django_utils
- v0.3.0 - 2020.02.22
- v0.2.0 - 2020.02.17
- 存储主/子任务的 "parent_task" 信息
- v0.1.0 - 2020.12.21
- 处理 Huey 工作进程死亡的情况
- 修复测试项目中 bx_py_utils 中缺失的翻译
- 通过 docker 和测试项目模拟 Huey 工作进程集群
- v0.0.1 - 2021.12.15
- 首次发布
许可证
GPL. 欢迎补丁!
链接
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。
源分布
构建版本
django-huey-monitor-0.9.0.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 03366d98579c07e132672aa760373949fecec108a0e91229e870bb21453c800b |
|
MD5 | 501d4839cb67dc492cf8b1f8d9fb1a54 |
|
BLAKE2b-256 | 6b58b51530283c18dcacda793fbb110ceeb051f7e16fc6c786d2ece1cd1d0aa9 |
django_huey_monitor-0.9.0-py3-none-any.whl 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1d5922d182e138e288f99d6cdb326cbed20c831d4c906c96cba148b0979e648a |
|
MD5 | 263d8af00a7cbd9cb7819326bb3f3f19 |
|
BLAKE2b-256 | fe2d9203527bc703cb15d5934ece6d304869b5cc6c0737eb91920aece893bcd2 |