Code Execution (Batch Mode)

Some kernels provide the batch mode, which offers an explicit build step required for multi-module programs or compiled programming languages. In this mode, you first upload files in prior to execution.

Uploading files

  • URI: /v2/kernel/:id/upload
  • Method: POST

Parameters

Upload files to the kernel session. You may upload multiple files at once using multi-part form-data encoding in the request body (RFC 1867/2388). The uploaded files are placed under /home/work directory (which is the home directory for all kernels by default), and existing files are always overwritten. If the filename has a directory part, non-existing directories will be auto-created. The path may be either absolute or relative, but only sub-directories under /home/work is allowed to be created.

Hint

This API is for uploading frequently-changing source files in prior to batch-mode execution. All files uploaded via this API is deleted when the kernel terminates. Use virtual folders to store and access larger, persistent, static data and library files for your codes.

Warning

You cannot upload files to mounted virtual folders using this API directly. However, you may copy/move the generated files to virtual folders in your build script or the main program for later uses.

There are several limits on this API:

The maximum size of each file 1 MiB
The number of files per upload request 20

Response

HTTP Status Code Description
200 OK The kernel has responded with the execution result. The response body contains a JSON object as described below.
400 Bad Request Returned when one of the uploaded file exeeds the size limit or there are too many files.

Executing with Build Step

  • URI: /v2/kernel/:id
  • Method: POST

Parameters

Parameter Type Description
:id slug The kernel ID.
mode enum[str] A constant string "batch".
options object Batch Execution Query Object.

Example:

{
  "type": "batch",
  "options": "{batch-execution-query-object}",
}

Response

HTTP Status Code Description
200 OK The kernel has responded with the execution result. The response body contains a JSON object as described below.
Fields Type Values
result object Execution Result Object.