Skip to content

Commit

Permalink
change to show the error logs when jobs are failed
Browse files Browse the repository at this point in the history
  • Loading branch information
kamo-naoyuki committed May 12, 2022
1 parent bb0d0aa commit 98689a5
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 123 deletions.
4 changes: 2 additions & 2 deletions egs2/TEMPLATE/asr1/scripts/utils/evaluate_asr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then

# 2. Submit decoding jobs
log "Decoding started... log: '${logdir}/asr_inference.*.log'"
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${_cmd} --gpu "${_ngpu}" JOB=1:"${_nj}" "${logdir}"/asr_inference.JOB.log \
python3 -m espnet2.bin.asr_inference \
--ngpu "${_ngpu}" \
--data_path_and_name_and_type "${wavscp},speech,sound" \
--key_file "${logdir}"/keys.JOB.scp \
--output_dir "${logdir}"/output.JOB \
"${_opts[@]}" ${inference_args}
"${_opts[@]}" ${inference_args} || { cat $(grep -l -i error "${logdir}"/asr_inference.*.log) ; exit 1; }

# 3. Concatenates the output files from each jobs
for f in token token_int score text; do
Expand Down
8 changes: 4 additions & 4 deletions egs2/TEMPLATE/diar1/diar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ if ! "${skip_train}"; then
# NOTE: --*_shape_file doesn't require length information if --batch_type=unsorted,
# but it's used only for deciding the sample ids.

# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${train_cmd} JOB=1:"${_nj}" "${_logdir}"/stats.JOB.log \
${python} -m espnet2.bin.diar_train \
--collect_stats true \
Expand All @@ -360,7 +360,7 @@ if ! "${skip_train}"; then
--train_shape_file "${_logdir}/train.JOB.scp" \
--valid_shape_file "${_logdir}/valid.JOB.scp" \
--output_dir "${_logdir}/stats.JOB" \
${_opts} ${diar_args} || { cat "${_logdir}"/stats.1.log; exit 1; }
${_opts} ${diar_args} || { cat $(grep -l -i error "${_logdir}"/stats.*.log) ; exit 1; }

# 4. Aggregate shape files
_opts=
Expand Down Expand Up @@ -510,7 +510,7 @@ if ! "${skip_eval}"; then

# 2. Submit inference jobs
log "Diarization started... log: '${_logdir}/diar_inference.*.log'"
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${_cmd} --gpu "${_ngpu}" JOB=1:"${_nj}" "${_logdir}"/diar_inference.JOB.log \
${python} -m espnet2.bin.diar_inference \
--ngpu "${_ngpu}" \
Expand All @@ -520,7 +520,7 @@ if ! "${skip_eval}"; then
--train_config "${diar_exp}"/config.yaml \
--model_file "${diar_exp}"/"${inference_model}" \
--output_dir "${_logdir}"/output.JOB \
${_opts}
${_opts} || { cat $(grep -l -i error "${_logdir}"/diar_inference.*.log) ; exit 1; }

# 3. Concatenates the output files from each jobs
for i in $(seq "${_nj}"); do
Expand Down
8 changes: 4 additions & 4 deletions egs2/TEMPLATE/enh1/enh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ if ! "${skip_train}"; then
# but it's used only for deciding the sample ids.


# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${train_cmd} JOB=1:"${_nj}" "${_logdir}"/stats.JOB.log \
${python} -m espnet2.bin.enh_train \
--collect_stats true \
Expand All @@ -504,7 +504,7 @@ if ! "${skip_train}"; then
--train_shape_file "${_logdir}/train.JOB.scp" \
--valid_shape_file "${_logdir}/valid.JOB.scp" \
--output_dir "${_logdir}/stats.JOB" \
${_opts} ${enh_args} || { cat "${_logdir}"/stats.1.log; exit 1; }
${_opts} ${enh_args} || { cat $(grep -l -i error "${_logdir}"/stats.*.log) ; exit 1; }

# 4. Aggregate shape files
_opts=
Expand Down Expand Up @@ -652,7 +652,7 @@ if ! "${skip_eval}"; then

