File size: 4,580 Bytes
4eeba46
 
 
fa1717e
4eeba46
0cec63f
4eeba46
 
 
 
 
 
 
0cec63f
4eeba46
 
 
 
 
 
 
ba32591
 
4eeba46
 
 
 
a544a50
4eeba46
 
 
 
 
66404dc
 
 
 
 
 
 
 
 
 
 
 
 
a544a50
d77e99f
227ab66
4eeba46
 
3f8bf9c
 
 
4eeba46
 
 
 
 
4994e68
4eeba46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227ab66
 
 
4eeba46
 
 
 
 
 
 
 
227ab66
 
4eeba46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227ab66
 
4eeba46
 
 
 
 
227ab66
4eeba46
 
3c4c67b
518063b
3c4c67b
66404dc
 
 
 
 
a544a50
 
4eeba46
 
 
 
 
 
 
 
 
 
 
aef1f5a
4eeba46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
[project]
name = "stroke-deepisles-demo"
version = "0.1.0"
description = "Demo: HF datasets + DeepISLES stroke segmentation + React SPA + FastAPI backend"
readme = "README.md"
license = { text = "Apache-2.0" }
requires-python = ">=3.11"
authors = [
    { name = "stroke-deepisles-demo contributors" }
]
classifiers = [
    "Development Status :: 3 - Alpha",
    "Intended Audience :: Science/Research",
    "License :: OSI Approved :: Apache Software License",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Topic :: Scientific/Engineering :: Medical Science Apps.",
]
keywords = ["stroke", "neuroimaging", "segmentation", "BIDS", "NIfTI", "deep-learning"]

dependencies = [
    # Core - BIDS + NIfTI lazy loading (maintained fork)
    "neuroimaging-go-brrrr @ git+https://github.com/The-Obstacle-Is-The-Way/[email protected]",
    "huggingface-hub>=0.25.0",

    # NIfTI handling
    "nibabel>=5.2.0",
    "numpy>=1.26.0,<2.0.0",

    # Configuration
    "pydantic>=2.5.0",
    "pydantic-settings>=2.1.0",

    # Networking
    "requests>=2.0.0",
]

[project.optional-dependencies]
# API server (FastAPI backend for HF Spaces Docker deployment)
api = [
    "fastapi>=0.115.0",
    "uvicorn[standard]>=0.32.0",
]

# Legacy Gradio UI (being replaced by React frontend)
gradio = [
    "gradio>=6.0.0,<7.0.0",
    "matplotlib>=3.8.0",
    "gradio_niivueviewer",
]

[project.scripts]
stroke-demo = "stroke_deepisles_demo.cli:main"

[dependency-groups]
dev = [
    "pytest>=8.0.0",
    "pytest-cov>=4.1.0",
    "pytest-mock>=3.12.0",
    "pytest-timeout>=2.3.0",
    "mypy>=1.19.0",
    "ruff>=0.14.0",
    "pre-commit>=3.6.0",
    # Type stubs
    "types-requests",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/stroke_deepisles_demo"]

[tool.uv.sources]
gradio_niivueviewer = { path = "packages/niivueviewer", editable = true }

# ─────────────────────────────────────────────────────────────────
# Tool configurations
# ─────────────────────────────────────────────────────────────────

[tool.ruff]
target-version = "py312"
line-length = 100
src = ["src", "tests"]
# Exclude auto-generated files from Gradio custom component
exclude = ["packages/niivueviewer/demo/space.py"]

[tool.ruff.lint]
select = [
    "E",      # pycodestyle errors
    "W",      # pycodestyle warnings
    "F",      # pyflakes
    "I",      # isort
    "B",      # flake8-bugbear
    "C4",     # flake8-comprehensions
    "UP",     # pyupgrade
    "ARG",    # flake8-unused-arguments
    "SIM",    # flake8-simplify
    "TCH",    # flake8-type-checking
    "PTH",    # flake8-use-pathlib
    "RUF",    # ruff-specific
]
ignore = [
    "E501",   # line too long (handled by formatter)
]

[tool.ruff.lint.isort]
known-first-party = ["stroke_deepisles_demo"]

[tool.mypy]
python_version = "3.12"
strict = true
warn_return_any = true
warn_unused_ignores = true
disallow_untyped_defs = true
plugins = ["pydantic.mypy"]
# Exclude auto-generated Gradio custom component demo files
exclude = "packages/niivueviewer/"

[[tool.mypy.overrides]]
module = [
    "nibabel.*",
    "gradio.*",
    "gradio_niivueviewer.*",
    "datasets.*",
    "niivue.*",
    "numpy.*",
    "pyarrow.*",
    "pytest.*",
    # FastAPI route decorators cause "untyped decorator" errors in strict mode
    # See: https://github.com/tiangolo/fastapi/discussions/7463
    "fastapi.*",
    "starlette.*",
    "uvicorn.*",
    # DeepISLES modules (only available in DeepISLES Docker image)
    "src.isles22_ensemble",
]
ignore_missing_imports = true

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_functions = ["test_*"]
addopts = [
    "-v",
    "--tb=short",
    "--strict-markers",
    "-m", "not integration",  # Skip integration tests by default
]
markers = [
    "integration: marks tests requiring external resources (Docker, network)",
    "slow: marks tests that take >10s to run",
]
filterwarnings = [
    "ignore::DeprecationWarning",
]

[tool.coverage.run]
source = ["src/stroke_deepisles_demo"]
branch = true

[tool.coverage.report]
exclude_lines = [
    "pragma: no cover",
    "if TYPE_CHECKING:",
    "raise NotImplementedError",
]