I have a few arguments added to my argparse parser in my script as below:
parser = argparse.ArgumentParser()
parser.add_argument("--eval_model_dir", type=str, default='',
help="Model directory for evaluation.")
parser.add_argument("--evaluate_during_training", action='store_true',
help="Run evaluation during training at each save_steps.")
I am running the script from command line as below:
python test.py --eval_ dummy_value
Even when the argument passed from the command line, --eval_
, does not match the argument in the script, --eval_model_dir
, the value passed, dummy_value
, is assigned to --eval_model_dir
. If the command line argument is --eval
, I get an error message as following:
error: ambiguous option: --eval could match --evaluate_during_training, --eval_model_dir
.
Based on my reading of the Argparse official documentation, I did not find it mentioned that the command line arguments and the script arguments could be the closest match. Intuitively, I would think that an exact match would be needed. I have following questions:
From the documentation:
class argparse.ArgumentParser(..., allow_abbrev=True, ...)
...
- allow_abbrev - Allows long options to be abbreviated if the abbreviation is unambiguous. (default:
True
)
More info: Argument abbreviations (prefix matching)