|
| 1 | +# How to use |
| 2 | +# 1. Login to https://app.globus.org/settings/developers and copy a project app id and secret |
| 3 | +# 2. Use the id and secret to create and endpoint https://funcx.readthedocs.io/en/latest/sdk.html#client-credentials-with-clients |
| 4 | +# $ export FUNCX_SDK_CLIENT_ID="b0500dab-ebd4-430f-b962-0c85bd43bdbb" |
| 5 | +# $ export FUNCX_SDK_CLIENT_SECRET="ABCDEFGHIJKLMNOP0123456789=" |
| 6 | +# 3. Set up an endpoint on the computer that will run the tests, using these instructions: https://funcx.readthedocs.io/en/latest/endpoints.html |
| 7 | +# 4. Create install-test.sh and run-test.sh on target computer |
| 8 | + |
| 9 | +from globus_compute_sdk import Executor |
| 10 | +import sys |
| 11 | +import os |
| 12 | + |
| 13 | +name = sys.argv[1] |
| 14 | +branch = sys.argv[2] |
| 15 | +endpoint = sys.argv[3] |
| 16 | + |
| 17 | +def run_on_endpoint(name, branch): |
| 18 | + import subprocess |
| 19 | + |
| 20 | + install = subprocess.run(["./install-test.sh "+name+" "+branch], shell=True, encoding="utf_8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 21 | + if install.returncode == 1: |
| 22 | + return (install, None) |
| 23 | + |
| 24 | + result = subprocess.run(["./run-test.sh "+name], shell=True, encoding="utf_8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 25 | + return (install, result) |
| 26 | + |
| 27 | +gce = Executor(endpoint_id = endpoint) |
| 28 | +future = gce.submit(run_on_endpoint, name, branch) |
| 29 | +result = future.result() |
| 30 | + |
| 31 | +os.popen("mkdir -p "+name+"-result").read() |
| 32 | +with open(name+"-result/Build.log", "w") as text_file: |
| 33 | + text_file.write("%s" % result[0].stdout) |
| 34 | + text_file.close() |
| 35 | +if result[0].returncode == 0: |
| 36 | + with open(name+"-result/Test.log", "w") as text_file: |
| 37 | + text_file.write("%s" % result[1].stdout) |
| 38 | + text_file.close() |
0 commit comments