fix(cli): order CLI commands deterministically#4027
Open
assinscreedFC wants to merge 2 commits into
Open
Conversation
group_commands returned top-level and sub-commands in plugin discovery order, which varies across systems. That non-determinism leaked into the CLI help output and the generated command-line-interface.md reference, producing spurious docs diffs. Sort the grouped commands alphabetically by name (and sub-commands by (parent, command)) before returning. Group contents keep their insertion order, so the primary command and 'extend' execute order are unchanged. Regenerated the CLI reference docs to match. Fixes dlt-hub#3454
…rder The previous docs regeneration ran without the 'cli' extra, which dropped the 'dlt pipeline mcp' section. Regenerated with 'uv sync --extra cli --group workspace-deps' (the env CI uses for check-cli-docs), so the only change to the reference is deterministic reordering, no content loss. Also add a test asserting the alphabetical key sort preserves within-group order (primary command and 'extend' execute order).
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.
Problem
group_commands(indlt/_workspace/cli/compose.py) returned top-level and sub-commands in plugin discovery order, which varies from system to system. That non-determinism leaks into:dlt --helpsubcommand order), anddocs/website/docs/reference/command-line-interface.md, producing spurious diffs / a flakymake check-cli-docs.Closes #3454.
Fix
Sort the grouped commands deterministically before returning:
Top-level commands are ordered alphabetically by name, sub-commands by
(parent, command). Group contents keep their insertion order, so the primary command (group[0]) and theextendexecute order are unaffected.Result
dlt --helpnow lists{ai, dashboard, deploy, init, pipeline, schema, telemetry}in a stable order regardless of discovery order. Regenerated the CLI reference docs (make update-cli-docs) to match.Tests
test_group_orders_commands_deterministically(regression for cli docs renderer works in non-deterministic order #3454): commands fed in non-alphabetical order come back sorted. Fails ondevel, passes with the fix.test_cli_compose.pysuite still green (single-key cases unaffected; within-group order preserved).make check-cli-docspasses against the regenerated reference.black --check,flake8,mypyclean on the changed files.If you'd prefer a curated order over alphabetical, the sort key is a one-line change.