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
1a779ad7
Unverified
Commit
1a779ad7
authored
Aug 24, 2020
by
Jared T Nielsen
Committed by
GitHub
Aug 24, 2020
Browse files
Specify config filename (#6626)
parent
a622705e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
src/transformers/hf_argparser.py
src/transformers/hf_argparser.py
+10
-3
No files found.
src/transformers/hf_argparser.py
View file @
1a779ad7
...
...
@@ -88,7 +88,7 @@ class HfArgumentParser(ArgumentParser):
self
.
add_argument
(
field_name
,
**
kwargs
)
def
parse_args_into_dataclasses
(
self
,
args
=
None
,
return_remaining_strings
=
False
,
look_for_args_file
=
True
self
,
args
=
None
,
return_remaining_strings
=
False
,
look_for_args_file
=
True
,
args_filename
=
None
)
->
Tuple
[
DataClass
,
...]:
"""
Parse command-line args into instances of the specified dataclass types.
...
...
@@ -107,6 +107,9 @@ class HfArgumentParser(ArgumentParser):
If true, will look for a ".args" file with the same base name
as the entry point script for this process, and will append its
potential content to the command line args.
args_filename:
If not None, will uses this file instead of the ".args" file
specified in the previous argument.
Returns:
Tuple consisting of:
...
...
@@ -118,8 +121,12 @@ class HfArgumentParser(ArgumentParser):
- The potential list of remaining argument strings.
(same as argparse.ArgumentParser.parse_known_args)
"""
if
look_for_args_file
and
len
(
sys
.
argv
):
args_file
=
Path
(
sys
.
argv
[
0
]).
with_suffix
(
".args"
)
if
args_filename
or
(
look_for_args_file
and
len
(
sys
.
argv
)):
if
args_filename
:
args_file
=
Path
(
args_filename
)
else
:
args_file
=
Path
(
sys
.
argv
[
0
]).
with_suffix
(
".args"
)
if
args_file
.
exists
():
fargs
=
args_file
.
read_text
().
split
()
args
=
fargs
+
args
if
args
is
not
None
else
fargs
+
sys
.
argv
[
1
:]
...
...
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