Skip to content

Commit

Permalink
Backport PR #1151 on branch 0.10.x (Moving source directory to src/an…
Browse files Browse the repository at this point in the history
…ndata) (#1457)
  • Loading branch information
flying-sheep committed Apr 9, 2024
1 parent 73545b1 commit ee3f6df
Show file tree
Hide file tree
Showing 84 changed files with 38 additions and 10 deletions.
13 changes: 12 additions & 1 deletion .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ trigger:

variables:
RUN_COVERAGE: no
PYTEST_ADDOPTS: --color=yes --junitxml=test-data/test-results.xml
# TODO: remove paths after moving tests to test dir: https://github.com/scverse/anndata/issues/1451
PYTEST_ADDOPTS: --color=yes --junitxml=test-data/test-results.xml anndata ./src/anndata/tests ./docs/concatenation.rst
DEPENDENCIES_VERSION: "latest" # |"pre-release" | "minimum-version"
TEST_TYPE: "standard" # | "coverage"

Expand Down Expand Up @@ -84,6 +85,16 @@ jobs:
displayName: "PyTest (treat warnings as errors)"
condition: eq(variables['TEST_TYPE'], 'strict-warning')
# TODO: remove: https://github.com/scverse/anndata/issues/1451
- task: PythonScript@0
inputs:
scriptSource: inline
script: |
import sys, xml.etree.ElementTree as ET
results = ET.parse("./test-data/test-results.xml").findall("./*/*")
sys.exit(0 if len(results) > 3000 else f"Error: only {len(results)} tests run")
displayName: "Check if enough tests ran"

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ __pycache__/

# Distribution / packaging
/dist/
/anndata/_version.py
/src/anndata/_version.py
/requirements*.lock
/.python-version
/hatch.toml
Expand Down
28 changes: 21 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ doc = [
]
test = [
"loompy>=3.0.5",
"pytest>=7.3",
"pytest>=8.1",
"pytest-cov>=2.10",
"zarr",
"matplotlib",
Expand All @@ -102,15 +102,21 @@ test = [
gpu = ["cupy"]

[tool.hatch.build]
exclude = ["anndata/tests/test_*.py", "anndata/tests/data"]
exclude = [
"src/anndata/tests/conftest.py",
"src/anndata/tests/test_*.py",
"src/anndata/tests/data",
]
[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "anndata/_version.py"
version-file = "src/anndata/_version.py"

[tool.coverage.run]
source = ["anndata"]
omit = ["anndata/_version.py", "**/test_*.py"]
source_pkgs = ["anndata"]
omit = ["src/anndata/_version.py", "**/test_*.py"]
[tool.coverage.paths]
source = ["./src", "**/site-packages"]

[tool.coverage.report]
exclude_also = [
Expand All @@ -119,8 +125,10 @@ exclude_also = [

[tool.pytest.ini_options]
addopts = [
# "--import-mode=importlib", # TODO: enable: https://github.com/scverse/anndata/issues/1451
"--strict-markers",
"--doctest-modules",
"--pyargs",
"--ignore=anndata/core.py", # deprecated
"--ignore=anndata/readwrite.py", # deprecated
]
Expand All @@ -139,11 +147,17 @@ filterwarnings_when_strict = [
"default::dask.array.core.PerformanceWarning",
]
python_files = "test_*.py"
testpaths = ["anndata", "docs/concatenation.rst"]
testpaths = [
"anndata", # docstrings and unit tests (module name due to --pyargs)
"./docs/concatenation.rst", # further doctests
]
# For some reason this effects how logging is shown when tests are run
xfail_strict = true
markers = ["gpu: mark test to run on GPU"]

[tool.ruff]
src = ["src"]

[tool.ruff.format]
docstring-code-format = true

Expand All @@ -168,7 +182,7 @@ ignore = [
]
[tool.ruff.lint.per-file-ignores]
# E721 comparing types, but we specifically are checking that we aren't getting subtypes (views)
"anndata/tests/test_readwrite.py" = ["E721"]
"src/anndata/tests/test_readwrite.py" = ["E721"]
[tool.ruff.lint.isort]
known-first-party = ["anndata"]
required-imports = ["from __future__ import annotations"]
Expand Down
2 changes: 1 addition & 1 deletion anndata/__init__.py → src/anndata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
try: # See https://github.com/maresb/hatch-vcs-footgun-example
from setuptools_scm import get_version

__version__ = get_version(root="..", relative_to=__file__)
__version__ = get_version(root="../..", relative_to=__file__)
except (ImportError, LookupError):
try:
from ._version import __version__
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions anndata/tests/conftest.py → src/anndata/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# TODO: Should be done in pyproject.toml, see anndata/conftest.py
warnings.filterwarnings("ignore", category=anndata.OldFormatWarning)

# TODO: remove once we extricated test utils and tests
collect_ignore = ["helpers.py"]


@pytest.fixture
def backing_h5ad(tmp_path):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ee3f6df

Please sign in to comment.