Skip to content

Commit 759e96c

Browse files
committed
Merge branch 'main' into add_image_normalization
2 parents ea3d98d + 973647c commit 759e96c

File tree

21 files changed

+651
-165
lines changed

21 files changed

+651
-165
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
scportrait_data
2121
)
2222
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: v0.15.0
23+
rev: v0.15.2
2424
hooks:
2525
- id: ruff
2626
args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes]
@@ -39,7 +39,7 @@ repos:
3939
rev: v1.19.1
4040
hooks:
4141
- id: mypy
42-
args: [--no-strict-optional, --ignore-missing-imports]
42+
args: [--python-version=3.10, --no-strict-optional, --ignore-missing-imports]
4343
additional_dependencies:
4444
["types-requests", "types-attrs", "types-PyYAML"]
4545
- repo: local

docs/CONTRIBUTING.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ The docs for scPortrait are updated and built automatically whenever code is mer
214214
make clean
215215
make html
216216
```
217-
4. open the file `scportriat/docs/_build/html/index.html` in your favorite browser
217+
4. open the file `scportrait/docs/_build/html/index.html` in your favorite browser
218218

219219
## Writing Tests
220220

@@ -246,11 +246,40 @@ pytest tests/unit_tests --disable-warnings
246246
E2E tests run larger workflow scenarios to ensure that multiple components of the pipeline work correctly together (e.g., segmentation → extraction → featurization → selection).
247247
These tests are **much slower** and may require larger example data.
248248

249+
If an E2E test depends on remotely downloaded data/config files, it must be annotated with `@pytest.mark.requires_dataset(...)`.
250+
This is required because scPortrait runs a preflight data check before executing E2E test bodies and exits early if required data cannot be downloaded, avoiding misleading downstream failures.
251+
See [Test Markers](#test-markers) for details and examples.
252+
249253
Run only E2E tests:
250254
```console
251255
pytest tests/e2e_tests --disable-warnings
252256
```
253257

258+
### Test Markers
259+
260+
scPortrait uses pytest markers to describe test metadata and e2e data requirements.
261+
262+
- `@pytest.mark.slow`: marks slow-running tests (used to identify expensive tests such as full-pipeline e2e runs).
263+
- `@pytest.mark.requires_dataset(...)`: declares which remote datasets/configs an e2e test needs.
264+
265+
The e2e preflight fixture in `tests/e2e_tests/conftest.py` reads `requires_dataset(...)` markers from the selected tests and preloads only those datasets before test bodies execute. If preloading fails, pytest exits early and the remaining e2e tests are not executed.
266+
267+
Example:
268+
269+
```python
270+
@pytest.mark.slow
271+
@pytest.mark.requires_dataset("dataset_1_config", "test_dataset")
272+
def test_full_pipeline_e2e(tmp_path):
273+
...
274+
```
275+
276+
Run marker-filtered tests:
277+
278+
```console
279+
pytest -m slow
280+
pytest -m "not slow"
281+
```
282+
254283
### Running All Tests
255284

256285
To run both unit and E2E tests together:

docs/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
#
33

44
github:
5-
@make html
5+
@$(MAKE) html
66

77
# You can set these variables from the command line, and also
88
# from the environment for the first two.
99
SPHINXOPTS ?=
10-
SPHINXBUILD ?= sphinx-build
10+
PYTHON ?= python
11+
SPHINXBUILD ?= $(PYTHON) -m sphinx.cmd.build
1112
SOURCEDIR = .
1213
BUILDDIR = ./_build
1314

1415
# Put it first so that "make" without argument is like "make help".
1516
help:
1617
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1718

18-
.PHONY: help Makefile
19+
.PHONY: help clean github Makefile
1920

2021
# Catch-all target: route all unknown targets to Sphinx using the new
2122
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def setup(app):
6262
"auto_examples/**.py",
6363
"auto_examples/**.md5",
6464
]
65+
suppress_warnings = ["config.cache"]
6566

6667
# autodoc_mock_imports = []
6768
autodoc_mock_imports = [] # type: ignore

docs/index.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ scPortrait is a scalable toolkit to analyse single-cell image datasets. This Pyt
1111
Installation
1212
=============
1313

14-
Check out the installation instructions :ref:`here<installation>`. You can validate your installation by running one of the example notebooks `here <https://github.com/MannLabs/scPortrait-notebooks/tree/main/example_projects/example_1>`_.
14+
Check out the installation instructions :ref:`here<installation>`. You can validate your installation by running one of the `example notebooks <https://github.com/MannLabs/scPortrait-notebooks/tree/main/example_projects/example_1>`_.
1515

1616
Getting Started
1717
===============
1818

19-
You can check out our :ref:`worfklow overview<workflow>` or our `in-depth tutorial <https://mannlabs.github.io/scPortrait/pages/notebooks/_notebook_workflow_walkthrough.html>`_ to get started with scPortrait. For more detailed information on the package, checkout the more detailed guides :ref:`here<detailed_guide>`. You can find a collection of example projects which run on datasets provided within scPortrait to help you get started with `here <https://github.com/MannLabs/scPortrait-notebooks/tree/main/example_projects>`_. If you encounter issues feel free to `open up a git issue <https://github.com/MannLabs/scPortrait/issues>`_.
19+
You can check out our :ref:`workflow overview<workflow>` or our `in-depth tutorial <https://mannlabs.github.io/scPortrait/pages/notebooks/_notebook_workflow_walkthrough.html>`_ to get started with scPortrait. For more detailed information on the package, checkout the more detailed guides :ref:`here<detailed_guide>`. You can find a collection of example projects which run on datasets provided within scPortrait in the `example projects repository <https://github.com/MannLabs/scPortrait-notebooks/tree/main/example_projects>`_. If you encounter issues feel free to `open up a git issue <https://github.com/MannLabs/scPortrait/issues>`_.
2020

