You can use W&B Sweeps with custom CLI commands if training configuration passes command-line arguments. This lets you run sweeps against existing training scripts that already expect specific CLI flags, without modifying how the script consumes its arguments. The following example shows a Bash terminal that trains a Python script namedDocumentation Index
Fetch the complete documentation index at: https://wb-21fd5541-style-guide-support-models-articles-20260527-00.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
train.py and provides values that the script parses:
command key in the sweep configuration YAML file so the sweep agent builds the same command line. Based on the previous example, the configuration looks like this:
${args} key expands to all parameters in the sweep configuration, formatted for argparse as --param1 value1 --param2 value2.
If your script accepts additional arguments outside of argparse, use parse_known_args so unrecognized flags don’t cause the parser to fail:
Depending on the environment,
python might refer to Python 2. To invoke Python 3, use python3 in the command configuration:Sweeps