Repository navigation
Expand file tree
/
Copy pathsubmit.py
More file actions
57 lines (43 loc) · 1.96 KB
/
Copy pathsubmit.py
File metadata and controls
57 lines (43 loc) · 1.96 KB
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
53
54
55
56
57
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
import sys
import os
import subprocess
import multiprocessing
#--------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------
def worker(cmd):
print("Calling process: %s" % cmd)
ret = subprocess.call(cmd, shell=True)
return (ret)
#--------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------
# Main function
if __name__ == "__main__":
FROM = int(sys.argv[1]) - 1
TO = int(sys.argv[2])
FEATS = sys.argv[3]
print("---------------------------------------------------")
print(" **** Meta-features extraction ***** ")
print("---------------------------------------------------")
print(" *** Datasets extracted ***")
print("@ From: %d" % FROM)
print("@ To: %d" % TO)
print("@ Features: %s" % FEATS)
print("---------------------------------------------------")
datasets = os.listdir("data/datasets")
sub = [data.replace(".arff", "") for data in datasets[FROM:TO]]
before = "R CMD BATCH --no-save --no-restore '--args' --datafile="
after = " --option=" + FEATS +" mainExtraction.R out_"
log = "_" + FEATS + ".log &"
# binding commands
commands = [before + data + after + data + log for data in sub]
# for cmd in commands:
# print(cmd)
# Calling commands over Pool
pool = multiprocessing.Pool(None)
r = pool.map_async(worker, commands)
r.wait()
print(" Done !!!")
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------