fix(cli): stringify list values from a YAML/JSON config before building argv - #10248
Merged
tastelikefeet merged 1 commit intoSep 26, 2026
Merged
Conversation
…ng argv parse_yaml_args converts scalar values with str() and dict values with json.dumps(), but appends list elements raw, so a config that sets a documented numeric list (interleave_prob, data_range, vllm_server_port) leaves floats or ints in argv and cli_main aborts on ' '.join(args).
tastelikefeet
approved these changes
Sep 26, 2026
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.
PR type
PR information
Launching from a YAML/JSON config crashes before the run starts whenever the config sets a documented list parameter whose elements are not strings.
parse_yaml_argsconverts a scalar value withstr(v)and a dict value withjson.dumps(v), but appends a list's elements raw:so numbers stay numbers in
argv, andcli_mainthen fails on the line that prints the command it is about to exec (swift/cli/main.py:99, andsubprocess.run(args)right after it would hit the same thing).Measured with the current
main(c08110b3) andparse_yaml_argscalled exactly ascli_maincalls it:These are ordinary parameters, not edge cases:
interleave_probis declaredOptional[List[float]](swift/arguments/base_args/data_args.py:87),data_rangeisList[int](swift/arguments/sampling_args.py:73) andvllm_server_portisList[int](swift/megatron/arguments/megatron_args.py:126).docs/source_en/Instruction/Command-line-parameters.mdpresents the YAML/JSON launch as supported forswift infer/rlhf/...andmegatron sft/rlhftoo, and suggests using YAML "for parameters that are infrequently modified" — a string list such asdatasetworks, and the first numeric list in the same file breaks the launch.The fix is the one missing conversion, matching what the scalar and dict branches already do:
The value still arrives unchanged:
parse_args(DataArguments, ['--interleave_prob', '0.5', '0.5'])returns[0.5, 0.5], so the launcher only needs strings to join and exec.Tested with the new
tests/utils/test_cli_config_args.py, which pins the two crashing cases and the two cases that must not change (a string list such asdataset, a dict value such asvllm_engine_kwargs):mainbefore the fix:Ran 4 tests ... FAILED (failures=2), and both failures are the' '.join(argv)TypeErrorabove;Ran 4 tests ... OK;flake8,isort --check-onlyandyapf --diffreport nothing on either file.Disclosure: this PR was prepared, tested and submitted by an AI agent working on behalf of the account owner.