Using Rescale’s REST API

With Rescale’s REST API you can upload input files, create jobs, view the status of existing jobs, and more. For the full list of API endpoints, see the Rescale API Documentation.

An API key is required to authenticate your account when interacting with the API. To generate an API key for your account, go to the API section of your settings page, then click the Generate button.

generate api.e8fc6161

Running a Job through the Rescale API

This example shows how to set up a LS-DYNA job through the API using both cURL and python.

First, navigate to the directory containing the input file ( and upload using the command:

curl -X POST -H 'Content-Type:multipart/form-data' \-H 'Authorization: Token <api-token>' \-F "" \

The response would be similar to:

  "pathParts": {
    "path": "user/user_WrNSdb/",
    "container": "prod-rescale-platform"
  "typeId": 1,
  "name": "",
  "dateUploaded": "2016-11-11T18:50:54.078468Z",
  "relativePath": "",
  "storage": {
    "storageType": "S3Storage",
    "id": "pCTMk",
    "connectionSettings": {
      "region": "us-east-1"
    "encryptionType": "default"
  "decryptedSize": 10391660,
  "downloadUrl": "",
  "sharedWith": [],
  "encodedEncryptionKey": "N1iq48GWyEDkMG1wTHI656hcJZKdSQecuwKhu31Epd0=",
  "owner": "",
  "path": "user/user_WrNSdb/",
  "isUploaded": true,
  "viewInBrowser": false,
  "id": "yMqdxd",
  "isDeleted": false,
  "md5": "159bb1cdd01987f9122f5ec673958eaf"

Next, we have to choose an analysis software. The complete list of analyses can be obtained by calling curl -H "Authorization: Token <api-token>" The important information to extract is the code of the Software that you would like to use, shown under "code":"...".

You will also need the coretype information, which can by found using curl -H "Authorization: Token <api-token>" The name of the coretypes as displayed on the Web UI is captured under "name":"..." in each entry. Similarly, you need to extract the code of the coretype, shown under "code":"...".

In the same directory that you are currently on, create a data file containing a JSON of the job settings and info. The ID of the input file can be found in the response when the input file was uploaded. For example:

cat <<EOF > data.json{  "name": "LS-DYNA cURL API Setup", "billingPriorityValue": "INSTANT", "jobanalyses": [    {      "useRescaleLicense":true,      "command": "ls-dyna -n 2 -i neon.refined.rev01.k -p single",      "analysis": {        "code": "ls_dyna",        "version": "9.0.0"      },      "hardware": {        "coresPerSlot": 2,        "slots": 1,        "coreType": "hpc-3"      },      "inputFiles": [        {          "id": "yMqdxd"        }      ]    }  ]}EOF

The full list of command options and its defaults can be found here.

Next, run the command to set up your Rescale job based on the data file that was just created:

curl -X POST --data @data.json \-H "Authorization: Token <api-token>" \-H "Content-Type: application/json" \

The response would be similar to:

{   "monteCarloIterations":null,   "paramFile":null,   "name":"LS-DYNA cURL API Setup",  "billingPriorityValue": "INSTANT", "includeNominalRun":false,   "jobanalyses":[      {         "envVars":{          },         "preProcessScriptCommand":"",         "postProcessScriptCommand":"",         "postProcessScript":null,         "useRescaleLicense":true,         "templateTasks":[          ],         "analysis":{            "version":"9.0.0",            "code":"ls_dyna",            "name":"LS-DYNA",            "versionName":"R9.0.0"         },         "hardware":{            "coresPerSlot":2,            "coreType":"hpc-3",            "coreSummary":{               "storagePerNode":80000,               "gpusPerNode":0,               "numberOfNodes":1.0,               "memoryPerNode":7500            },            "slots":1,            "type":"compute",            "walltime":750         },         "command":"ls-dyna -n 2 -i neon.refined.rev01.k -p single",         "preProcessScript":null,         "flags":{          },         "inputFiles":[            {               "pathParts":{                  "path":"user/user_WrNSdb/",                  "container":"prod-rescale-platform"               },               "typeId":1,               "name":"",               "dateUploaded":"2016-11-11T18:50:54.078468Z",               "relativePath":"",               "storage":{                  "storageType":"S3Storage",                  "id":"pCTMk",                  "connectionSettings":{                     "region":"us-east-1"                  },                  "encryptionType":"default"               },               "decryptedSize":10391660,               "downloadUrl":"",               "sharedWith":[                ],               "encodedEncryptionKey":"N1iq48GWyEDkMG1wTHI656hcJZKdSQecuwKhu31Epd0=",               "owner":"",               "path":"user/user_WrNSdb/",               "isUploaded":true,               "viewInBrowser":false,               "id":"yMqdxd",               "isDeleted":false,               "md5":"159bb1cdd01987f9122f5ec673958eaf"            }         ]      }   ],   "projectId":null,   "resourceFilters":[    ],   "remoteVizConfig":null,   "jobvariables":[    ],   "sshPort":22,   "expectedRuns":null,   "caseFile":null,   "isLowPriority":false,   "owner":"",   "isTemplateDryRun":false,   "autoTerminateCluster":true,   "id":"RcAFeb",   "archiveFilters":[]}

The job is now saved and will appear in the Rescale Web UI. Finally, you need to submit the job using the command:

curl -X POST -H 'Authorization: Token <api-token>' \

Note: The Job ID can be found in the previous response.

If you want to monitor the status of your job, use the command:

curl -H 'Authorization: Token <api-token>' \

The response would be similar to:

{   "count":6,   "previous":null,   "results":[      {         "status":"Completed",         "statusDate":"2016-11-15T19:01:13.948641Z",         "id":"KNwnm",         "statusReason":"Completed successfully"      },      {         "status":"Executing",         "statusDate":"2016-11-15T18:47:05.530000Z",         "id":"ePisa",         "statusReason":null      },      {         "status":"Validated",         "statusDate":"2016-11-15T18:41:23.929000Z",         "id":"Yfcem",         "statusReason":null      },      {         "status":"Started",         "statusDate":"2016-11-15T18:41:23.629000Z",         "id":"KDisa",         "statusReason":null      },      {         "status":"Queued",         "statusDate":"2016-11-15T18:41:21.577545Z",         "id":"ircem",         "statusReason":null      },      {         "status":"Pending",         "statusDate":"2016-11-15T18:40:56.465755Z",         "id":"UOisa",         "statusReason":null      }   ],   "next":null}

A job also can be set up through a python script. This example provides chunks of sample python code that can be used to set up and run a LS-DYNA job.

Note: This method uses the requests library, so you have to run import requests at the start of your code.

First, zip the file and then upload to Rescale using:

file_upload =  '',  data=None,  files={'file': open('','rb')},  headers={'Authorization': 'Token <api-token>'} )print file_upload.content

Note that the file ( must be in the same directory as the script.

The output would be similar to:

{   "pathParts":{      "path":"user/user_WrNSdb/",      "container":"prod-rescale-platform"   },   "typeId":1,   "name":"",   "dateUploaded":"2016-11-14T22:58:35.729270Z",   "relativePath":"",   "storage":{      "storageType":"S3Storage",      "id":"pCTMk",      "connectionSettings":{         "region":"us-east-1"      },      "encryptionType":"default"   },   "decryptedSize":10391660,   "downloadUrl":"",   "sharedWith":[    ],   "encodedEncryptionKey":"ixay5gbPcYHnSwKNhPHldhzCZXEpN/rpD9Q8tskoavo=",   "owner":"",   "path":"user/user_WrNSdb/",   "isUploaded":true,   "viewInBrowser":false,   "id":"FDXpJd",   "isDeleted":false,   "md5":"159bb1cdd01987f9122f5ec673958eaf"}

Next, you will need to set up the job. For this, you will need to obtain the Analyses Software and Hardware information.

For Analyses:

requests.get(  '',  headers={'Authorization': 'Token <api-token>'} )

For Coretype:

requests.get(  '',  headers={'Authorization': 'Token <api-token>'} )

In both cases, you need to retrieve the code displayed under "code":"...".

An example of setting up a job would be:

job_setup =    '',    json = {         "name": "LS-DYNA Python API Setup",         "jobanalyses": [             {                 "useRescaleLicense":True,                 "command": "ls-dyna -n 2 -i neon.refined.rev01.k -p single",                 "analysis": {                     "code": "ls_dyna",                     "version": "9.0.0"                    },                 "hardware": {                     "coresPerSlot": 2,                     "slots": 1,                     "coreType": "hpc-3"                    },                 "inputFiles": [                     {                         "id": "FDXpJd"                        }                    ]                }            ]        },  headers={'Authorization': 'Token <api-token>'} )print job_setup.content

Note: You can find the input file ID from the previous output (file upload)

The output would be similar to:

{   "monteCarloIterations":null,   "paramFile":null,   "name":"LS-DYNA Python API Setup",   "includeNominalRun":false,   "jobanalyses":[      {         "envVars":{          },         "preProcessScriptCommand":"",         "postProcessScriptCommand":"",         "postProcessScript":null,         "useRescaleLicense":true,         "templateTasks":[          ],         "analysis":{            "version":"9.0.0",            "code":"ls_dyna",            "name":"LS-DYNA",            "versionName":"R9.0.0"         },         "hardware":{            "coresPerSlot":2,            "coreType":"hpc-3",            "coreSummary":{               "storagePerNode":80000,               "gpusPerNode":0,               "numberOfNodes":1.0,               "memoryPerNode":7500            },            "slots":1,            "type":"compute",            "walltime":750         },         "command":"ls-dyna -n 2 -i neon.refined.rev01.k -p single",         "preProcessScript":null,         "flags":{          },         "inputFiles":[            {               "pathParts":{                  "path":"user/user_WrNSdb/",                  "container":"prod-rescale-platform"               },               "typeId":1,               "name":"",               "dateUploaded":"2016-11-14T22:58:35.729270Z",               "relativePath":"",               "storage":{                  "storageType":"S3Storage",                  "id":"pCTMk",                  "connectionSettings":{                     "region":"us-east-1"                  },                  "encryptionType":"default"               },               "decryptedSize":10391660,               "downloadUrl":"",               "sharedWith":[                ],               "encodedEncryptionKey":"ixay5gbPcYHnSwKNhPHldhzCZXEpN/rpD9Q8tskoavo=",               "owner":"",               "path":"user/user_WrNSdb/",               "isUploaded":true,               "viewInBrowser":false,               "id":"FDXpJd",               "isDeleted":false,               "md5":"159bb1cdd01987f9122f5ec673958eaf"            }         ]      }   ],   "projectId":null,   "resourceFilters":[    ],   "remoteVizConfig":null,   "jobvariables":[    ],   "sshPort":22,   "expectedRuns":null,   "caseFile":null,   "isLowPriority":false,   "owner":"",   "isTemplateDryRun":false,   "autoTerminateCluster":true,   "id":"ASwPT",   "archiveFilters":[    ]}

The job is now saved and will appear in the Rescale Web UI. Finally, you need to submit the job using the command:  '',  headers={'Authorization': 'Token <api-token>'} )

If you would like to monitor your job, you can run the command:

job_status = requests.get(  '',  headers={'Authorization': 'Token <api-token>'} )print job_status.content