初始提交:chongming-task 任务控制库
单任务受控执行(15 态状态机 + 审计轨迹)、DAG 管道、Controller 门面。
执行器三个:线程(默认,含 async def 任务)、内联(同步 / 测试)、进程
(spawn 子进程:硬性停止、绕开 GIL、崩溃隔离)。
调度:并发额度 + 每桶限流 + 具名资源信号量(按标签)+ 优先级排队。
持久层:TaskStore 契约 + 内存 / SQLite / Postgres 实现,契约测试随包发布。
跨进程与多节点:写穿 / 读穿、指令通道与租约、owned_buckets 划界、reconcile。
CLI、12 个可直接运行的示例、docs/ 下 5 份文档。
门禁:ruff / ruff format / mypy(strict) 干净;
pytest 563 passed(44 skipped 是需要真实 Postgres 的那批);
带一台可连的 Postgres 时 607 passed。
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
[build-system]
|
||||
build-backend = "hatchling.build"
|
||||
requires = ["hatchling"]
|
||||
|
||||
[project]
|
||||
dependencies = []
|
||||
description = "精细化状态控制的 Python 管道任务控制工具"
|
||||
name = "chongming-task"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
version = "0.1.0"
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: 3.14",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
chongming-task = "chongming_task.cli.main:main"
|
||||
|
||||
[project.optional-dependencies]
|
||||
postgres = [
|
||||
"psycopg-pool>=3.2",
|
||||
"psycopg[binary]>=3.2",
|
||||
]
|
||||
|
||||
# 核心包运行时零第三方依赖(CLI 也只用标准库 argparse)。
|
||||
# 观测后端等适配器在各自阶段追加为 [project.optional-dependencies]。
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"pytest>=8.0",
|
||||
"hypothesis>=6.100",
|
||||
"ruff>=0.6",
|
||||
"mypy>=1.11",
|
||||
"psycopg[binary]>=3.2",
|
||||
"psycopg-pool>=3.2",
|
||||
]
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/chongming_task"]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 工具链
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 100
|
||||
target-version = "py311"
|
||||
src = ["src", "tests"]
|
||||
# pytest 的临时目录默认落在项目根下,测试往里写的临时 .py 文件不该被 lint 扫到
|
||||
# (其中不乏**故意写坏**的样本,例如"导入一个不存在的依赖")。
|
||||
extend-exclude = ["pytest-of-*"]
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "I", "UP", "B", "SIM", "RUF", "C4", "PTH"]
|
||||
ignore = [
|
||||
"RUF001", # 允许注释/字符串中的中文全角标点
|
||||
"RUF002",
|
||||
"RUF003",
|
||||
]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"tests/**" = ["B011"]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
known-first-party = ["chongming_task"]
|
||||
|
||||
# 内核必须保持可被状态机属性测试穷举验证的纯粹性,故 src 全量 strict。
|
||||
[tool.mypy]
|
||||
python_version = "3.11"
|
||||
strict = true
|
||||
warn_unreachable = true
|
||||
warn_redundant_casts = true
|
||||
show_error_codes = true
|
||||
files = ["src"]
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = "tests.*"
|
||||
disallow_untyped_defs = false
|
||||
disallow_incomplete_defs = false
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
addopts = "-ra --strict-markers --strict-config"
|
||||
markers = [
|
||||
"slow: 耗时较长的集成测试",
|
||||
"windows_only: 仅在 Windows 上有意义的用例",
|
||||
"posix_only: 仅在 POSIX 上有意义的用例",
|
||||
]
|
||||
filterwarnings = ["error"]
|
||||
Reference in New Issue
Block a user