Repository navigation
Add -v/--version to optimum-cli - #2530
Open
manunicholasjacob wants to merge 1 commit into
Open
manunicholasjacob wants to merge 1 commit into
manunicholasjacob wants to merge 1 commit into
Conversation
Prints the optimum version and the version of each installed optimum-* subpackage, then exits. Requested in huggingface/optimum-intel#1447. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What does this PR do?
Adds
-v/--versiontooptimum-cli, as requested in huggingface/optimum-intel#1447, where @IlyasMoutawwakil suggested opening a PR for it.The flag prints the optimum version, then one line per installed
optimum-*package, and exits:I used a small custom argparse
Actioninstead ofaction="version"for two reasons. The built-in action reflows its text onto a single line, so the per-package lines get joined. It also needs the string when the parser is built, which would mean scanning installed distributions on every CLI start. The custom action only does the lookup when the flag is passed.This is separate from #2188 (
optimum.__version__attribute) and does not touch it.How I tested
WSL2 Ubuntu, Python 3.12.13, optimum main at 0df84f2.
tests/cli/test_cli.py::TestCLI::test_version_flag: fails on main (optimum-cli --versionexits with status 2, unrecognized argument) and passes with this change.test_env_commandsstill passes.ruff==0.1.5andblack~=23.1(the versions pinned insetup.py) report no changes on both files.optimum-onnxinstalled: one line without it, two lines with it.optimum-cli --helpnow lists the new flag.Before submitting
Who can review?
@IlyasMoutawwakil
AI-assisted (Claude); I reviewed the change and ran the tests above.