-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-globus.py
More file actions
60 lines (45 loc) · 2.31 KB
/
run-globus.py
File metadata and controls
60 lines (45 loc) · 2.31 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
58
59
60
# How to use
# 1. Login to https://app.globus.org/settings/developers and copy a project app id and secret
# 2. Use the id and secret to create and endpoint https://funcx.readthedocs.io/en/latest/sdk.html#client-credentials-with-clients
# $ export FUNCX_SDK_CLIENT_ID="b0500dab-ebd4-430f-b962-0c85bd43bdbb"
# $ export FUNCX_SDK_CLIENT_SECRET="ABCDEFGHIJKLMNOP0123456789="
# 3. Set up an endpoint on the computer that will run the tests, using these instructions: https://funcx.readthedocs.io/en/latest/endpoints.html
# 4. Create install-test.sh and run-test.sh on target computer
from globus_compute_sdk import Executor
import sys
import os
machine = sys.argv[1]
name = sys.argv[2]
branch = sys.argv[3]
endpoint = sys.argv[4]
with open(machine+'/install.sh', 'r') as file:
install_file = file.read()
with open(machine+'/run.sh', 'r') as file:
run_file = file.read()
def run_on_endpoint(name, branch, install_file, run_file):
import subprocess
with open(name+"-test/install.sh", "w") as text_file:
text_file.write("%s" % install_file)
text_file.close()
with open(name+"-test/run.sh", "w") as text_file:
text_file.write("%s" % run_file)
text_file.close()
install_command = "cd {0}-test && chmod +x install.sh && ./install.sh {1} 2>&1 | tee build.log".format(name, branch)
install_result = subprocess.run([install_command], shell=True, encoding="utf_8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if install_result.returncode != 0:
return (install_result, None)
run_command = "cd {0}-test && chmod +x run.sh && ./run.sh 2>&1 | tee test.log".format(name)
run_result = subprocess.run([run_command], shell=True, encoding="utf_8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return (install_result, run_result)
print ("===Running tests on endpoint, this might take a few minutes===")
gce = Executor(endpoint_id = endpoint)
future = gce.submit(run_on_endpoint, name, branch, install_file, run_file)
result = future.result()
with open("Build.log", "w") as text_file:
text_file.write("%s" % result[0].stdout)
text_file.close()
if result[1] != None:
with open("Test.log", "w") as text_file:
text_file.write("%s" % result[1].stdout)
text_file.close()
print ("Done: output written to Build.log and Test.log in "+ os.getcwd())