Skip to content

Commit

Permalink
Merge pull request #10 from jluethi/2_tests_for_2d_to_3d
Browse files Browse the repository at this point in the history
Add coverage to CI
  • Loading branch information
jluethi authored Aug 8, 2024
2 parents e277acc + 4d5d203 commit 4fc3c85
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cache: "pip"

- name: Install package
run: python -m pip install .[dev,test]
run: python -m pip install -e .[dev,test]

- name: Install some testing dependencies (hard-coded)
run: python -m pip install pytest devtools jsonschema requests wget pooch
Expand All @@ -46,7 +46,7 @@ jobs:
run: pytest --color=yes --cov --cov-report=xml --cov-report=term-missing -s --log-cli-level debug

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
uses: codecov/codecov-action@v4.3.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: jluethi/fractal-helper-tasks
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# fractal-helper-tasks

[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](LICENSE)
![Python version](https://img.shields.io/badge/python-%3E%3D3.9-blue)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jluethi/fractal-helper-tasks/your-workflow-file.yml?branch=main)
[![codecov](https://codecov.io/gh/jluethi/fractal-helper-tasks/graph/badge.svg?token=ednmg2GzOw)](https://codecov.io/gh/jluethi/fractal-helper-tasks)

Collection of Fractal helper tasks

## Development instructions
Expand Down
12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ extend-ignore = [
"tests/*.py" = ["D", "S"]
"setup.py" = ["D"]

[tool.deptry]
exclude = [
'tests', 'examples'
[tool.coverage.run]
# Include only the specific package directories for coverage, exclude tests
include = [
"src/fractal_helper_tasks/*"
]
omit = [
"*/tests/*",
"*_test.py",
"setup.py"
]
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def zenodo_zarr(testdata_path: Path) -> list[str]:
f"{file_name}.zip", processor=pooch.Unzip(extract_dir=file_name)
)
zarr_full_path = file_paths[0].split(file_name)[0] + file_name
print(zarr_full_path)
folder = folders[ind]

# 2) Copy the downloaded Zarr into tests/data
Expand Down
15 changes: 12 additions & 3 deletions tests/test_convert_2d_to_3d_segmentation.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
"""Test copy 2D to 3D segmentation."""

import dask.array as da
import pytest
import zarr

from fractal_helper_tasks.convert_2D_segmentation_to_3D import (
convert_2D_segmentation_to_3D,
)


def test_2d_to_3d(tmp_zenodo_zarr: list[str]):
@pytest.mark.parametrize("new_label_name", [None, "nuclei_new"])
def test_2d_to_3d(tmp_zenodo_zarr: list[str], new_label_name):
zarr_url = f"{tmp_zenodo_zarr[1]}/B/03/0"
label_name = "nuclei"

convert_2D_segmentation_to_3D(
zarr_url=zarr_url,
label_name=label_name,
new_label_name=new_label_name,
)
zarr_3D_label_url = f"{tmp_zenodo_zarr[0]}/B/03/0/labels/{label_name}"

if not new_label_name:
new_label_name = label_name

zarr_3D_label_url = f"{tmp_zenodo_zarr[0]}/B/03/0/labels/{new_label_name}"
# Check that the label has been copied correctly
with zarr.open(zarr_3D_label_url, mode="rw+") as zarr_img:
zarr_3D = da.from_zarr(zarr_img[0])
Expand All @@ -25,7 +32,9 @@ def test_2d_to_3d(tmp_zenodo_zarr: list[str]):

# TODO: Add custom ROI tables to be copied to 3D

# TODO: Add test with new label name, new table names
# TODO: Add a feature table & have it copied over

# TODO: Add test with new table names

# TODO: Create a version of the test data where image suffixes need to be
# changed, run tests on those

0 comments on commit 4fc3c85

Please sign in to comment.