Skip to content

Commit

Permalink
Don't use store_xxx on optional bools (#7786)
Browse files Browse the repository at this point in the history
* Don't use `store_xxx` on optional bools

* Refine test

* Refine test
  • Loading branch information
sgugger authored Oct 14, 2020
1 parent a1d1b33 commit bb9559a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/test_xla_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_run_glue(self):
--model_name_or_path=bert-base-cased
--per_device_train_batch_size=64
--per_device_eval_batch_size=64
--evaluate_during_training
--evaluation_strategy steps
--overwrite_cache
""".split()
with patch.object(sys, "argv", testargs):
Expand Down
2 changes: 1 addition & 1 deletion examples/text-classification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ python run_tf_text_classification.py \
--do_eval \
--do_predict \
--logging_steps 10 \
--evaluate_during_training \
--evaluation_strategy steps \
--save_steps 10 \
--overwrite_output_dir \
--max_seq_length 128
Expand Down
3 changes: 2 additions & 1 deletion src/transformers/hf_argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def _add_dataclass_arguments(self, dtype: DataClassType):
if field.default is not dataclasses.MISSING:
kwargs["default"] = field.default
elif field.type is bool or field.type is Optional[bool]:
kwargs["action"] = "store_false" if field.default is True else "store_true"
if field.type is bool or (field.default is not None and field.default is not dataclasses.MISSING):
kwargs["action"] = "store_false" if field.default is True else "store_true"
if field.default is True:
field_name = f"--no-{field.name}"
kwargs["dest"] = field.name
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/training_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class TrainingArguments:
do_eval: bool = field(default=None, metadata={"help": "Whether to run eval on the dev set."})
do_predict: bool = field(default=False, metadata={"help": "Whether to run predictions on the test set."})
evaluate_during_training: bool = field(
default=None,
default=False,
metadata={"help": "Run evaluation during training at each logging step."},
)
evaluation_strategy: EvaluationStrategy = field(
Expand Down
8 changes: 4 additions & 4 deletions valohai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
pass-as: --output_dir={v}
type: string
default: /valohai/outputs
- name: evaluate_during_training
description: Run evaluation during training at each logging step.
type: flag
default: true
- name: evaluation_strategy
description: The evaluation strategy to use.
type: string
default: steps

0 comments on commit bb9559a

Please sign in to comment.