2121
Citing our Work
2222
================
@@ -51,7 +51,6 @@ Documentation
5151

5252
auto_examples/code_snippets/index
5353

54-
..
5554
pages/example_notebooks.ipynb
5655

5756
.. toctree::

docs/pages/module/processing.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ masks
1111
############
1212
.. automodule:: scportrait.processing.masks
1313
:members:
14+
:no-index:

docs/pages/module/tools/ml.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ plmodels
3939
.. autoclass:: scportrait.tools.ml.plmodels.MultilabelSupervisedModel
4040
:members:
4141
:show-inheritance: False
42+
:no-index:
4243

4344
pretrained_models
4445
#################

docs/pages/workflow.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Stitching
3939
During stitching, individual fields-of-view are registered and combined into a single whole-slide image. Using parallel processing and out-of-memory computation scPortrait can efficiently align and assemble large
4040
datasets that exceed the memory capacities of a single machine. The stitching process is optional and can be skipped if the input images are already in the form of a single whole-slide image or individual images need to be processed.
4141

42-
You can find an example notebook illustrating the stitching of individual tif files to whole-slide images :ref:`here <example_stitching>`
42+
You can find an example notebook illustrating the stitching of individual tif files to whole-slide images :ref:`in the stitching tutorial <example_stitching>`
4343

4444
.. _quickstart_segmentation:
4545

@@ -124,7 +124,7 @@ During featurization, the extracted single cell images are passed to a phenotype
124124

125125
The type of featurization applicable to your use case will depend on the type of data you are working with and the biological question you are trying to answer. For example, in our `first publication <https://doi.org/10.1101/2023.06.01.542416>`_ we describe a deep learning-based binary image classifier that identifies individual cells defective in a biological process called "autophagy". Multiple featurization runs can be performed on the same dataset so that different featurization approaches can be used in parallel.
126126

127-
You can find more information on running an inference within a scPortrait Project in this `notebook <https://mannlabs.github.io/scPortrait/html/pages/notebooks/example_scPortrait_project.html#Classification-of-extracted-single-cells>`_.
127+
You can find more information on running an inference within a scPortrait Project in this `classification notebook <https://mannlabs.github.io/scPortrait/html/pages/notebooks/example_scPortrait_project.html#Classification-of-extracted-single-cells>`_.
128128

129129
.. _quickstart_selection:
130130

@@ -135,7 +135,7 @@ The selection step takes a list of cells that have been selected based on their
135135

136136
During selection, the appearance of selected cells can be modified, e.g. by applying an erosion or dilation or by smoothing the shapes to further stream-line the excision process. Please refer to the `py-lmd <https://github.com/MannLabs/py-lmd>`_ library for more details on the available parameters.
137137

138-
You can also find an example selection workflow outlined in this `notebook <https://mannlabs.github.io/scPortrait/html/pages/notebooks/example_scPortrait_project.html#Exporting-Cutting-contours-for-excision-on-a-Leica-LMD7>`_.
138+
You can also find an example selection workflow outlined in this `selection notebook <https://mannlabs.github.io/scPortrait/html/pages/notebooks/example_scPortrait_project.html#Exporting-Cutting-contours-for-excision-on-a-Leica-LMD7>`_.
139139

140140
.. _detailed_guide:
141141

docs/pages/workflow/segmentation_workflow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ If you utilize this segmentation workflow please also consider citing the `cellp
498498
Cytosol Only Cellpose segmentation
499499
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
500500

501-
This segmentation workflow is also built around the cellular segmentation algorithm `cellpose <https://cellpose.readthedocs.io/en/latest/>`_ but only performs a cytosol segmentation. Unlike the :ref:`DAPI segmentation cellpose <_DAPI_segmentation_cellpose>` workflow it uses two input channels to generate a single output mask. The generated single cell datasets using this segmentation method will contain all signal from within the cytosolic region.
501+
This segmentation workflow is also built around the cellular segmentation algorithm `cellpose <https://cellpose.readthedocs.io/en/latest/>`_ but only performs a cytosol segmentation. Unlike the :ref:`DAPI segmentation cellpose <DAPI_segmentation_cellpose>` workflow it uses two input channels to generate a single output mask. The generated single cell datasets using this segmentation method will contain all signal from within the cytosolic region.
502502

503503
As for the :ref:`cytosol segmentation cellpose <Cytosol_segmentation_cellpose>` workflow it is highly recommended to utilize a GPU. If your system has more than one GPU available, in a ShardedSegmentation context, you can specify the number of GPUs to be used via the configuration file (``nGPUs``).
504504

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,10 @@ show_error_codes = true
130130
show_error_context = true
131131
ignore_missing_imports = true
132132
no_strict_optional = true
133+
explicit_package_bases = true
134+
135+
[tool.pytest.ini_options]
136+
markers = [
137+
"slow: marks slow-running tests",
138+
"requires_dataset(*names): e2e datasets/configs that must be preloaded before test execution",
139+
]

0 commit comments

Comments
 (0)