Skip to content

Every argparse entry point under yeto/ takes full option names only; fewer look-alike hints; quoted preflight command - #925

Merged
michaellchung merged 5 commits into
mainfrom
fix/argparse-exact-entrypoints
Nov 26, 2026
Merged

michaellchung merged 5 commits into
mainfrom
fix/argparse-exact-entrypoints

Conversation

@michaellchung

Copy link
Copy Markdown
Contributor

Follow-up to #904. That PR moved the yeto command tree, the NC pool tool and the Miles island to ExactArgumentParser. This one moves every other argparse entry point under yeto/, tightens the spelling hints, and quotes one printed command.

1. Every module entry point takes full option names only

  • 62 modules that built a plain argparse.ArgumentParser now build an ExactArgumentParser. This includes dashboard/fleet_store.py, whose merge CLI landed in fleet.jsonl: learner id as island_id, chunked copy into the run store #910 after the first switch. Their sub-parsers inherit it. They include:
    • the node-side entry points whose argv the launcher renders: engine_sampler(_entry), init_from_release, tape_upload, store_dispense, role_switch, controller, health/*, spot/watchdog, ssh_harness, hw/node_health, node/relay_proxy;
    • the learners;
    • the exporters;
    • the stage1 and quant tools;
    • the remaining operator tools.
  • Three modules run without the rest of yeto. They keep stdlib argparse and set allow_abbrev=False on the parser and, through parser_class, on every subcommand (a plain add_subparsers would not inherit it):
    • launch/weights_sync.py and launch/preflight/bench.py are shipped to the nodes as single files. weights_sync even runs under python3 -I;
    • codepack.py is imported by a node from a partly unpacked pack (PACK_FETCH_PY) before the tree is verified. Its contract test packs only __init__.py and codepack.py. A first draft that imported yeto.exact_argparse there broke that test, which is how this case was found.

Who relied on abbreviations

I checked this three ways with one-off local scripts, none committed:

  • Full suite on main with an audit hook. The hook logs any long option that argparse resolved only by prefix, for every parser including all 65 entry points. Result: 0 hits.

  • Real rendered commands. On this branch I ran the full suite with a second hook. It parses each command at the point where it is rendered, using the target module's own parser. It hooks:

    • the renderers: init_release_block, syncer_tape_sidecar, ssh_weights.sync_argv / node_script, nc.ssh_sampler.sampler_command, node.launch.process_argv / container_argv;
    • every subprocess.run / Popen / check_output argv that runs -m yeto.<entry point>.

    Result: 91 rendered commands across 6 entry points, all parsed. Those entry points are engine_sampler (36), init_from_release (39), weights_sync (9), hw/node_health (4), remote_code_prewarm (2) and store_dispense (1). No test renders the tape_upload follow line of syncer_tape_sidecar, so I parsed that template separately, along with the store_dispense status call of run up. Both parse with no extras.

  • Written command lines. Every place a command line for one of these modules is written down: renderers in the source, docs, examples, tests, scripts and tools. Every --option token was checked against that module's parser. Result: no token relies on a prefix. The three candidates the scan flagged were option names of other parsers on the same lines.

2. Hints: fewer look-alikes; only argparse's message is replaced

  • The difflib cutoff goes from 0.6 to 0.8. At 0.6, --rl-max offered --rl-image (similarity 0.78) next to the --rl-max-* options it is a prefix of. At 0.8, typos are still offered: --modle gives --model (0.86), --rl-imgae gives --rl-image (0.9).
  • New tests for error():
    • argparse's unrecognized arguments message for the extras of the last parse gains the hints, and its first line is kept verbatim;
    • another error of the same parser is unchanged (expected one argument);
    • a caller's own message that only looks like the unrecognized one is unchanged;
    • parse_known_args still returns the extras and never errors.

3. run up: the dry run's preflight command is printed quoted

run up --dry-run printed the trainer's cluster preflight command joined with spaces. An argument with a space did not paste back as one word. It now uses shlex.join, as the launch gate already did. The customer K3.1 bare-metal dry run prints the same line, because none of its arguments needs quoting. test_k31_baremetal_run_up_dry_run compares that dry run line for line with main and passes.

Tests and gates

  • tests/test_exact_option_names.py gains these tests:
    • every ArgumentParser( under yeto/ is an ExactArgumentParser. A plain one fails the test, as does a from argparse import ArgumentParser call. The three self-contained modules must set allow_abbrev=False on the parser and the subcommands, and must have no top-level yeto import;
    • all three refuse a prefix inside a subcommand (sync --work for --workers, ports --peer for --peers, verify --di);
    • the error() behavior and the look-alike cutoff described in section 2.
  • tests/test_preflight_gate.py: a dry run with an inventory path that contains a space prints it as one shell word.
  • Mutations, each reverted after the run; every one fails at least one test:
    • a plain parser in one module;
    • a from argparse import ArgumentParser parser;
    • a standalone tool without allow_abbrev=False;
    • a standalone subcommand without parser_class (weights_sync, codepack);
    • a top-level yeto import in codepack.py;
    • error() replacing any message;
    • cutoff back to 0.6;
    • allow_abbrev on by default;
    • no hints at all;
    • " ".join instead of shlex.join.
  • K3.1 customer plan golden + breakers golden: 52 passed (main: 52 passed).
  • customer dry-run diff: none. That covers run up --dry-run for every examples/k31/run*.json and the pool --dry-run, compared line by line with origin/main. 5 outputs were compared.
  • Full suite, 4 shards (--shard i/4) on the final head: 18,477 passed, 0 failed. The same run carried the render hook described in section 1.

🤖 Generated with Claude Code

michaellchung and others added 5 commits November 27, 2026 05:17
The command run up's dry run prints was joined with spaces; an argument
with a space or a shell character (an inventory path, say) did not paste
back as one word. It is shlex.join'ed now, as the launch gate already does.
The customer K3.1 dry runs print the same line (nothing there needs quotes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0.6 offered look-alikes: --rl-max named --rl-image (0.78) next to the
--rl-max-* options it is a prefix of. 0.8 keeps typos such as --modle
(--model, 0.86) and --rl-imgae (--rl-image, 0.9).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The command tree, the NC pool tool and the Miles island moved to
ExactArgumentParser in #904; the module entry points did not. The 62
modules that build a parser (node-side ones whose argv the launcher
renders: engine sampler, init_from_release, tape_upload, store_dispense,
role_switch, controller, health readers, spot watchdog, ssh_harness,
learners, exporters, ...) now build an ExactArgumentParser; their
sub-parsers inherit it.

weights_sync.py and preflight/bench.py run as single files on a node
(no yeto package there): they keep argparse and set allow_abbrev=False
on the parser and, through parser_class, on every subcommand.

Tests: every parser under yeto/ is exact (a plain ArgumentParser fails),
the two standalone tools refuse a prefix in a subcommand, and error()
replaces argparse's "unrecognized arguments" message only (another
error, a caller's look-alike message and parse_known_args stay as they
were); look-alike options are not offered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ked pack)

PACK_FETCH_PY puts the pack's yeto/ files on sys.path and imports
yeto.codepack before the tree is unpacked and verified; its contract
(test_rl_ssh_resident's tiny pack of __init__.py + codepack.py) is a
module with no top-level yeto import. It keeps argparse and sets
allow_abbrev=False on the parser and its subcommands, like the two tools
shipped alone to a node; the coverage test names it with them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… switch, #910)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michaellchung
michaellchung merged commit 6c32787 into main Nov 26, 2026
7 checks passed
@michaellchung
michaellchung deleted the fix/argparse-exact-entrypoints branch November 26, 2026 21:56
michaellchung added a commit that referenced this pull request Nov 26, 2026
…verage test) (#927)

yeto/node/smoke.py (#894) built a plain argparse.ArgumentParser and
landed after #925, whose coverage test requires every parser under yeto/
to be an ExactArgumentParser. The smoke runs as `python -m yeto.node.smoke`
inside the adopted image with the yeto tree (it imports
yeto.rl.engine.engine_sampler_entry), so it takes the exact parser.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant