Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ee4a532
test: curate coverage omit for un-testable vendored/dead code
Hendrik-code Jun 30, 2026
56daf13
test: cover bids_files.py via in-memory BIDS dataset (38%->96%)
Hendrik-code Jun 30, 2026
e49abcf
test: cover nii_wrapper math mixin + wrapper ops (math 100%, wrapper …
Hendrik-code Jun 30, 2026
7fc43c7
test: cover spine/spinestats + snapshot_modular (->93%)
Hendrik-code Jun 30, 2026
5cf83e4
test: cover poi_fun save_load + ray_casting (both ->94%)
Hendrik-code Jun 30, 2026
b0d08a2
test: cover core/dicom via generated DICOM series round-trip (0%->70%)
Hendrik-code Jun 30, 2026
59ffa8c
test: cover sitk_utils + point_registration + deepali wrappers (->81%)
Hendrik-code Jun 30, 2026
65d04c5
test: MagicMock GPU segmentation + deface wrappers (->93%)
Hendrik-code Jun 30, 2026
ddd3dca
test: cover logger + stitching; push np_utils to 99% (->84%)
Hendrik-code Jun 30, 2026
03597d0
ci: add build-full-coverage job with heavy deps (CPU) for Codecov
Hendrik-code Jun 30, 2026
3bac33f
test: gate real-model segmentation tests behind opt-in env var
Hendrik-code Jun 30, 2026
dd2153e
fix(logger): write log files as UTF-8 (locale-independent)
Hendrik-code Jun 30, 2026
3537df5
address robsy
Hendrik-code Jul 2, 2026
54b0f6b
fix
Hendrik-code Jul 2, 2026
8ad3451
fix
Hendrik-code Jul 2, 2026
4961277
testcase torch dependancy
Hendrik-code Jul 2, 2026
1af165f
added dicom2nifti to dev dep
Hendrik-code Jul 2, 2026
9ba6a13
fixed workflow test
Hendrik-code Jul 2, 2026
19748ba
fixed workflow test
Hendrik-code Jul 2, 2026
83f7f4c
fixed workflow test
Hendrik-code Jul 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
python -m pip install flake8 pytest
- name: Install dependancies
run: |
python -m poetry install
python -m poetry install --with dev
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -46,3 +46,36 @@ jobs:
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

build-full-coverage:
# Authoritative coverage job: installs the heavy optional deps (CPU-only) so
# the segmentation / registration / dicom / mocked-GPU tests actually run and
# count towards Codecov. The light `build` matrix above stays fast and skips them.
runs-on: ubuntu-latest
Comment thread
Hendrik-code marked this conversation as resolved.
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Configure python
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Install dependancies
run: |
python -m poetry install --with dev
- name: Install heavy optional deps (CPU)
run: |
python -m poetry run pip install torch --index-url https://download.pytorch.org/whl/cpu
python -m poetry run pip install antspyx pydicom numpy-stl nnunetv2 deepali spineps
- name: Test with pytest and create coverage report
run: |
python -m poetry run coverage run --source=TPTBox -m pytest unit_tests/ --ignore=unit_tests/test_auto_segmentation.py
python -m poetry run coverage xml
- name: Upload coverage results to Codecov (Only on merge to main)
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: full
6 changes: 3 additions & 3 deletions .github/workflows/tests_mr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
pip install -e .
python -m pip install poetry flake8 pytest
python -m poetry install --with dev
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -35,4 +35,4 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
python -m poetry run pytest
4 changes: 3 additions & 1 deletion TPTBox/logger/log_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ def __init__(
if not Path.exists(log_path):
Path.mkdir(log_path)
# Open log file
self.f = open(log_path.joinpath(log_filename_full), "w") # noqa: SIM115
# encoding="utf-8" so non-ASCII log content (e.g. the "±" from
# print_statistic) cannot raise UnicodeEncodeError under a C/ASCII locale.
self.f = open(log_path.joinpath(log_filename_full), "w", encoding="utf-8") # noqa: SIM115
# calls close() if program terminates
self._finalizer = weakref.finalize(self.f, self.close)
self.default_verbose = default_verbose
Expand Down
33 changes: 32 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ coverage = ">=7.0.1"
pytest-mock = "^3.6.0"
exceptiongroup = { version = "^1.2", python = "<3.11" }
tomli = {version = "*", python = "<3.11" }
dicom2nifti = "*"

[tool.poetry.group.docs.dependencies]
mkdocs = ">=1.6"
Expand Down Expand Up @@ -240,7 +241,37 @@ exclude_lines = [
"raise "
]
omit = [
"TPTBox/test/speedtest/*",
"TPTBox/tests/speedtests/*",
# --- Vendored nnU-Net internals: mocked around in unit tests, never executed ---
"TPTBox/segmentation/nnUnet_utils/predictor.py",
"TPTBox/segmentation/nnUnet_utils/plans_handler.py",
"TPTBox/segmentation/nnUnet_utils/export_prediction.py",
"TPTBox/segmentation/nnUnet_utils/default_preprocessor.py",
"TPTBox/segmentation/nnUnet_utils/data_iterators.py",
"TPTBox/segmentation/nnUnet_utils/get_network_from_plans.py",
"TPTBox/segmentation/nnUnet_utils/sliding_window_prediction.py",
# --- Vendored deepali optimization internals ---
"TPTBox/registration/_deformable/_deepali/deform_reg_pair.py",
"TPTBox/registration/_deformable/_deepali/registration_losses.py",
"TPTBox/registration/_deformable/_deepali/engine.py",
"TPTBox/registration/_deformable/_deepali/metrics.py",
"TPTBox/registration/_deformable/_deepali/hooks.py",
"TPTBox/registration/_deformable/_deepali/optim.py",
"TPTBox/registration/ridged_intensity/affine_deepali.py",
"TPTBox/registration/_ridged_intensity/affine_deepali.py",
"TPTBox/registration/_deepali/spine_rigid_elements_reg.py",
# --- 3D rendering: requires vedo (not a core dependency) ---
"TPTBox/mesh3D/snapshot3D.py",
"TPTBox/mesh3D/mesh.py",
"TPTBox/mesh3D/html_preview.py",
# --- Import-broken / missing optional dep (nipy) / stale scripts ---
"TPTBox/registration/_deformable/grid_search.py",
"TPTBox/registration/_deformable/_grid_search_vert.py",
"TPTBox/registration/script_ax2sag.py",
"TPTBox/registration/_ridged_intensity/register.py",
# --- Dead / unused ---
"TPTBox/registration/_deformable/deformable_reg_old.py",
"TPTBox/core/internal/elastic_deform.py",
]
[tool.ruff.format]
# Like Black, use double quotes for strings.
Expand Down
133 changes: 0 additions & 133 deletions unit_tests/test_auto_segmentation.py

This file was deleted.

Loading
Loading