Python wrapper for running instances of trisurf-ng
Samo Penic
2017-01-15 d55834e161e1f79b7685bb56202f48914b083364
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
#!/usr/bin/python3
from trisurf import trisurf
from trisurf import tsmgr
 
from trisurf import analyses
 
 
#Ok... Configure your keys:
#ssh-keygen
#and copy them to all the remote hosts
#ssh-copy-id -i ./ssh/id_rsa.pub username@remotehost
 
run2=trisurf.Runner(tape='tape')
run2.setMaindir(("N","k","V","Np","Nm"),("nshell","xk0","constvolswitch","npoly","nmono"))
run2.setSubdir("run1")
 
run3=trisurf.Runner(tape='tape')
run3.setMaindir(("N","k","V","Np","Nm"),("nshell","xk0","constvolswitch","npoly","nmono"))
run3.setSubdir("run2")
 
 
Runs=[run2, run3]
 
#this is how analyses are defined
def analyze(run, **kwargs):
    host=kwargs.get('host', None)
    print("Demo analysis")
    print("Analysis on host "+host['name']+" for run "+run.Dir.fullpath()+" completed")
    print("here comes info on the run variable:")
    print(run)
    print("here comes info on the host variable:")
    print(host)
    print("here comes info on the hosts variable:")
    print(kwargs.get('hosts',None))
    print("here comes info on the args variable:")
    print(kwargs.get('args',None))
 
def testWebAnalysis(run, **kwargs):
    print("Simulations are located in "+run.Dir.fullpath())
    print("\n\nStatistics file:")
    print(run.Statistics.readText())
 
hosts=({'name':'natalie','address':'kabinet.penic.eu', 'runs':Runs, 'username':'samo', 'remotebasepath':'simulations-test/subdir/subdir'},
    {'name':'Hestia','address':'127.0.0.1', 'runs':Runs, 'username':'samo'})
analyses={'analysis1':analyze,'webReport':testWebAnalysis,'runningavg':analyses.plotrunningavginteractive}
 
tsmgr.start(hosts, analyses=analyses)