Change boolean command line args to inverted flags #541
+9
−7
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.
Using argparse, if an argument is set up like
argparse will cast whatever argument is passed to it, as a string, to a bool. The only string that will cast to
False
in Python is an empty one, so trying to turn this arg off in an intuitive way like--half False
or--half off
or--half 0
or even--half ""
are all actually setting the argument toTrue
(bool("False")
,bool("off")
,bool("0")
,bool("\"\"")
and so on), which is no different from leaving it out entirely.In order to turn an arg set up this way off, you have call it exactly like
--half=""
I went through and changed them into flags like
--no-half
and--no-use_deepspeed
, which is admittedly still a little awkward, but at least doesn't just fail silently anymore.A cleaner way than I did it in this PR is to set the args up like
however this adds a hard dependency on Python 3.9, which I don't want to impose unless something more important already requires it (and I don't know if it does). From a user's perspective it would still work exactly the same way anyway, so to turn off e.g.
--half
you still would pass--no-half
.