forked from lspector/Clojush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster_launcher.py
52 lines (36 loc) · 1.6 KB
/
cluster_launcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os, stat
# Settings
number_runs = 10
clojush_directory = "/home/thelmuth/Clojush/"
output_directory = "../Results/odd/"
output_prefix = "log"
output_postfix = ".txt"
title_string = "Test of cluster runs with odd problem"
command = "/home/thelmuth/bin/lein run clojush.examples.odd"
##########################################################################
# You don't need to change anything below here
# Check to make sure directory doesn't exist; if not, create it
if os.path.isdir(clojush_directory + output_directory):
raise RuntimeError, "Output directory already exists"
os.mkdir(clojush_directory + output_directory)
# Make alf file
alf_file_string = output_directory + "clojush_runs.alf"
alf_f = open(alf_file_string, "w")
alfcode = """##AlfredToDo 3.0
Job -title {%s} -subtasks {
""" % (title_string)
for run in range(0, number_runs):
intro_command = "echo Starting run;export PATH=$PATH:/usr/java/latest/bin; cd %s;" % (clojush_directory)
outro_command = " > %s%s%i%s; echo Finished Run" % (output_directory, output_prefix, run, output_postfix)
full_command = intro_command + command + outro_command
alfcode += """ Task -title {%s - run %i} -cmds {
RemoteCmd {/bin/sh -c "%s"} -service {cluster}
}
""" % (title_string, run, full_command)
alfcode += "}\n"
alf_f.writelines(alfcode)
alf_f.close()
# Run tractor command
source_string = "source /etc/sysconfig/pixar"
pixar_string = "/opt/pixar/tractor-blade-1.6.3/python/bin/python2.6 /opt/pixar/tractor-blade-1.6.3/tractor-spool.py --engine=fly:8000"
os.system("%s;%s %s" % (source_string, pixar_string, alf_file_string))