Skip to content

Fix #376: argparse conflicting option string: --file#377

Open
idevasena wants to merge 1 commit into
mlcommons:mainfrom
idevasena:fix/issue-376-file-arg-conflict
Open

Fix #376: argparse conflicting option string: --file#377
idevasena wants to merge 1 commit into
mlcommons:mainfrom
idevasena:fix/issue-376-file-arg-conflict

Conversation

@idevasena
Copy link
Copy Markdown
Contributor

Fix #376: argparse "conflicting option string: --file" by removing duplicate declaration

Fixes #376.

Root cause

--file / --object are declared in two places in mlpstorage_py/cli/common_args.py:

  • add_universal_arguments() — line ~198
  • add_storage_type_arguments() — line ~323

Every benchmark subparser builder (add_training_arguments, add_checkpointing_arguments, add_vectordb_arguments, add_kvcache_arguments) calls both functions on the same parser, so argparse raises

argparse.ArgumentError: argument --file: conflicting option string: --file

at parser-construction time — which fires on the very first mlpstorage --help invocation, before any user arg is parsed. This is also why --debug appeared not to work in the report: the parser never finishes being built, so no flag gets evaluated.

How the regression was introduced

Two commits, in sequence:

  1. PR Bug fixes and performance enhancements: object storage, checkpointing, Parquet loading #359 (39e657d, May 8 2026) — Correctly extracted --file/--object out of add_universal_arguments into a new add_storage_type_arguments(). After this commit --file lived in one place.

  2. PR Fix: Issue 349 open flag recognition #352 (258483b, May 13 2026) — Fix for Running training with --open doesn't seem to be recognized #349 --open recognition. The substantive change was rewriting the --open/--closed mutex group inside add_universal_arguments, but the diff also re-introduced the --file/--object mutex block (with required=True) — most likely a merge-conflict resolution against a pre-Bug fixes and performance enhancements: object storage, checkpointing, Parquet loading #359 base. From that commit onward, --file exists in both functions and every benchmark subparser builder crashes.

Verifiable from git show 258483b -- mlpstorage_py/cli/common_args.py: the diff adds back an access_proto.add_argument("--file", ...) block that PR #359 had explicitly removed eight days earlier.

Fix

Remove the duplicate --file/--object block from add_universal_arguments. Replace with a comment that pins the invariant so a future merge can't silently re-introduce it. Restores PR #359's intent: declare those flags once, in add_storage_type_arguments, attached only to benchmark subparsers (training, checkpointing, vectordb, kvcache).

Utility subparsers (reports, history, lockfile) that only call add_universal_arguments no longer carry --file/--object, which is the correct behavior — they don't need storage-type selection.

Tests

New file: mlpstorage_py/tests/test_issue_376_file_arg_conflict.py — seven cases pinning the invariant:

  • Direct reproduction: both adders on one parser no longer raise
  • --file/--object declared in exactly one adder (add_storage_type_arguments)
  • All four benchmark builders (add_training_arguments, add_checkpointing_arguments, add_vectordb_arguments, add_kvcache_arguments) construct cleanly when invoked the same way cli_parser.py invokes them
  • --debug parses correctly post-fix

Updated: mlpstorage_py/tests/test_open_closed_flag_recognition.py_build_parser now also calls add_storage_type_arguments, mirroring how real benchmark subparsers are built, so the open/closed CLI tests keep working.

Validation

Check Pre-fix Post-fix
mlpstorage --help ArgumentError: --file conflict clean SystemExit(0)
mlpstorage training --help crash clean SystemExit(0)
mlpstorage checkpointing --help crash clean SystemExit(0)
mlpstorage vectordb --help crash clean SystemExit(0)
mlpstorage kvcache --help crash clean SystemExit(0)
mlpstorage --debug --help crash clean SystemExit(0)
tests/unit/test_cli.py::TestAddUniversalArguments (8 tests) 7 failed, 1 passed 8 passed
mlpstorage_py/tests/test_open_closed_flag_recognition.py::TestOpenClosedCLIFlags (4 tests) crash 4 passed
mlpstorage_py/tests/test_issue_376_file_arg_conflict.py (7 tests, new) 7 passed

The 7 pre-existing unit-test failures in TestAddUniversalArguments were caused by the same regression (the required=True re-introduction made every parse_args call without --file exit with code 2) — they likely went unnoticed because CI wasn't running them on PR #352.

Diff stats

 mlpstorage_py/cli/common_args.py                          | 21 +++++--------------
 mlpstorage_py/tests/test_open_closed_flag_recognition.py  |  9 +++++++-
 mlpstorage_py/tests/test_issue_376_file_arg_conflict.py   | 131 +++++++++++++++ (new)
 3 files changed, 145 insertions(+), 16 deletions(-)

Remove duplicate --file/--object declaration from add_universal_arguments

Add regression test mlpstorage_py/tests/test_issue_376_file_arg_conflict.py

Update test_open_closed_flag_recognition.py _build_parser to call add_storage_type_arguments
@idevasena idevasena requested a review from a team May 15, 2026 19:55
@github-actions
Copy link
Copy Markdown

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@FileSystemGuy
Copy link
Copy Markdown
Contributor

Please review (and merge if appropriate): @russfellows

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.

Unexpected error: argument --file: conflicting option string: --file

2 participants