9a916c65a5
任务书 01 遗留修复(C14): - library 新增 check_key_image(path):关键图能逐像素保真重编码时返回 None,否则返回原因; _write_clean_png 的判断移过去,自身保留断言性质报错(走到这里说明 build 漏了检查)。 - build 写库前对每例调用,返回原因的整例跳过,记 C14「关键图能原样重编码」,涉及值写原因。 - 原来三条「关键图格式不对整次构建停下」的测试改为整例跳过,另加非 PNG、library 漏检报错两条。 - 结构.md 第八部分、guides/装配两个库.md 相应几行改掉。 第一阶段(src/cadx/ceus/): - 照搬旧 geometry、video_decoder、research_config、split_screen、green_prompt、prompt_frames、 mapping,去掉产品层,注释改中文。 - 配置类去掉全部默认值,strict、extra=forbid、frozen;新建 config/ceus.yaml(paths、ceus 两段), 数值照抄旧 yaml,逐项注明出处。删去 source_view/target_view、effective_region、mapping 锚点; 旧代码写死的分屏抽帧数 25 和搜索区间 (0.35, 0.65) 改成配置,值不变。 - 视频解码改为按路径用 cv2 逐帧读。 - 坐标换算改为两个视图矩形左上角之差,不再用按某种宽度写死的锚点。 - 造影画面在哪一半:两半各自选提示帧,恰好一半有才定,否则抛 ContrastSideError(CeusCaseError 子类,带步号和原因,供第三阶段记 failed.csv)。 - 旧测试照搬(改 import 与配置读取方式),因上述改动不再成立的删去;新增两处修改的手算测试。 - import-linter 加「ceus 不引用其他 cadx 模块」。依赖加 numpy、opencv-python-headless。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
130 lines
4.3 KiB
TOML
130 lines
4.3 KiB
TOML
[project]
|
||
name = "cadx"
|
||
version = "0.0.0"
|
||
description = "胰腺囊性肿瘤多模态会诊诊断的研究代码"
|
||
requires-python = ">=3.12"
|
||
dependencies = [
|
||
"numpy>=2.5.4",
|
||
"opencv-python-headless>=5.0.0.93",
|
||
"openpyxl>=3.1.5",
|
||
"pillow>=12.3.0",
|
||
"pydantic>=2.14.1",
|
||
"pyyaml>=6.0.3",
|
||
]
|
||
|
||
[dependency-groups]
|
||
dev = [
|
||
"ruff>=0.6",
|
||
"pyright>=1.1.380",
|
||
"pytest>=8.3",
|
||
"import-linter>=2.1",
|
||
"pre-commit>=4.0",
|
||
"types-pyyaml>=6.0.12.20260906",
|
||
"types-openpyxl>=3.1.5.20260827",
|
||
]
|
||
|
||
[build-system]
|
||
requires = ["hatchling>=1.26"]
|
||
build-backend = "hatchling.build"
|
||
|
||
[tool.hatch.build.targets.wheel]
|
||
packages = ["src/cadx"]
|
||
|
||
[tool.ruff]
|
||
line-length = 100
|
||
target-version = "py312"
|
||
src = ["src", "tests", "scripts"]
|
||
extend-exclude = ["research-wiki", "reference", "reference-pdf", "runs", "data"]
|
||
|
||
[tool.ruff.lint]
|
||
select = ["E", "W", "F", "I", "UP", "B", "BLE", "S", "SIM", "RUF"]
|
||
# 允许注释和文档字符串里的中文全角标点。
|
||
ignore = ["RUF001", "RUF002", "RUF003"]
|
||
|
||
[tool.ruff.lint.per-file-ignores]
|
||
"tests/**" = ["S101"]
|
||
|
||
[tool.pyright]
|
||
include = ["src", "tests", "scripts"]
|
||
pythonVersion = "3.12"
|
||
typeCheckingMode = "strict"
|
||
venvPath = "."
|
||
venv = ".venv"
|
||
extraPaths = ["tests"]
|
||
|
||
[tool.pytest.ini_options]
|
||
testpaths = ["tests"]
|
||
# 测试辅助(假交付包生成器)放在 tests/ 下,按普通模块导入。
|
||
pythonpath = ["tests"]
|
||
addopts = "--strict-markers --import-mode=importlib"
|
||
markers = [
|
||
"live: 真实模型调用,花钱,需要 .env 里的密钥",
|
||
"gpu: 需要 CUDA 显卡(MedSAM2 分割)",
|
||
]
|
||
|
||
# 导入边界。改契约先改 research-wiki/explanation/结构.md,再改这里;
|
||
# 不靠 ignore_imports 让违规通过。规划中的契约见结构.md 第五部分,模块落地时随任务书加入。
|
||
[tool.importlinter]
|
||
root_packages = ["cadx"]
|
||
include_external_packages = true
|
||
|
||
[[tool.importlinter.contracts]]
|
||
# design 0001:torch 与 MedSAM2 只许出现在分割模块(模块落地时在这里放行 cadx.segment)。
|
||
name = "torch 与 sam2 不进 cadx"
|
||
type = "forbidden"
|
||
source_modules = ["cadx"]
|
||
forbidden_modules = ["torch", "sam2"]
|
||
|
||
[[tool.importlinter.contracts]]
|
||
# 结构.md 第三部分依赖表:外部层与格式层的模块不依赖其他 cadx 模块。
|
||
name = "delivery、library、answers、runs 互不依赖"
|
||
type = "independence"
|
||
modules = ["cadx.delivery", "cadx.library", "cadx.answers", "cadx.runs"]
|
||
|
||
[[tool.importlinter.contracts]]
|
||
# 同上,依赖表的另一半:它们也不引用上层和其余规划中的模块(独立契约只管它们之间)。
|
||
name = "delivery、library、answers、runs 不引用其他 cadx 模块"
|
||
type = "forbidden"
|
||
source_modules = ["cadx.delivery", "cadx.library", "cadx.answers", "cadx.runs"]
|
||
forbidden_modules = [
|
||
"cadx.build", "cadx.ceus", "cadx.segment", "cadx.llm", "cadx.ledger",
|
||
"cadx.consult", "cadx.evaluate", "cadx.verdicts",
|
||
]
|
||
|
||
[[tool.importlinter.contracts]]
|
||
# 结构.md 第三部分依赖表:ceus 是纯计算,不引用其他 cadx 模块(含 segment,分割结果由脚本传进来)。
|
||
name = "ceus 不引用其他 cadx 模块"
|
||
type = "forbidden"
|
||
source_modules = ["cadx.ceus"]
|
||
forbidden_modules = [
|
||
"cadx.delivery", "cadx.library", "cadx.answers", "cadx.runs", "cadx.build",
|
||
"cadx.segment", "cadx.llm", "cadx.ledger", "cadx.consult", "cadx.evaluate", "cadx.verdicts",
|
||
]
|
||
|
||
[[tool.importlinter.contracts]]
|
||
# 结构.md 第三部分依赖表:build 只依赖 delivery、library、answers、runs(ceus 落地时加入)。
|
||
name = "build 只引用 delivery、library、answers、runs"
|
||
type = "forbidden"
|
||
source_modules = ["cadx.build"]
|
||
forbidden_modules = [
|
||
"cadx.ceus", "cadx.segment", "cadx.llm", "cadx.ledger",
|
||
"cadx.consult", "cadx.evaluate", "cadx.verdicts",
|
||
]
|
||
allow_indirect_imports = true
|
||
|
||
[[tool.importlinter.contracts]]
|
||
# 结构.md 第五部分:交付包的 Excel 只有 delivery 碰。
|
||
name = "只有 delivery 引用 openpyxl"
|
||
type = "forbidden"
|
||
source_modules = ["cadx.library", "cadx.answers", "cadx.runs", "cadx.build"]
|
||
forbidden_modules = ["openpyxl"]
|
||
allow_indirect_imports = true
|
||
|
||
[[tool.importlinter.contracts]]
|
||
# 结构.md 第五部分:写资料库的图片(去掉元数据)只有 library 碰。
|
||
name = "只有 library 引用 PIL"
|
||
type = "forbidden"
|
||
source_modules = ["cadx.delivery", "cadx.answers", "cadx.runs", "cadx.build"]
|
||
forbidden_modules = ["PIL"]
|
||
allow_indirect_imports = true
|