Skip to content

cluster_pilots.py shows a traceback for a bad --k and leaves outputs when --truth is invalid #232

Closed

Description

@jmacd867

Describe the bug
Two behaviours of inference/cluster_pilots.py on the #225 branch. An out-of-range --k ends in a raw ValueError traceback. If --truth is invalid, the group and centre CSVs have already been written when the error is raised, so a failed run leaves half its outputs.

To Reproduce

  1. Run generate_synthetic_pilots.py, then compute_features.py on its output.
  2. python inference/cluster_pilots.py --k 1 prints a traceback ending ValueError: k must be 2 to 5 for 15 pilots, got 1.
  3. Repeat a row in inference/Data/synthetic_pilot_tiers.csv, then run python inference/cluster_pilots.py --k 3 --truth inference/Data/synthetic_pilot_tiers.csv. pilot_clusters.csv and group_centres.csv are written, then ValueError: Pilot(s) repeated in truth: P01.

Expected behavior
A one-line usage error and exit status 2 for a bad --k, as --truth without --k already gives. No output files when the run fails.

Screenshots
Not applicable.

Additional context
Fit and score first, then write; use parser.error for input errors. Needs CLI tests in tests/test_cluster_pilots.py.

Activity

  1. added 2 commits that reference this issue on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mlML / inference workbugSomething isn't workingpython

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions