Last active
June 14, 2019 15:38
-
-
Save TakahisaShiratori/61a05f77a1fc20e000efe99c6a6d6fda to your computer and use it in GitHub Desktop.
Sample script to use Rescale with REST API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
api_token = "a0************************************4b" | |
token_in_header = "Token " + api_token | |
platform = "platform.rescale.com" | |
job_configuration = { | |
"name": "Example Job from API", | |
"jobanalyses": [ | |
{ | |
"analysis": { | |
"code": "user_included", | |
"version": "0", | |
"name":"Bring Your Own Software", | |
"versionName":"CPU" | |
}, | |
"command": "echo \"Hello from Rescale\"\nsleep 10s", | |
"hardware": { | |
"coreType": "hpc-3", | |
"coresPerSlot": 1 | |
} | |
} | |
] | |
} | |
# Create a Job | |
raw_reply = requests.post( | |
"https://" + platform + "/api/v2/jobs/", | |
headers={"Authorization": token_in_header}, | |
json=job_configuration | |
) | |
created_job = json.loads(raw_reply.text) | |
print("Job ID: " + created_job["id"]) | |
# Submit the Job | |
requests.post( | |
"https://" + platform + "/api/v2/jobs/" + created_job["id"] + "/submit/", | |
headers={"Authorization": token_in_header} | |
) | |
print("Done!!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
api_token = "a0************************************4b" | |
token_in_header = "Token " + api_token | |
platform = "platform.rescale.jp" | |
job_configuration = { | |
"name": "Example Job from API", | |
"jobanalyses": [ | |
{ | |
"analysis": { | |
"code": "user_included", | |
"version": "0", | |
"name":"Bring Your Own Software", | |
"versionName":"CPU" | |
}, | |
"command": "echo \"Hello from Rescale\"\nsleep 10s", | |
"hardware": { | |
"coreType": "hpc-3", | |
"coresPerSlot": 1 | |
} | |
} | |
] | |
} | |
# Create a Job | |
raw_reply = requests.post( | |
"https://" + platform + "/api/v2/jobs/", | |
headers={"Authorization": token_in_header}, | |
json=job_configuration | |
) | |
created_job = json.loads(raw_reply.text) | |
print("Job ID: " + created_job["id"]) | |
# Submit the Job | |
requests.post( | |
"https://" + platform + "/api/v2/jobs/" + created_job["id"] + "/submit/", | |
headers={"Authorization": token_in_header} | |
) | |
print("Done!!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
api_token = "a0************************************4b" | |
token_in_header = "Token " + api_token | |
platform = "kr.rescale.com" | |
job_configuration = { | |
"name": "Example Job from API", | |
"jobanalyses": [ | |
{ | |
"analysis": { | |
"code": "user_included", | |
"version": "0", | |
"name":"Bring Your Own Software", | |
"versionName":"CPU" | |
}, | |
"command": "echo \"Hello from Rescale\"\nsleep 10s", | |
"hardware": { | |
"coreType": "hpc-3", | |
"coresPerSlot": 1 | |
} | |
} | |
] | |
} | |
# Create a Job | |
raw_reply = requests.post( | |
"https://" + platform + "/api/v2/jobs/", | |
headers={"Authorization": token_in_header}, | |
json=job_configuration | |
) | |
created_job = json.loads(raw_reply.text) | |
print("Job ID: " + created_job["id"]) | |
# Submit the Job | |
requests.post( | |
"https://" + platform + "/api/v2/jobs/" + created_job["id"] + "/submit/", | |
headers={"Authorization": token_in_header} | |
) | |
print("Done!!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使い方はこちらに書きました
RescaleでOpenFOAMのBuoyant Cavityを実行するTutorial - Qiita
https://qiita.com/takashiratori/items/fe6e8344aa2d1b2e7eb5