Skip to content

Instantly share code, notes, and snippets.

@TakahisaShiratori
Last active June 14, 2019 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TakahisaShiratori/61a05f77a1fc20e000efe99c6a6d6fda to your computer and use it in GitHub Desktop.
Save TakahisaShiratori/61a05f77a1fc20e000efe99c6a6d6fda to your computer and use it in GitHub Desktop.
Sample script to use Rescale with REST API
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!!")
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!!")
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!!")
@TakahisaShiratori
Copy link
Author

使い方はこちらに書きました
RescaleでOpenFOAMのBuoyant Cavityを実行するTutorial - Qiita
https://qiita.com/takashiratori/items/fe6e8344aa2d1b2e7eb5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment