Skip to content

Generate dynamic arg parsing for closed versus open#360

Closed
FileSystemGuy wants to merge 2 commits intomainfrom
FileSystemGuy-argparsing-for-closed
Closed

Generate dynamic arg parsing for closed versus open#360
FileSystemGuy wants to merge 2 commits intomainfrom
FileSystemGuy-argparsing-for-closed

Conversation

@FileSystemGuy
Copy link
Copy Markdown
Contributor

As we are parsing through the options on the command line, dynamically generate the argparsing controls for the remaining options and arguments on the command line.

The purpose of all this is so that the user cannot use, or even see in the help message, the options that are not permitted in CLOSED, but they can see them if they're running in OPEN. This makes it much less likely (impossible?) for them to make a mistake and give an option that isn't permitted in a CLOSED submission. It also makes the submission validation checker much more robust because if the run was for a CLOSED submission, we know that the user cannot use CLI options that are not permitted in CLOSED.

Devasena Inupakutika added 2 commits April 27, 2026 02:21
The `--open` flag was silently ignored because of two intertwined bugs:

1. CLI parser: `--open` was defined with `action="store_false", dest="closed"`,
   which meant passing `--open` produced the exact same Namespace as passing
   nothing (`args.closed=False`, no `args.open` attribute). Callers had no
   way to tell the two cases apart.

2. verify_benchmark() in benchmarks/base.py: the guard
   `if not self.args.closed and not hasattr(self.args, "open"):`
   used hasattr on an attribute that was never created, so it was equivalent
   to `if not self.args.closed:`. Running with `--open` therefore routed
   through the 'Running the benchmark without verification for open or closed
   configurations' warning branch and skipped formal verification entirely.

As a downstream consequence, overrides legitimate under OPEN (e.g.
`dataset.num_files_train=425000` in #349) were never accepted and the run
crashed inside DLIO on a `num_subfolders == len(filenames)` assertion.

Fix:

* common_args.py: give `--open` its own `dest="open"` with
  `action="store_true"`. `--open` and `--closed` are now independent
  booleans, both default False, still mutually exclusive.
* benchmarks/base.py: use `getattr(self.args, 'open'/'closed', False)`; the
  'no verification' warning now fires only when *neither* flag is passed.
  The OPEN-allowed branch is now correctly gated on `open_mode` rather than
  the ambiguous `self.args.closed == False`.
* benchmarks/kvcache.py: verification now triggers for `--open` too, not
  just `--closed`.
* Adds mlpstorage_py/tests/test_open_closed_flag_recognition.py — 11 tests
  pinning (a) CLI parser produces distinguishable `open`/`closed`/neither
  namespaces, (b) verify_benchmark routes each case correctly, (c) kvcache
  guard fires for both submission flags.
…tics

Follow-up to the #349 fix. These tests currently cannot execute on main
because they import `mlpstorage.benchmarks.base` instead of
`mlpstorage_py.benchmarks.base` (broader package-rename migration that
lives outside this PR). But once that import issue is resolved, the test
logic should already be correct for the post-fix behavior:

* The `benchmark` fixture now sets `open=False` alongside `closed=True`
  so the Namespace matches what the fixed argparse definition produces.
* `test_exits_for_open_when_closed_required` — explicit `open=False`.
* `test_allows_open_with_open_flag` — now sets `open=True` (rather than
  just `closed=False`, which the pre-fix code accepted only by accident).
* `test_returns_true_with_closed_false_no_open_attr` renamed to
  `test_returns_true_with_neither_flag_set` and updated: both `closed`
  and `open` are explicitly `False`, matching the new parser defaults.
* `test_full_workflow` fixture gets `open=False` for consistency.

No test expectations are weakened; the only semantic change is
`test_allows_open_with_open_flag`, which now actually exercises --open.
@FileSystemGuy FileSystemGuy requested a review from a team April 28, 2026 02:08
@github-actions
Copy link
Copy Markdown

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

@FileSystemGuy
Copy link
Copy Markdown
Contributor Author

Please review: @russ @idevasena

This should be merged after PR-352. There will very likely be conflicts, so I'll fix them one PR352 is merged.

@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2026
@FileSystemGuy
Copy link
Copy Markdown
Contributor Author

The branch wasn't created correctly, so it had the wrong contents/diff.

@FileSystemGuy FileSystemGuy deleted the FileSystemGuy-argparsing-for-closed branch April 28, 2026 05:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant