diff options
author | Roman Grundkiewicz <romang@amu.edu.pl> | 2018-10-15 09:04:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 09:04:04 +0300 |
commit | 2102120ddb5a0edf68751716bd8222e70356f3f1 (patch) | |
tree | 95c40b779f65effaffe62b9beb2fa6fa3e87c5e8 | |
parent | bb42f22134854d5f872db3ef4c621064db730d43 (diff) | |
parent | 4df5959623b3662f1afe56bd6678e2f83485e83a (diff) |
Merge pull request #15 from marian-nmt/new-relative-paths
Updated tests for new --relative-paths
16 files changed, 131 insertions, 17 deletions
diff --git a/tests/interface/config/.gitignore b/tests/interface/config/.gitignore index ef89cf0..8f2de3a 100644 --- a/tests/interface/config/.gitignore +++ b/tests/interface/config/.gitignore @@ -12,3 +12,5 @@ bestdeep_overwrite booloff booloff.yml +relpaths_input.in +relpaths_nocmd.in diff --git a/tests/interface/config/relative_paths.yml b/tests/interface/config/relpaths.yml index c7cbcd8..c7cbcd8 100644 --- a/tests/interface/config/relative_paths.yml +++ b/tests/interface/config/relpaths.yml diff --git a/tests/interface/config/relpaths_nocmd.in b/tests/interface/config/relpaths_nocmd.in new file mode 100644 index 0000000..90bfcb5 --- /dev/null +++ b/tests/interface/config/relpaths_nocmd.in @@ -0,0 +1 @@ +this is a test diff --git a/tests/interface/config/relpaths_subdir.yml b/tests/interface/config/relpaths_subdir.yml new file mode 100644 index 0000000..45b8d97 --- /dev/null +++ b/tests/interface/config/relpaths_subdir.yml @@ -0,0 +1,5 @@ +relative-paths: true +type: amun +dim-emb: 500 +models: + - ../../../models/wmt16_systems/en-de/model.npz diff --git a/tests/interface/config/relpaths_to_cfgfile.yml b/tests/interface/config/relpaths_to_cfgfile.yml new file mode 100644 index 0000000..bebed03 --- /dev/null +++ b/tests/interface/config/relpaths_to_cfgfile.yml @@ -0,0 +1,9 @@ +relative-paths: true +type: amun +dim-emb: 500 +vocabs: + - ../../../models/wmt16_systems/en-de/vocab.en.json + - ../../../models/wmt16_systems/en-de/vocab.de.json +dim-vocabs: + - 85000 + - 85000 diff --git a/tests/interface/config/subdir/relpaths_input.yml b/tests/interface/config/subdir/relpaths_input.yml new file mode 100644 index 0000000..3692859 --- /dev/null +++ b/tests/interface/config/subdir/relpaths_input.yml @@ -0,0 +1,13 @@ +relative-paths: true +type: amun +dim-emb: 500 +models: + - ../../../../models/wmt16_systems/en-de/model.npz +vocabs: + - ../../../../models/wmt16_systems/en-de/vocab.en.json + - ../../../../models/wmt16_systems/en-de/vocab.de.json +dim-vocabs: + - 85000 + - 85000 +input: + - ../relpaths_input.in diff --git a/tests/interface/config/subdir/relpaths_subdir.yml b/tests/interface/config/subdir/relpaths_subdir.yml new file mode 100644 index 0000000..4c9830d --- /dev/null +++ b/tests/interface/config/subdir/relpaths_subdir.yml @@ -0,0 +1,7 @@ +relative-paths: true +vocabs: + - ../../../../models/wmt16_systems/en-de/vocab.en.json + - ../../../../models/wmt16_systems/en-de/vocab.de.json +dim-vocabs: + - 85000 + - 85000 diff --git a/tests/interface/config/test_dump_config_with_relative_paths.sh b/tests/interface/config/test_dump_config_with_relative_paths.sh index ead1cf4..63db969 100644 --- a/tests/interface/config/test_dump_config_with_relative_paths.sh +++ b/tests/interface/config/test_dump_config_with_relative_paths.sh @@ -6,7 +6,7 @@ set -e rm -rf dump_relpaths.yml # Run with no config file -$MRT_MARIAN/build/marian-decoder -c relative_paths.yml --mini-batch 8 --dump-config > dump_relpaths.yml +$MRT_MARIAN/build/marian-decoder -c relpaths.yml --mini-batch 8 --dump-config > dump_relpaths.yml test -e dump_relpaths.yml diff --git a/tests/interface/config/test_relative_paths.sh b/tests/interface/config/test_relative_paths.sh index 48a134b..2e5b199 100644 --- a/tests/interface/config/test_relative_paths.sh +++ b/tests/interface/config/test_relative_paths.sh @@ -3,13 +3,13 @@ # Exit on error set -e -rm -f relative_paths.log +rm -f relpaths.log # Test code goes here -echo "this is a test" | $MRT_MARIAN/build/marian-decoder -c relative_paths.yml --log relative_paths.log +echo "this is a test" | $MRT_MARIAN/build/marian-decoder -c relpaths.yml --log relpaths.log -test -e relative_paths.log -if ! grep -q "\.\." relative_paths.log; then exit 0; else exit 1; fi +test -e relpaths.log +if ! grep -q "\.\." relpaths.log; then exit 0; else exit 1; fi # Exit with success code exit 0 diff --git a/tests/interface/config/test_relative_paths_apply_only_to_config_files.sh b/tests/interface/config/test_relative_paths_apply_only_to_config_files.sh new file mode 100644 index 0000000..c8ab7d4 --- /dev/null +++ b/tests/interface/config/test_relative_paths_apply_only_to_config_files.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Exit on error +set -e + +rm -f relpaths_to_cfgfile.log + +# Test code goes here +echo "this is a test" | $MRT_MARIAN/build/marian-decoder -c relpaths_to_cfgfile.yml -m ../../../models/wmt16_systems/en-de/model.npz --log relpaths_to_cfgfile.log + +test -e relpaths_to_cfgfile.log + +# Check if relative paths from command-line options are untouched +grep -q "\.\./\.\./\.\./models/wmt16_systems/en-de/model.npz" relpaths_to_cfgfile.log +# Check if relative paths from the config file are expanded +if ! grep -q "\.\./\.\./\.\./models/wmt16_systems/en-de/vocab\...\.json" relpaths_to_cfgfile.log; then exit 0; else exit 1; fi + +# Exit with success code +exit 0 diff --git a/tests/interface/config/test_relative_paths_are_not_applied_to_cmd_options.sh b/tests/interface/config/test_relative_paths_are_not_applied_to_cmd_options.sh new file mode 100644 index 0000000..61de1fe --- /dev/null +++ b/tests/interface/config/test_relative_paths_are_not_applied_to_cmd_options.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Exit on error +set -e + +rm -f relpaths_nocmd.log +mkdir -p subdir + +# Test code goes here +echo "this is a test" > relpaths_nocmd.in + +$MRT_MARIAN/build/marian-decoder -c relpaths.yml -i ./subdir/../relpaths_nocmd.in -o ./subdir/../relpaths_nocmd.out --log relpaths_nocmd.log + +test -e relpaths_nocmd.log +test -e relpaths_nocmd.out + +# Check if relative paths from config files have been expanded +if ! grep -q "\.\./\.\./" relpaths_nocmd.log; then exit 0; else exit 1; fi +# Check if relative paths from command-line have been left untouched +grep -q "\./subdir/\.\." relpaths_nocmd.log + +# Exit with success code +exit 0 diff --git a/tests/interface/config/test_relative_paths_for_each_config_file.sh b/tests/interface/config/test_relative_paths_for_each_config_file.sh new file mode 100644 index 0000000..aa88007 --- /dev/null +++ b/tests/interface/config/test_relative_paths_for_each_config_file.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Exit on error +set -e + +rm -f relpaths_subdir.log + +# Test code goes here +echo "this is a test" | $MRT_MARIAN/build/marian-decoder -c relpaths_subdir.yml subdir/relpaths_subdir.yml --log relpaths_subdir.log + +test -e relpaths_subdir.log + +# Check if there is no relative paths +if ! grep -q "\.\./\.\." relpaths_subdir.log; then exit 0; else exit 1; fi + +# Exit with success code +exit 0 diff --git a/tests/interface/config/test_relative_paths_for_input_in_config_file.sh b/tests/interface/config/test_relative_paths_for_input_in_config_file.sh new file mode 100644 index 0000000..b635a1a --- /dev/null +++ b/tests/interface/config/test_relative_paths_for_input_in_config_file.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Exit on error +set -e + +rm -f relpaths_input.log +mkdir -p subdir + +# Test code goes here +echo "this is a test" > relpaths_input.in + +$MRT_MARIAN/build/marian-decoder -c ./subdir/relpaths_input.yml -o relpaths_input.out --log relpaths_input.log + +test -e relpaths_input.log +test -e relpaths_input.out + +# Check if relative paths from config files have been expanded +if ! grep -q "\.\./\.\./" relpaths_input.log; then exit 0; else exit 1; fi +if ! grep -q "\./subdir/\.\." relpaths_input.log; then exit 0; else exit 1; fi + +# Exit with success code +exit 0 diff --git a/tests/scorer/nbest/test_compare_parallel_and_nbest.sh b/tests/scorer/nbest/test_compare_parallel_and_nbest.sh index 68674cb..f7602df 100644 --- a/tests/scorer/nbest/test_compare_parallel_and_nbest.sh +++ b/tests/scorer/nbest/test_compare_parallel_and_nbest.sh @@ -7,14 +7,12 @@ test -e text.srcall.in || cat text.src.in | sed 'p;p;p;p' > text.srcall.in test -e text.trg.in || cat text.nbest.in | sed 's/ ||| /\t/g' | cut -f2 > text.trg.in # Run scorer -$MRT_MARIAN/build/marian-scorer \ - -c $MRT_MODELS/wmt16_systems/marian.en-de.yml -m en-de/model.npz \ - -t $(pwd)/text.srcall.in $(pwd)/text.trg.in \ +$MRT_MARIAN/build/marian-scorer -c $MRT_MODELS/wmt16_systems/marian.en-de.yml -m $MRT_MODELS/wmt16_systems/en-de/model.npz \ + -t text.srcall.in text.trg.in \ > parallel.scores.out -$MRT_MARIAN/build/marian-scorer \ - -c $MRT_MODELS/wmt16_systems/marian.en-de.yml -m en-de/model.npz \ - --n-best -t $(pwd)/text.src.in $(pwd)/text.nbest.in \ +$MRT_MARIAN/build/marian-scorer -c $MRT_MODELS/wmt16_systems/marian.en-de.yml -m $MRT_MODELS/wmt16_systems/en-de/model.npz \ + --n-best -t text.src.in text.nbest.in \ > parallel.nbest.out cat parallel.nbest.out | sed 's/ ||| /\t/g' | cut -f3 | tr ' ' '\t' | cut -f4 > parallel.nbest.scores.out diff --git a/tests/scorer/nbest/test_custom_feature_name.sh b/tests/scorer/nbest/test_custom_feature_name.sh index a22a38e..5ab0e37 100644 --- a/tests/scorer/nbest/test_custom_feature_name.sh +++ b/tests/scorer/nbest/test_custom_feature_name.sh @@ -4,9 +4,8 @@ set -e # Run scorer -$MRT_MARIAN/build/marian-scorer \ - -c $MRT_MODELS/wmt16_systems/marian.en-de.yml -m en-de/model.npz \ - --n-best --n-best-feature FeatureName -t $(pwd)/text.src.in $(pwd)/text.nbest.in \ +$MRT_MARIAN/build/marian-scorer -c $MRT_MODELS/wmt16_systems/marian.en-de.yml -m $MRT_MODELS/wmt16_systems/en-de/model.npz \ + --n-best --n-best-feature FeatureName -t text.src.in text.nbest.in \ > custom.out grep -c 'FeatureName= ' custom.out diff --git a/tests/scorer/nbest/test_score_nbest_list.sh b/tests/scorer/nbest/test_score_nbest_list.sh index 9e00d72..3ada7cd 100644 --- a/tests/scorer/nbest/test_score_nbest_list.sh +++ b/tests/scorer/nbest/test_score_nbest_list.sh @@ -4,9 +4,8 @@ set -e # Run scorer -$MRT_MARIAN/build/marian-scorer \ - -c $MRT_MODELS/wmt16_systems/marian.en-de.yml -m en-de/model.npz \ - --n-best -t $(pwd)/text.src.in $(pwd)/text.nbest.in \ +$MRT_MARIAN/build/marian-scorer -c $MRT_MODELS/wmt16_systems/marian.en-de.yml -m $MRT_MODELS/wmt16_systems/en-de/model.npz \ + --n-best -t text.src.in text.nbest.in \ > nbest.out $MRT_TOOLS/diff-floats.py nbest.out nbest.expected -p 0.0003 > nbest.diff |