[fix](cli): keep "1" and "0" as integers in kt config set - #2201
Open
Dev-next-gen wants to merge 1 commit into
Open
[fix](cli): keep "1" and "0" as integers in kt config set#2201Dev-next-gen wants to merge 1 commit into
Dev-next-gen wants to merge 1 commit into
Conversation
_parse_value() checked the boolean words before trying int, and "1"/"0" were in that list, so `kt config set advanced.env.CUDA_VISIBLE_DEVICES 1` saved `true` and kt run exported CUDA_VISIBLE_DEVICES=True, while "2" stayed 2. Drop "1"/"0" from the boolean words so they parse as integers.
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?
While reading the kt CLI I noticed that
kt config setstores1and0as booleans._parse_value()inkt-kernel/python/cli/commands/config.pychecks the boolean words before it triesint(), and"1"/"0"are in that list, whereas"2"goes on to become the integer 2.Where this hurts is environment variables. After
the config file contains
CUDA_VISIBLE_DEVICES: true,Settings.get_env_vars()stringifies it, andkt runhands sglangCUDA_VISIBLE_DEVICES=Trueinstead of1. The same goes forOMP_NUM_THREADS 1or anyinference.env.*value set to 1 or 0. I reproduced this on current main by calling_parse_value()andSettingsagainst a temporary config file. I did not launch sglang itself (no NVIDIA GPU on the machine I used), so the last step, CUDA rejectingTrueas a device list, is what I expect rather than something I watched happen.The change drops
"1"and"0"from the boolean words so they fall through to the integer parse.true/false/yes/no/on/offstill give booleans, and0/1keep the same truthiness, so anything that doesif settings.get(...)behaves as before. I grepped the CLI foris True/== Truestyle checks on settings values and found none.The new CPU test
kt-kernel/test/per_commit/test_config_parse_value.pyfails on main withand passes with the change. The boolean-word test passes on both sides. The test writes nothing outside its temporary directory. I ran it without building the extension, through a bare
kt_kernelpackage that only linkspython/cli, so it has not been through thekt-cpurunner yet. I also didn't have black installed; the new lines stay under the 120-column limit.No issue filed for this one.
Before submitting
AI tools used