-
Notifications
You must be signed in to change notification settings - Fork 2
/
rynner.py
executable file
·133 lines (104 loc) · 3.54 KB
/
rynner.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import os
import glob
import yaml
from unittest.mock import patch, call, ANY
from unittest.mock import MagicMock as MM
from tests.qtest_helpers import *
import rynner.host
from rynner.datastore import Datastore
from rynner.pattern_parser import PatternParser
from rynner.main import MainView
from rynner.create_view import RunCreateView, TextField
from rynner.plugin import Plugin, PluginCollection, RunAction
from rynner.run import RunManager
from rynner.host_patterns import host_patterns
from rynner.logs import Logger
from tests.host_env import *
from PySide2.QtGui import QIcon
defaults = []
#---------------------------------------------------------
# PLUGIN SCRIPT
#---------------------------------------------------------
# Create a fake run_create_view
view1 = [TextField('Message', 'message', default='Hello, World!')]
def runner(run_manager, data):
run = run_manager.new(
ntasks=1,
memory_per_task_MB=10000,
host=hosts[0],
script='echo "Hello from Sunbird!" > "my-job-output"')
# create Plugin objects
plugin1 = Plugin(
'swansea.ac.uk/1',
'Hello, World!',
view1,
runner,
view_keys=[
('Message', 'config-options.Message'),
('State', 'queue.State'),
('Elapsed', 'queue.Elapsed'),
('Time Limit', 'queue.TimeLimit'),
])
#---------------------------------------------------------
# PLUGIN 2 SCRIPT
#---------------------------------------------------------
view2 = [
TextField('Velocity', 'velocity', default="10"),
TextField('Altitude', 'altitude', default="40,000"),
TextField('Angle', 'angle', default='10'),
]
def runner2(run_manager, data):
print('running...')
plugin2 = Plugin(
'swansea.ac.uk/2',
'simpleCFD',
view2,
runner2,
view_keys=[
('Velocity', 'config-options.Velocity'),
])
#---------------------------------------------------------
# LOAD HOSTS
#---------------------------------------------------------
globdir = f'{homedir}/.rynner/hosts/*' # fixme how did this folder appear here?
host_config_files = glob.glob(globdir)
if len(host_config_files) == 0:
raise Exception(f'No host config files found in {globdir}')
hosts = []
for filename in host_config_files:
with open(filename, 'r') as file:
host_config = yaml.load(file)
host_class = getattr(rynner.host, host_config['classname'])
host = host_class(host_config['domain'], host_config['username'],
host_config['rsa_file'])
hosts.append(host)
#---------------------------------------------------------
# INITIALISE PLUGINS
#---------------------------------------------------------
plugins = [PluginCollection("All Runs", [plugin1, plugin2]), plugin1, plugin2]
#---------------------------------------------------------
# Run application
#---------------------------------------------------------
def update_plugins():
for plugin in [plugin1, plugin2]:
plugin_id = plugin.plugin_id
for host in hosts:
host.update(plugin_id)
timer = QTimer()
timer.timeout.connect(update_plugins)
secs = 60
timer.start(secs * 1000)
QTimer.singleShot(10, update_plugins)
main = MainView(hosts, plugins)
#---------------------------------------------------------
# Icon
#---------------------------------------------------------
icon = QIcon("icons/Rynner-icon-256.png")
icon.addFile("icons/Rynner-icon-32.png")
main.setWindowIcon(icon)
main.setWindowTitle("Rynner")
#---------------------------------------------------------
# Start
#---------------------------------------------------------
main.show()
app.exec_()