Kernel Management¶
Here are the API calls to create and manage compute sessions.
Creating Kernel Session¶
URI:
/kernel
(/kernel/create
also works for legacy)Method:
POST
Creates a new kernel session or returns an existing session, depending on the parameters.
Parameters¶
Parameter |
Type |
Description |
---|---|---|
|
|
The kernel runtime type in the form of the Docker image name and tag.
For legacy, the API also recognizes the Changed in version v4.20190315. |
|
|
A client-provided session token, which must be unique among the currently non-terminated sessions owned by the requesting access key. Clients may reuse the token if the previous session with the same token has been terminated. It may contain ASCII alphabets, numbers, and hyphens in the middle. The length must be between 4 to 64 characters inclusively. It is useful for aliasing the session with a human-friendly name. |
|
|
(optional) If set true, the API returns immediately after queueing the session creation request to the scheduler.
Otherwise, the manager will wait until the session gets started actually.
(default: New in version v4.20190615. |
|
|
(optional) Set the maximum duration to wait until the session starts after queued, in seconds. If zero,
the manager will wait indefinitely.
(default: New in version v4.20190615. |
|
|
(optional) If set true, the API returns without creating a new session if a session
with the same ID and the same image already exists and not terminated.
In this case New in version v4.20190615. |
|
|
(optional) The name of a user group (aka “project”) to launch the session within. (default: New in version v4.20190615. |
|
|
(optional) The name of a domain to launch the session within (default: New in version v4.20190615. |
|
|
(optional) A Creation Config Object to specify kernel configuration including resource requirements. If not given, the kernel is created with the minimum required resource slots defined by the target image. |
|
|
(optional) A per-session, user-provided tag for administrators to keep track of additional information of each session, such as which sessions are from which users. |
Example:
{
"image": "python:3.6-ubuntu18.04",
"clientSessionToken": "mysession-01",
"enqueueOnly": false,
"maxWaitSeconds": 0,
"reuseIfExists": true,
"domain": "default",
"group": "default",
"config": {
"clusterSize": 1,
"environ": {
"MYCONFIG": "XXX",
},
"mounts": ["mydata", "mypkgs"],
"resources": {
"cpu": "2",
"mem": "4g",
"cuda.devices": "1",
}
},
"tag": "example-tag"
}
Response¶
HTTP Status Code |
Description |
---|---|
200 OK |
The kernel is already running and you are okay to reuse it. |
201 Created |
The kernel is successfully created. |
401 Invalid API parameters |
There are invalid or malformed values in the API parameters. |
406 Not acceptable |
The requested resource limits exceed the server’s own limits. |
Fields |
Type |
Values |
---|---|---|
|
|
The session ID used for later API calls, which is same to the value of |
|
|
The status of the created kernel. This is always New in version v4.20190615. |
|
|
The list of Service Port Object.
This field becomes an empty list if Note In most cases the service ports are same to what specified in the image metadata, but the agent may add shared services for all kernels. Changed in version v4.20190615. |
|
|
True if the kernel is freshly created. |
Example:
{
"kernelId": "mysession-01",
"status": "RUNNING",
"servicePorts": [
{"name": "jupyter", "protocol": "http"},
{"name": "tensorboard", "protocol": "http"}
],
"created": true
}
Getting Kernel Information¶
URI:
/kernel/:id
Method:
GET
Retrieves information about a kernel session. For performance reasons, the returned information may not be real-time; usually they are updated every a few seconds in the server-side.
Parameters¶
Parameter |
Type |
Description |
---|---|---|
|
|
The kernel ID. |
Response¶
HTTP Status Code |
Description |
---|---|
200 OK |
The information is successfully returned. |
404 Not Found |
There is no such kernel. |
Key |
Type |
Description |
---|---|---|
|
|
The kernel’s programming language |
|
|
The time elapsed since the kernel has started. |
|
|
The memory limit of the kernel in KiB. |
|
|
The number of times the kernel has been accessed. |
|
|
The total time the kernel was running. |
Destroying Kernel Session¶
URI:
/kernel/:id
Method:
DELETE
Terminates a kernel session.
Parameters¶
Parameter |
Type |
Description |
---|---|---|
|
|
The kernel ID. |
Response¶
HTTP Status Code |
Description |
---|---|
204 No Content |
The kernel is successfully destroyed. |
404 Not Found |
There is no such kernel. |
Key |
Type |
Description |
---|---|---|
|
|
The Container Stats Object of the kernel when deleted. |
Restarting Kernel Session¶
URI:
/kernel/:id
Method:
PATCH
Restarts a kernel session. The idle time of the kernel will be reset, but other properties such as the age and CPU credit will continue to accumulate. All global states such as global variables and modules imports are also reset.
Parameters¶
Parameter |
Type |
Description |
---|---|---|
|
|
The kernel ID. |
Response¶
HTTP Status Code |
Description |
---|---|
204 No Content |
The kernel is successfully restarted. |
404 Not Found |
There is no such kernel. |