You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@joshua.apache.org by mj...@apache.org on 2016/09/14 09:11:28 UTC

[06/43] incubator-joshua git commit: use temporary file name to avoid potential clash

use temporary file name to avoid potential clash


Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/56be05ec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/56be05ec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/56be05ec

Branch: refs/heads/7
Commit: 56be05ec63b964fa06f1a9317c048182e623dddb
Parents: 209f222
Author: Matt Post <po...@cs.jhu.edu>
Authored: Wed Sep 7 16:41:05 2016 -0400
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Wed Sep 7 16:41:05 2016 -0400

----------------------------------------------------------------------
 scripts/training/run_thrax.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/56be05ec/scripts/training/run_thrax.py
----------------------------------------------------------------------
diff --git a/scripts/training/run_thrax.py b/scripts/training/run_thrax.py
index eef2c19..4457245 100755
--- a/scripts/training/run_thrax.py
+++ b/scripts/training/run_thrax.py
@@ -91,13 +91,13 @@ paste(args.source_corpus, args.target_corpus, args.alignment_file, thrax_file)
 run('%s/bin/hadoop fs -put %s %s/input-file' % (HADOOP, thrax_file, THRAXDIR))
 
 # Copy the template
-conf_file_name = 'thrax.conf'
-conf_file = open(conf_file_name, 'w')
+conf_file = tempfile.NamedTemporaryFile(prefix='thrax.conf')
 for line in open(args.thrax_config):
     if not line.startswith('input-file'):
         conf_file.write(line)
 conf_file.write('input-file %s/input-file\n' % (THRAXDIR))
 conf_file.close()
+conf_file_name = conf_file.name
 
 # Run Hadoop
 run('%s/bin/hadoop jar %s -D mapred.child.java.opts="-Xmx%s" -D hadoop.tmp.dir=%s %s %s > thrax.log 2>&1' % (HADOOP, THRAX_JAR, '4g', args.tmp_dir, conf_file_name, THRAXDIR))