Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving source directory to src/anndata #1151

Merged
merged 38 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0f916d3
Start moving
ivirshup Sep 8, 2023
3159ae5
bug fixes
ivirshup Sep 8, 2023
96994af
editable install for doctests
flying-sheep Oct 2, 2023
28df752
oops
flying-sheep Oct 2, 2023
50be530
fix gpu tests
flying-sheep Oct 2, 2023
f1e3b8e
Merge branch 'main' into src2
flying-sheep Jan 12, 2024
5fdbc60
--pyargs
flying-sheep Jan 12, 2024
878d2fd
Merge branch 'main' into src2
flying-sheep Jan 12, 2024
8ae217e
IT WORKS
flying-sheep Jan 12, 2024
abad630
Discard changes to .azure-pipelines.yml
flying-sheep Jan 12, 2024
4471d95
Discard changes to .github/workflows/test-gpu.yml
flying-sheep Jan 12, 2024
9650876
importlib
flying-sheep Jan 12, 2024
55e1f0e
Merge branch 'main' into src2
flying-sheep Feb 5, 2024
09343e9
Merge branch 'main' into src2
flying-sheep Feb 5, 2024
bdf7447
exclude conftest
flying-sheep Feb 18, 2024
d2ea31b
Merge branch 'main' into src2
flying-sheep Feb 18, 2024
e627fdd
Merge branch 'main' into src2
flying-sheep Mar 4, 2024
61d8ecc
bump pytest version
flying-sheep Mar 4, 2024
55afbaa
make less dependent on import order
flying-sheep Mar 4, 2024
4f619f2
fix weird import
flying-sheep Mar 4, 2024
77a744d
Merge branch 'main' into src2
flying-sheep Mar 4, 2024
7019f39
dev version
flying-sheep Mar 4, 2024
fbd89ab
Merge branch 'main' into src2
flying-sheep Mar 12, 2024
d4ab295
pytest version
flying-sheep Mar 12, 2024
edd2ca2
maybe fix coverage paths
flying-sheep Mar 12, 2024
062717f
more correct
flying-sheep Mar 12, 2024
d4170cb
Merge branch 'main' into src2
flying-sheep Mar 14, 2024
6f07f81
Merge branch 'main' into src2
flying-sheep Mar 28, 2024
fbd5a3f
deduplicate collection
flying-sheep Mar 28, 2024
6e55886
no importlib for now
flying-sheep Mar 28, 2024
99dcc98
revert
flying-sheep Mar 28, 2024
2992a35
revert pyargs
flying-sheep Mar 28, 2024
6c28074
pyargs was load bearing
flying-sheep Mar 28, 2024
b0efbc2
cache bust
flying-sheep Mar 28, 2024
30d7891
Merge branch 'main' into src2
flying-sheep Apr 8, 2024
8a845af
update TODOs
flying-sheep Apr 8, 2024
045c19c
fix
flying-sheep Apr 9, 2024
a834c42
bump nuber to be extra safe
flying-sheep Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions .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
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 @@ -41,10 +42,10 @@ jobs:

- task: Cache@2
inputs:
key: '"python $(python.version)" | "$(Agent.OS)" | pyproject.toml'
key: '2 | "python $(python.version)" | "$(Agent.OS)" | pyproject.toml'
restoreKeys: |
python | "$(Agent.OS)"
python
2 | python | "$(Agent.OS)"
2 | python
path: $(uv_cache_dir)
displayName: Cache pip packages

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some explanation of why, link to a relevant issue here would be good

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because you said so. there’s no issue that I’m aware of.

You said something along the lines of “let’s not make too many changes at once because this is fragile. Let’s do that when we move the tests out of the package.”

"--strict-markers",
"--doctest-modules",
"--pyargs",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I totally get this argument. What does this do other than let us use anndata instead of ./src/anndata in testpaths?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because doctests are weird and would otherwise result in importing some modules as files and others via sys.path.

pytest imports the files that hosts doctests. If they are in a src directory, they’ll be imported twice: once that way and once when importing the actual library.

Using --pyargs means that pytest will identify the doctest parent modules as identical to the library module with the same path.

]
filterwarnings = [
'ignore:Support for Awkward Arrays is currently experimental',
Expand All @@ -137,11 +145,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 @@ -166,7 +180,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.
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.