Improve CLI error message for unknown options to dask worker (#9094)#9281
Open
ernestprovo23 wants to merge 2 commits into
Open
Improve CLI error message for unknown options to dask worker (#9094)#9281ernestprovo23 wants to merge 2 commits into
ernestprovo23 wants to merge 2 commits into
Conversation
Contributor
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 31 files + 1 31 suites +1 10h 45m 18s ⏱️ + 43m 53s Results for commit a8b8572. ± Comparison against base commit bcad953. This pull request skips 1 test. |
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
Improves the error message users see when they pass an unknown option or stray positional argument to
dask worker(anddask scheduler). Fixes #9094.Motivation
dask_worker's click group is configured withignore_unknown_options=True, so any unrecognized token gets passed through intopreload_argvand is then caught invalidate_preload_argv(distributed/preloading.py).For dash-prefixed tokens the existing code already raises
click.NoSuchOption, which produces a helpful "No such option: --foo" message. But for any non-dash stray value the user just got:with no hint that
--helplists the valid options or that--preloadconsumes everything to its right. After #9240 removed the deprecated--nprocs, the original MCVE in #9094 now hits the dash-prefixed branch and produces a good message — but the catch-all message remained the same misleading wall.Changes
distributed/preloading.py— extended theclick.UsageErrormessage invalidate_preload_argvto point users at--helpand explain the--preloadordering rule. No structural changes; theNoSuchOptionbranch is untouched.distributed/cli/tests/test_dask_worker.py— two newCliRunnertests:test_unknown_option_reports_no_such_option— regression guard for the dash-prefixed branch.test_stray_positional_hints_at_help_and_preload— asserts the improved message mentions--helpand--preload.Net diff: +26 / -1 across two files.
Testing
Repro on
mainafter #9240:After this PR:
Dash-prefixed unknowns still produce the click-native message:
Local runs:
pytest distributed/cli/tests/test_dask_worker.py -m "not slow"— 31 passed, 2 skipped (uvloop missing), 0 failed.pre-commit run --files distributed/preloading.py distributed/cli/tests/test_dask_worker.py— ruff, black, mypy all clean.Notes:
validate_preload_argvis also imported bydistributed/cli/dask_scheduler.py, so the improved message benefits both entry points. Behavior is unchanged.ignore_unknown_options=Trueincli/dask_worker.py— that's a deeper refactor and out of scope for the message fix requested in Dask worker CLI error message might be misleading #9094.Fixes #9094.