Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
63f2b9ab
Unverified
Commit
63f2b9ab
authored
Jul 28, 2021
by
Sylvain Gugger
Committed by
GitHub
Jul 28, 2021
Browse files
Print defaults when using --help for scripts (#12930)
parent
3ec851dc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
src/transformers/hf_argparser.py
src/transformers/hf_argparser.py
+4
-1
No files found.
src/transformers/hf_argparser.py
View file @
63f2b9ab
...
@@ -16,7 +16,7 @@ import dataclasses
...
@@ -16,7 +16,7 @@ import dataclasses
import
json
import
json
import
re
import
re
import
sys
import
sys
from
argparse
import
ArgumentParser
,
ArgumentTypeError
from
argparse
import
ArgumentDefaultsHelpFormatter
,
ArgumentParser
,
ArgumentTypeError
from
enum
import
Enum
from
enum
import
Enum
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Any
,
Iterable
,
List
,
NewType
,
Optional
,
Tuple
,
Union
from
typing
import
Any
,
Iterable
,
List
,
NewType
,
Optional
,
Tuple
,
Union
...
@@ -59,6 +59,9 @@ class HfArgumentParser(ArgumentParser):
...
@@ -59,6 +59,9 @@ class HfArgumentParser(ArgumentParser):
kwargs:
kwargs:
(Optional) Passed to `argparse.ArgumentParser()` in the regular way.
(Optional) Passed to `argparse.ArgumentParser()` in the regular way.
"""
"""
# To make the default appear when using --help
if
"formatter_class"
not
in
kwargs
:
kwargs
[
"formatter_class"
]
=
ArgumentDefaultsHelpFormatter
super
().
__init__
(
**
kwargs
)
super
().
__init__
(
**
kwargs
)
if
dataclasses
.
is_dataclass
(
dataclass_types
):
if
dataclasses
.
is_dataclass
(
dataclass_types
):
dataclass_types
=
[
dataclass_types
]
dataclass_types
=
[
dataclass_types
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment