Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
DEFAULT_N_JOBS: Final = 10
DEFAULT_FPS: Final = 25.0
DEFAULT_N_BIRDS: Final = 3
K_RANGE: Final[range] = range(2, 13)
LABEL_ORDER: Final = ["none", "worm", "locomotor", "social"]
RANDOM_SEED: Final[int] = 42
19 changes: 12 additions & 7 deletions tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Smoke-test that every src module imports without error.
"""Smoke-test that every src and pipeline module imports without error.

Modules whose only failure is a missing optional dependency (torch,
transformers, etc.) are skipped so the test suite stays useful in the
Expand All @@ -10,7 +10,8 @@

import pytest

SRC_ROOT = Path(__file__).resolve().parent.parent / "src"
PROJECT_ROOT = Path(__file__).resolve().parent.parent
PACKAGE_ROOTS = [PROJECT_ROOT / "src", PROJECT_ROOT / "pipeline"]

OPTIONAL_PACKAGES = frozenset({
"torch",
Expand All @@ -29,16 +30,20 @@
"omegaconf",
"motmetrics",
"kmedoids",
"yaml",
})


def _discover_modules():
"""Yield dotted module paths for every .py file under src/."""
for py_file in sorted(SRC_ROOT.rglob("*.py")):
if py_file.name == "__init__.py":
"""Yield dotted module paths for every .py file under src/ and pipeline/."""
for root in PACKAGE_ROOTS:
if not root.exists():
continue
relative = py_file.relative_to(SRC_ROOT.parent)
yield str(relative.with_suffix("")).replace("/", ".")
for py_file in sorted(root.rglob("*.py")):
if py_file.name == "__init__.py":
continue
relative = py_file.relative_to(PROJECT_ROOT)
yield str(relative.with_suffix("")).replace("/", ".")


def _is_optional_dep_missing(exc: ModuleNotFoundError) -> bool:
Expand Down
Loading