This file provides instructions for Codex and similar coding agents working in this repository.
PyTorch Connectomics (PyTC) is a Hydra/OmegaConf + PyTorch Lightning + MONAI codebase for EM segmentation.
Primary entry point: scripts/main.py.
- Many project-specific Markdown knowledge-base files live under
.claude/(for example, architecture notes, workflows, and integration guides). - Check
.claude/*.mdwhen you need deeper repository context before making non-trivial changes.
- Ecosystem-first, no reinvention: Leverage proven frameworks (PyTorch, Lightning, MONAI, nnU-Net) to keep the codebase modern, minimal, and scalable.
- Config-first reproducibility: Use Hydra/OmegaConf YAML composition + CLI overrides so experiments are declarative, reproducible, and easy to customize across datasets/benchmarks.
- Modular + extensible connectomics workflows: Separate concerns cleanly (config, data, training, inference/decoding), expose registry-style extension points, and support large-volume EM workloads (tiling, sliding-window, multi-GPU) for both novices and agentic workflows.
- Preserve user-facing behavior unless explicitly requested.
- Preserve
scripts/main.pyCLI arguments and mode semantics. - Preserve Hydra/OmegaConf key structure and override behavior.
- Prefer small, reviewable refactors over large rewrites.
- Do not add new runtime dependencies unless explicitly approved.
- Use conda env
pytcfor all validation. - Do not install into
base. - Prefer
conda run -n pytc <command>for deterministic execution.
Run these after meaningful changes (or explain why not possible):
conda run -n pytc python scripts/main.py --democonda run -n pytc pytest -q
For targeted changes, run focused tests plus the demo smoke test.
Use changed-file scope unless specifically fixing global style/type debt:
black --check <changed_py_files>isort --check-only <changed_py_files>flake8 --max-line-length=100 <changed_py_files>mypy --config-file .github/mypy_changed.ini <changed_py_files>
Note: repository-wide black --check connectomics/ is not currently clean.
- Keep diffs minimal and localized.
- Avoid changing config keys and defaults without a clear migration plan.
- Keep module boundaries explicit (config, data, training, decoding).
- Add or update tests when behavior or contracts are touched.
- Commit logically (one milestone/concern per commit).
- In PR descriptions, include:
- what changed
- why
- exact validation commands run
- key results
- Config system:
connectomics/config/ - Data pipeline:
connectomics/data/ - Lightning runtime:
connectomics/training/lightning/ - Decoding/postprocess:
connectomics/decoding/
- Do not use destructive git commands (
reset --hard, checkout discards) unless explicitly requested. - If unexpected working-tree changes appear, pause and confirm intent before touching them.