Replace assertions with ValueError exception (#14142)
Updated masked-language modeling examples in pytorch with convention defined by #12789
This commit is contained in:
@@ -188,10 +188,12 @@ class DataTrainingArguments:
|
|||||||
else:
|
else:
|
||||||
if self.train_file is not None:
|
if self.train_file is not None:
|
||||||
extension = self.train_file.split(".")[-1]
|
extension = self.train_file.split(".")[-1]
|
||||||
assert extension in ["csv", "json", "txt"], "`train_file` should be a csv, a json or a txt file."
|
if extension not in ["csv", "json", "txt"]:
|
||||||
|
raise ValueError("`train_file` should be a csv, a json or a txt file.")
|
||||||
if self.validation_file is not None:
|
if self.validation_file is not None:
|
||||||
extension = self.validation_file.split(".")[-1]
|
extension = self.validation_file.split(".")[-1]
|
||||||
assert extension in ["csv", "json", "txt"], "`validation_file` should be a csv, a json or a txt file."
|
if extension not in ["csv", "json", "txt"]:
|
||||||
|
raise ValueError("`validation_file` should be a csv, a json or a txt file.")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@@ -201,10 +201,12 @@ def parse_args():
|
|||||||
else:
|
else:
|
||||||
if args.train_file is not None:
|
if args.train_file is not None:
|
||||||
extension = args.train_file.split(".")[-1]
|
extension = args.train_file.split(".")[-1]
|
||||||
assert extension in ["csv", "json", "txt"], "`train_file` should be a csv, json or txt file."
|
if extension not in ["csv", "json", "txt"]:
|
||||||
|
raise ValueError("`train_file` should be a csv, json or txt file.")
|
||||||
if args.validation_file is not None:
|
if args.validation_file is not None:
|
||||||
extension = args.validation_file.split(".")[-1]
|
extension = args.validation_file.split(".")[-1]
|
||||||
assert extension in ["csv", "json", "txt"], "`validation_file` should be a csv, json or txt file."
|
if extension not in ["csv", "json", "txt"]:
|
||||||
|
raise ValueError("`validation_file` should be a csv, json or txt file.")
|
||||||
|
|
||||||
if args.push_to_hub:
|
if args.push_to_hub:
|
||||||
assert args.output_dir is not None, "Need an `output_dir` to create a repo when `--push_to_hub` is passed."
|
assert args.output_dir is not None, "Need an `output_dir` to create a repo when `--push_to_hub` is passed."
|
||||||
|
|||||||
Reference in New Issue
Block a user