# 2. Submit inference jobs
log "Enhancement started... log: '${_logdir}/enh_inference.*.log'"
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${_cmd} --gpu "${_ngpu}" JOB=1:"${_nj}" "${_logdir}"/enh_inference.JOB.log \
${python} -m espnet2.bin.enh_inference \
--ngpu "${_ngpu}" \
Expand All @@ -663,7 +663,7 @@ if ! "${skip_eval}"; then
${inference_enh_config:+--inference_config "$inference_enh_config"} \
--model_file "${enh_exp}"/"${inference_model}" \
--output_dir "${_logdir}"/output.JOB \
${_opts} ${inference_args}
${_opts} ${inference_args} || { cat $(grep -l -i error "${_logdir}"/enh_inference.*.log) ; exit 1; }


_spk_list=" "
Expand Down
12 changes: 6 additions & 6 deletions egs2/TEMPLATE/enh_asr1/enh_asr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ if ! "${skip_train}"; then
log "LM collect-stats started... log: '${_logdir}/stats.*.log'"
# NOTE: --*_shape_file doesn't require length information if --batch_type=unsorted,
# but it's used only for deciding the sample ids.
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${train_cmd} JOB=1:"${_nj}" "${_logdir}"/stats.JOB.log \
${python} -m espnet2.bin.lm_train \
--collect_stats true \
Expand All @@ -810,7 +810,7 @@ if ! "${skip_train}"; then
--train_shape_file "${_logdir}/train.JOB.scp" \
--valid_shape_file "${_logdir}/dev.JOB.scp" \
--output_dir "${_logdir}/stats.JOB" \
${_opts} ${lm_args} || { cat "${_logdir}"/stats.1.log; exit 1; }
${_opts} ${lm_args} || { cat $(grep -l -i error "${_logdir}"/stats.*.log) ; exit 1; }

# 4. Aggregate shape files
_opts=
Expand Down Expand Up @@ -937,7 +937,7 @@ if ! "${skip_train}"; then
if "${use_ngram}"; then
log "Stage 9: Ngram Training: train_set=${data_feats}/lm_train.txt"
cut -f 2 -d " " ${data_feats}/lm_train.txt | lmplz -S "20%" --discount_fallback -o ${ngram_num} - >${ngram_exp}/${ngram_num}gram.arpa
build_binary -s ${ngram_exp}/${ngram_num}gram.arpa ${ngram_exp}/${ngram_num}gram.bin
build_binary -s ${ngram_exp}/${ngram_num}gram.arpa ${ngram_exp}/${ngram_num}gram.bin
else
log "Stage 9: Skip ngram stages: use_ngram=${use_ngram}"
fi
Expand Down Expand Up @@ -1335,7 +1335,7 @@ if ! "${skip_eval}"; then

# 2. Submit inference jobs
log "Enhancement started... log: '${_logdir}/enh_inference.*.log'"
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${_cmd} --gpu "${_ngpu}" JOB=1:"${_nj}" "${_logdir}"/enh_inference.JOB.log \
${python} -m espnet2.bin.enh_inference \
--enh_s2t_task true \
Expand All @@ -1347,7 +1347,7 @@ if ! "${skip_eval}"; then
${inference_enh_config:+--inference_config "$inference_enh_config"} \
--model_file "${enh_asr_exp}"/"${inference_enh_asr_model}" \
--output_dir "${_logdir}"/output.JOB \
${_opts} ${enh_inference_args}
${_opts} ${enh_inference_args} || { cat $(grep -l -i error "${_logdir}"/enh_inference.*.log) ; exit 1; }

# 3. Concatenates the output files from each jobs
_spk_list=" "
Expand Down Expand Up @@ -1632,7 +1632,7 @@ if ! "${skip_upload_hf}"; then
# Generate description file
# shellcheck disable=SC2034
hf_task=speech-enhancement-recognition
# shellcheck disable=SC2034
# shellcheck disable=SC2034
espnet_task=EnhS2T
# shellcheck disable=SC2034
task_exp=${enh_asr_exp}
Expand Down
32 changes: 16 additions & 16 deletions egs2/TEMPLATE/enh_st1/enh_st.sh
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ if ! "${skip_data_prep}"; then
done
utils/combine_data.sh --extra_files "${utt_extra_files} ${_scp_list}" "data/${train_set}_sp" ${_dirs}
for extra_file in ${utt_extra_files}; do
python pyscripts/utils/remove_duplicate_keys.py data/"${train_set}_sp"/${extra_file} > data/"${train_set}_sp"/${extra_file}.tmp
python pyscripts/utils/remove_duplicate_keys.py data/"${train_set}_sp"/${extra_file} > data/"${train_set}_sp"/${extra_file}.tmp
mv data/"${train_set}_sp"/${extra_file}.tmp data/"${train_set}_sp"/${extra_file}
done
else
Expand Down Expand Up @@ -593,7 +593,7 @@ if ! "${skip_data_prep}"; then
fi
cp ${single_file} "${data_feats}${_suf}/${dset}"
expand_utt_extra_files="${expand_utt_extra_files} $(basename ${single_file})"
done
done
done
echo "${expand_utt_extra_files}"
utils/fix_data_dir.sh --utt_extra_files "${expand_utt_extra_files}" "${data_feats}${_suf}/${dset}"
Expand Down Expand Up @@ -727,9 +727,9 @@ if ! "${skip_data_prep}"; then
utils/fix_data_dir.sh --utt_extra_files "${utt_extra_files}" "${data_feats}/${dset}"
for utt_extra_file in ${utt_extra_files}; do
python pyscripts/utils/remove_duplicate_keys.py ${data_feats}/${dset}/${utt_extra_file} \
> ${data_feats}/${dset}/${utt_extra_file}.tmp
> ${data_feats}/${dset}/${utt_extra_file}.tmp
mv ${data_feats}/${dset}/${utt_extra_file}.tmp ${data_feats}/${dset}/${utt_extra_file}
done
done
done

# shellcheck disable=SC2002
Expand Down Expand Up @@ -934,7 +934,7 @@ if ! "${skip_train}"; then
log "LM collect-stats started... log: '${_logdir}/stats.*.log'"
# NOTE: --*_shape_file doesn't require length information if --batch_type=unsorted,
# but it's used only for deciding the sample ids.
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${train_cmd} JOB=1:"${_nj}" "${_logdir}"/stats.JOB.log \
${python} -m espnet2.bin.lm_train \
--collect_stats true \
Expand All @@ -950,7 +950,7 @@ if ! "${skip_train}"; then
--train_shape_file "${_logdir}/train.JOB.scp" \
--valid_shape_file "${_logdir}/dev.JOB.scp" \
--output_dir "${_logdir}/stats.JOB" \
${_opts} ${lm_args} || { cat "${_logdir}"/stats.1.log; exit 1; }
${_opts} ${lm_args} || { cat $(grep -l -i error "${_logdir}"/stats.*.log) ; exit 1; }

# 4. Aggregate shape files
_opts=
Expand Down Expand Up @@ -1078,7 +1078,7 @@ if ! "${skip_train}"; then
if "${use_ngram}"; then
log "Stage 9: Ngram Training: train_set=${data_feats}/lm_train.txt"
cut -f 2 -d " " ${data_feats}/lm_train.txt | lmplz -S "20%" --discount_fallback -o ${ngram_num} - >${ngram_exp}/${ngram_num}gram.arpa
build_binary -s ${ngram_exp}/${ngram_num}gram.arpa ${ngram_exp}/${ngram_num}gram.bin
build_binary -s ${ngram_exp}/${ngram_num}gram.arpa ${ngram_exp}/${ngram_num}gram.bin
else
log "Stage 9: Skip ngram stages: use_ngram=${use_ngram}"
fi
Expand Down Expand Up @@ -1148,7 +1148,7 @@ if ! "${skip_train}"; then
# but it's used only for deciding the sample ids.

# TODO(jiatong): fix different bpe model
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${train_cmd} JOB=1:"${_nj}" "${_logdir}"/stats.JOB.log \
${python} -m espnet2.bin.enh_s2t_train \
--collect_stats true \
Expand All @@ -1173,7 +1173,7 @@ if ! "${skip_train}"; then
--train_shape_file "${_logdir}/train.JOB.scp" \
--valid_shape_file "${_logdir}/valid.JOB.scp" \
--output_dir "${_logdir}/stats.JOB" \
${_opts} ${enh_st_args} || { cat "${_logdir}"/stats.1.log; exit 1; }
${_opts} ${enh_st_args} || { cat $(grep -l -i error "${_logdir}"/stats.*.log) ; exit 1; }

# 4. Aggregate shape files
_opts=
Expand Down Expand Up @@ -1436,7 +1436,7 @@ if ! "${skip_eval}"; then

# 2. Submit decoding jobs
log "Decoding started... log: '${_logdir}/st_inference.*.log'"
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${_cmd} --gpu "${_ngpu}" JOB=1:"${_nj}" "${_logdir}"/st_inference.JOB.log \
${python} -m ${st_inference_tool} \
--enh_s2t_task true \
Expand All @@ -1447,7 +1447,7 @@ if ! "${skip_eval}"; then
--st_train_config "${enh_st_exp}"/config.yaml \
--st_model_file "${enh_st_exp}"/"${inference_enh_st_model}" \
--output_dir "${_logdir}"/output.JOB \
${_opts} ${st_inference_args}
${_opts} ${st_inference_args} || { cat $(grep -l -i error "${_logdir}"/st_inference.*.log) ; exit 1; }

# 3. Concatenates the output files from each jobs
for f in token token_int score text; do
Expand Down Expand Up @@ -1773,11 +1773,11 @@ if ! "${skip_upload_hf}"; then
gitlfs=$(git lfs --version 2> /dev/null || true)
[ -z "${gitlfs}" ] && \
log "ERROR: You need to install git-lfs first" && \
exit 1
exit 1

dir_repo=${expdir}/hf_${hf_repo//"/"/"_"}
[ ! -d "${dir_repo}" ] && git clone https://huggingface.co/${hf_repo} ${dir_repo}

if command -v git &> /dev/null; then
_creator_name="$(git config user.name)"
_checkout="git checkout $(git show -s --format=%H)"
Expand All @@ -1790,13 +1790,13 @@ if ! "${skip_upload_hf}"; then
# foo/asr1 -> foo
_corpus="${_task%/*}"
_model_name="${_creator_name}/${_corpus}_$(basename ${packed_model} .zip)"

# copy files in ${dir_repo}
unzip -o ${packed_model} -d ${dir_repo}
# Generate description file
# shellcheck disable=SC2034
hf_task=speech-enhancement-translation
# shellcheck disable=SC2034
# shellcheck disable=SC2034
espnet_task=EnhS2T
# shellcheck disable=SC2034
task_exp=${enh_st_exp}
Expand Down
32 changes: 16 additions & 16 deletions egs2/TEMPLATE/mt1/mt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ if ! "${skip_data_prep}"; then
log "Stage 1: Data preparation for data/${train_set}, data/${valid_set}, etc."
# [Task dependent] Need to create data.sh for new corpus
local/data.sh ${local_data_opts}

fi

if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
Expand All @@ -474,7 +474,7 @@ if ! "${skip_data_prep}"; then
# with regex to suuport multi-references
for single_file in $(ls data/"${dset}"/${extra_file}*); do
cp ${single_file} "${data_feats}${_suf}/${dset}"
done
done
done
echo "${feats_type}" > "${data_feats}${_suf}/${dset}/feats_type"
done
Expand Down Expand Up @@ -702,7 +702,7 @@ if ! "${skip_train}"; then
log "LM collect-stats started... log: '${_logdir}/stats.*.log'"
# NOTE: --*_shape_file doesn't require length information if --batch_type=unsorted,
# but it's used only for deciding the sample ids.
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${train_cmd} JOB=1:"${_nj}" "${_logdir}"/stats.JOB.log \
${python} -m espnet2.bin.lm_train \
--collect_stats true \
Expand All @@ -718,7 +718,7 @@ if ! "${skip_train}"; then
--train_shape_file "${_logdir}/train.JOB.scp" \
--valid_shape_file "${_logdir}/dev.JOB.scp" \
--output_dir "${_logdir}/stats.JOB" \
${_opts} ${lm_args} || { cat "${_logdir}"/stats.1.log; exit 1; }
${_opts} ${lm_args} || { cat $(grep -l -i error "${_logdir}"/stats.*.log) ; exit 1; }

# 4. Aggregate shape files
_opts=
Expand Down Expand Up @@ -845,7 +845,7 @@ if ! "${skip_train}"; then
if "${use_ngram}"; then
log "Stage 8: Ngram Training: train_set=${data_feats}/lm_train.txt"
cut -f 2 -d " " ${data_feats}/lm_train.txt | lmplz -S "20%" --discount_fallback -o ${ngram_num} - >${ngram_exp}/${ngram_num}gram.arpa
build_binary -s ${ngram_exp}/${ngram_num}gram.arpa ${ngram_exp}/${ngram_num}gram.bin
build_binary -s ${ngram_exp}/${ngram_num}gram.arpa ${ngram_exp}/${ngram_num}gram.bin
else
log "Stage 8: Skip ngram stages: use_ngram=${use_ngram}"
fi
Expand Down Expand Up @@ -1132,7 +1132,7 @@ if ! "${skip_eval}"; then

# 2. Submit decoding jobs
log "Decoding started... log: '${_logdir}/mt_inference.*.log'"
# shellcheck disable=SC2086
# shellcheck disable=SC2046,SC2086
${_cmd} --gpu "${_ngpu}" JOB=1:"${_nj}" "${_logdir}"/mt_inference.JOB.log \
${python} -m ${mt_inference_tool} \
--batch_size ${batch_size} \
Expand All @@ -1142,7 +1142,7 @@ if ! "${skip_eval}"; then
--mt_train_config "${mt_exp}"/config.yaml \
--mt_model_file "${mt_exp}"/"${inference_mt_model}" \
--output_dir "${_logdir}"/output.JOB \
${_opts} ${inference_args}
${_opts} ${inference_args} || { cat $(grep -l -i error "${_logdir}"/mt_inference.*.log) ; exit 1; }

# 3. Concatenates the output files from each jobs
for f in token token_int score text; do
Expand Down Expand Up @@ -1205,7 +1205,7 @@ if ! "${skip_eval}"; then
# ) \
# <(<"${_data}/text.${tgt_case}.${tgt_lang}" awk '{ print "(" $2 "-" $1 ")" }') \
# >"${_scoredir}/hyp.trn.org"

# remove utterance id
#perl -pe 's/\([^\)]+\)//g;' "${_scoredir}/ref.trn.org" > "${_scoredir}/ref.trn"
#perl -pe 's/\([^\)]+\)//g;' "${_scoredir}/hyp.trn.org" > "${_scoredir}/hyp.trn"
Expand All @@ -1220,7 +1220,7 @@ if ! "${skip_eval}"; then
-i "${_scoredir}/hyp.trn.detok" \
-m bleu chrf ter \
>> ${_scoredir}/result.tc.txt

log "Write a case-sensitive BLEU (single-reference) result in ${_scoredir}/result.tc.txt"
fi

Expand Down Expand Up @@ -1252,8 +1252,8 @@ if ! "${skip_eval}"; then
) \
<(<"${_data}/text.${tgt_case}.${tgt_lang}" awk '{ print "(" $2 "-" $1 ")" }') \
>"${_scoredir}/ref.trn.org.${ref_idx}"
#

#
perl -pe 's/\([^\)]+\)//g;' "${_scoredir}/ref.trn.org.${ref_idx}" > "${_scoredir}/ref.trn.${ref_idx}"
detokenizer.perl -l ${tgt_lang} -q < "${_scoredir}/ref.trn.${ref_idx}" > "${_scoredir}/ref.trn.detok.${ref_idx}"
remove_punctuation.pl < "${_scoredir}/ref.trn.detok.${ref_idx}" > "${_scoredir}/ref.trn.detok.lc.rm.${ref_idx}"
Expand Down Expand Up @@ -1386,11 +1386,11 @@ if ! "${skip_upload_hf}"; then
gitlfs=$(git lfs --version 2> /dev/null || true)
[ -z "${gitlfs}" ] && \
log "ERROR: You need to install git-lfs first" && \
exit 1
exit 1

dir_repo=${expdir}/hf_${hf_repo//"/"/"_"}
[ ! -d "${dir_repo}" ] && git clone https://huggingface.co/${hf_repo} ${dir_repo}

if command -v git &> /dev/null; then
_creator_name="$(git config user.name)"
_checkout="git checkout $(git show -s --format=%H)"
Expand All @@ -1403,13 +1403,13 @@ if ! "${skip_upload_hf}"; then
# foo/asr1 -> foo
_corpus="${_task%/*}"
_model_name="${_creator_name}/${_corpus}_$(basename ${packed_model} .zip)"

# copy files in ${dir_repo}
unzip -o ${packed_model} -d ${dir_repo}
# Generate description file
# shellcheck disable=SC2034
hf_task=machine-translation
# shellcheck disable=SC2034
# shellcheck disable=SC2034
espnet_task=MT
# shellcheck disable=SC2034
task_exp=${mt_exp}
Expand Down
Loading

0 comments on commit 98689a5

Please sign in to comment.