Skip to content

faircode benchmark crashes with a raw traceback for a malformed manifest or degenerate dataset #403

Description

@yakew7

Where: faircode/cli.py's benchmark subcommand - the run_benchmark(...) call has no exception handling, unlike every other failure path in the same block (the top-level import at try/except, the missing-manifests check, and - per a related fix - the write_report matplotlib import).

The gap: verified three distinct ways to crash faircode benchmark with a raw Python traceback instead of a clean CLI error:

  1. Manifest with a YAML syntax error - unhandled yaml.parser.ParserError.
  2. Manifest missing a required key (e.g. no target section):
    $ faircode benchmark bad_manifest/audit.yaml
    ...
      File "faircode/manifest.py", line 141, in from_dict
        target = TargetSpec(**data["target"])
    KeyError: 'target'
    
  3. Manifest pointing at a 0-row dataset - unhandled ValueError: With n_samples=0, ... from deep inside sklearn's train_test_split, raised via faircode/benchmark.py.

All three propagate uncaught all the way to main().

Why it matters: faircode benchmark already handles the "missing optional dependency" and "no manifests found" failure modes cleanly - a malformed manifest or degenerate dataset are just as easy for a real user to hit (a typo'd YAML key, a dataset that got filtered down to nothing upstream) and get none of that same care.

Suggested fix: wrap the run_benchmark(...) call in a try/except catching yaml.YAMLError, KeyError, and ValueError, printing error: <manifest path>: <message> and returning exit code 2, matching this file's existing style for other anticipated failures.

Activity

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

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions