Accept multiple --chunk-ids without quoting in download_pai.py#81
Open
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
Open
Accept multiple --chunk-ids without quoting in download_pai.py#81lonexreb wants to merge 1 commit intoNVlabs:mainfrom
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
Conversation
The `--chunk-ids` help text and the FINETUNE_SFT example both document a
``multi '0 1'`` form, but argparse was using ``type=str`` with no ``nargs``,
so that form failed:
$ python scripts/download_pai.py --chunk-ids 0 1 2
error: unrecognized arguments: 1 2
Switch to ``nargs="+"`` and route the list through a small ``_expand_chunk_ids``
helper. Now all of these work and produce the same flat ``list[int]`` of chunk
ids:
* ``--chunk-ids 0`` -> ``[0]``
* ``--chunk-ids 0 1 2`` -> ``[0, 1, 2]`` (newly works unquoted)
* ``--chunk-ids 0-3`` -> ``[0, 1, 2]`` (range, end exclusive)
* ``--chunk-ids 0-2 5`` -> ``[0, 1, 5]`` (mix of range and singles)
* ``--chunk-ids "0 1 2"`` -> ``[0, 1, 2]`` (legacy quoted form preserved)
The change is strictly more permissive — every previously valid invocation
still produces the same list of integers.
Signed-off-by: lonexreb <[email protected]>
9fb907f to
a74b63b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The `--chunk-ids` help text already advertises a `multi '0 1'` form, and `docs/FINETUNE_SFT.md` reinforces it ("multiple ids (`0 1`)"). But `argparse` was wired with `type=str` and no `nargs`, so that form actually fails:
```console
$ python scripts/download_pai.py --chunk-ids 0 1 2
usage: download_pai.py [-h] ...
download_pai.py: error: unrecognized arguments: 1 2
```
Switching to `nargs="+"` plus a small `_expand_chunk_ids` helper lines the CLI up with what the docs already promise.
Behavior matrix
Every previously valid invocation still produces the same flat list of integer chunk ids that `build_allow_patterns` consumes — strictly more permissive.
Test plan
Existing example invocations in the docs continue to work: