mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-25 15:33:20 +03:00
indexers: log translation errors
This commit is contained in:
parent
de60de001e
commit
d9b0d15eef
@ -13,18 +13,27 @@
|
||||
utils.writePureShellScript
|
||||
[coreutils translate jq python3]
|
||||
''
|
||||
jobJson=$1
|
||||
job_nr=$2
|
||||
time=$(date +%s)
|
||||
runtime=$(($time - $start_time))
|
||||
average_runtime=$(python3 -c "print($runtime / $job_nr)")
|
||||
total_remaining_time=$(python3 -c "print($average_runtime * ($num_jobs - $job_nr))")
|
||||
echo "starting job nr. $job_nr; average job runtime: $average_runtime sec; remaining time: $total_remaining_time sec"
|
||||
translate $1 $targetDir || echo "Failed to translate $1"
|
||||
|
||||
# if job fails, store error in ./translation-errors/$jobId.log
|
||||
translate $jobJson $targetDir &> $TMPDIR/log \
|
||||
|| (
|
||||
echo "Failed to translate $1"
|
||||
mkdir -p ./translation-errors
|
||||
jobId=$(jq '.id' -c -r <(echo "$jobJson"))
|
||||
cp $TMPDIR/log ./translation-errors/$jobId.log
|
||||
)
|
||||
'';
|
||||
in
|
||||
utils.writePureShellScriptBin
|
||||
"translate-index"
|
||||
[coreutils translate jq parallel]
|
||||
[coreutils translate jq parallel python3]
|
||||
''
|
||||
set -e
|
||||
usage="usage:
|
||||
@ -65,4 +74,6 @@ in
|
||||
|
||||
runtime=$(($(date +%s) - $start_time))
|
||||
echo "FINISHED! Executed $num_jobs jobs in $runtime seconds"
|
||||
|
||||
python3 ${./summarize-stats.py} translation-errors.json
|
||||
''
|
||||
|
11
src/apps/translate-index/summarize-stats.py
Normal file
11
src/apps/translate-index/summarize-stats.py
Normal file
@ -0,0 +1,11 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
failed_proj_ids = list(os.listdir('translation-errors'))
|
||||
if failed_proj_ids:
|
||||
print("saving list of failed projects in ./translation-errors.json")
|
||||
print("failure logs can be found in ./translation-errors/")
|
||||
with open(sys.argv[1], 'w') as f:
|
||||
json.dump(failed_proj_ids, f, indent=2)
|
Loading…
Reference in New Issue
Block a user