Repository navigation
Update package structure to be installable #78
Description
Background
The codebase imports its modules under the literal top-level name src (e.g. from src.dataset_tools.cli import cli), and the packaging entry points follow suit (ami-dataset = "src.dataset_tools.cli:cli"). After the Poetry→uv migration (#68), the wheel ships src/ and this works for editable installs and even for a non-editable pip install (verified by building the wheel and importing src.dataset_tools.cli from outside the repo).
It works, but src is not a good distribution package name:
srcis a generic name. In a shared environment it can collide or merge (implicit namespace packages) with any other project that also ships a top-levelsrc.src/is conventionally a layout container, not the package itself. The standard src-layout puts a single importable package one level down (src/<package>/) and imports it by name (<package>.…), neversrc.….pip install ami-mlcurrently exposes a package calledsrc, which is surprising for any downstream consumer.
This aligns the repo with the standard src-layout used elsewhere in the lab.
Goal
Rename the package so the project installs cleanly and is imported as ami_ml:
- Move the modules under a single package:
src/ami_ml/{dataset_tools,classification,localization}/ from src.dataset_tools import …→from ami_ml.dataset_tools import …- Packaging:
[tool.hatch.build.targets.wheel] packages = ["src/ami_ml"] - Update the entry points (
ami-dataset,ami-classification), the tests (tests/imports), and the flake8per-file-ignorespaths.
Sketch
mkdir -p src/ami_ml
git mv src/dataset_tools src/classification src/localization src/ami_ml/
# add src/ami_ml/__init__.py
grep -rl --include='*.py' --include='*.sh' '\bsrc\.' . | xargs sed -i 's/\bsrc\./ami_ml./g'
# then hand-fix: pyproject entry points + packages, flake8 per-file-ignores, any string refsgit mv is preferable to a Hatchling sources path remap: with the directory actually named ami_ml, both editable and wheel installs resolve ami_ml for free, and there's no dev/wheel import-name mismatch. (A build-time remap was tested and is fragile — it still forces the same import rewrite, so it buys nothing.)
Sequencing
This rewrites nearly every import line, so it should land after the in-flight PRs that heavily touch src/ (#74, #69) to avoid rebase conflicts.
Notes
- Not a blocker for Migrate dependency management from Poetry to uv #68 — the current
srcpackaging is verified working; this is a correctness/cleanliness follow-up. - Verify after:
uv build --wheel, install the wheel non-editable in a clean venv,ami-dataset --help+import ami_ml.dataset_tools, anduv run pytest tests/.
Activity