Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Use comma as filename separator (#5506)
Browse files Browse the repository at this point in the history
* Use comma as filename separator

* update tests and changelog
  • Loading branch information
AkshitaB authored Dec 11, 2021
1 parent e0ee7f4 commit 38436d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed the name that the `push-to-hf` command uses to store weights.
- `FBetaMultiLabelMeasure` now works with multiple dimensions
- Support for inferior operating systems when making hardlinks
- Use `,` as a separator for filenames in the `evaluate` command, thus allowing for URLs (eg. `gs://...`) as input files.

### Removed

Expand Down
12 changes: 6 additions & 6 deletions allennlp/commands/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def add_subparser(self, parser: argparse._SubParsersAction) -> argparse.Argument
type=str,
help=(
"path to the file containing the evaluation data"
' (for mutiple files, put ":" between filenames e.g., input1.txt:input2.txt)'
' (for mutiple files, put "," between filenames e.g., input1.txt,input2.txt)'
),
)

Expand All @@ -46,7 +46,7 @@ def add_subparser(self, parser: argparse._SubParsersAction) -> argparse.Argument
type=str,
help=(
"optional path to write the metrics to as JSON"
' (for mutiple files, put ":" between filenames e.g., output1.txt:output2.txt)'
' (for mutiple files, put "," between filenames e.g., output1.txt,output2.txt)'
),
)

Expand All @@ -55,7 +55,7 @@ def add_subparser(self, parser: argparse._SubParsersAction) -> argparse.Argument
type=str,
help=(
"optional path to write the predictions to as JSON lines"
' (for mutiple files, put ":" between filenames e.g., output1.jsonl:output2.jsonl)'
' (for mutiple files, put "," between filenames e.g., output1.jsonl,output2.jsonl)'
),
)

Expand Down Expand Up @@ -145,14 +145,14 @@ def evaluate_from_args(args: argparse.Namespace) -> Dict[str, Any]:
dataset_reader = archive.validation_dataset_reader

# split files
evaluation_data_path_list = args.input_file.split(":")
evaluation_data_path_list = args.input_file.split(",")
if args.output_file is not None:
output_file_list = args.output_file.split(":")
output_file_list = args.output_file.split(",")
assert len(output_file_list) == len(
evaluation_data_path_list
), "The number of `output_file` paths must be equal to the number of datasets being evaluated."
if args.predictions_output_file is not None:
predictions_output_file_list = args.predictions_output_file.split(":")
predictions_output_file_list = args.predictions_output_file.split(",")
assert len(predictions_output_file_list) == len(evaluation_data_path_list), (
"The number of `predictions_output_file` paths must be equal"
+ "to the number of datasets being evaluated. "
Expand Down
6 changes: 3 additions & 3 deletions tests/commands/evaluate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ def test_multiple_output_files_evaluate_from_args(self):
self.FIXTURES_ROOT / "simple_tagger_with_span_f1" / "serialization" / "model.tar.gz"
),
str(self.FIXTURES_ROOT / "data" / "conll2003.txt")
+ ":"
+ ","
+ str(self.FIXTURES_ROOT / "data" / "conll2003.txt"),
"--cuda-device",
"-1",
"--output-file",
output_file + ":" + output_file,
output_file + "," + output_file,
"--predictions-output-file",
predictions_output_file + ":" + predictions_output_file,
predictions_output_file + "," + predictions_output_file,
]
args = self.parser.parse_args(kebab_args)
computed_metrics = evaluate_from_args(args)
Expand Down

0 comments on commit 38436d8

Please sign in to comment.