Skip to content

[REFACTOR] remove dead code and duplication, tidy naming and packaging - #8

Merged
youssefassis merged 6 commits into
mainfrom
refactor/cleanup
Oct 5, 2026
Merged

youssefassis merged 6 commits into
mainfrom
refactor/cleanup

Conversation

@youssefassis

Copy link
Copy Markdown
Owner

Why

Cleanup pass after the uv migration: code with no caller, logic copied in two places, and leftovers that still pointed at python -m. No behaviour change intended.

Changes

  • Remove build_all, build_model, the never-passed target_layer_name option and three unread TrainResult fields. Model-config validation tests now target ModelConfig directly.
  • Trainer reuses collate_without_masks; Score-CAM and to_heatmap share min_max_per_sample.
  • channel_statistics is typed by Dataset (it is also fed synthetic data); hoist a function-local import in the trainer.
  • CLI help and messages say classify-justify.
  • Drop unused pytest-cov.
  • Version read from __init__.py by hatch, so it lives in one place.

Deferred on purpose: sharing the trainer's dataset factory with evaluate and splitting _run_evaluate. Both are entangled with the --split bug and the silent preprocessing defaults, and belong with those fixes.

Testing

  • ruff check clean, pytest 140 passed (one test removed with build_model).
  • Seeded synthetic pipeline run on main and on this branch (train, evaluate all 18 methods with --sanity, explain): checkpoint weights, evaluation JSON, every method's heatmap and the explain figure are bit-identical.
  • explain and evaluate run on MPS; the built wheel installs with plain pip and reports 0.1.0.
  • Not run: the KolektorSDD2 path (dataset not available locally). This branch only changes an error message and a type hint there.

build_all, build_model, the target_layer_name option and three
TrainResult fields had no caller outside their own tests. Each was
surface to read and keep working with no user behind it. The model
config tests now exercise ModelConfig directly, which is where the
validation actually lives.
The trainer carried its own copy of collate_without_masks, and Score-CAM
its own copy of the min-max scaling inside to_heatmap. Two copies drift:
a fix to one would silently miss the other.
channel_statistics is also fed SyntheticDefects, so its KolektorSDD2
hint was wrong and pulled in an import only for that. The trainer's
function-local import of load_checkpoint guarded against no cycle; the
same package is already imported at the top.
The console script is the documented way to run it now; usage lines and
the missing-dataset hint still pointed at python -m.
It was installed into every dev environment without ever being invoked.
It was written in both pyproject.toml and __init__.py, so a release
could bump one and leave --version reporting the other. Hatch now reads
it from __init__.py.
@youssefassis
youssefassis merged commit 53c879c into main Oct 5, 2026
5 checks passed
@youssefassis
youssefassis deleted the refactor/cleanup branch October 5, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant