Skip to content

Commit 3c52177

Browse files
authored
Merge pull request #105 from JohanMabille/kernelspec-spec
Kernelspec JSON schema
2 parents 3b9379b + 6c9be20 commit 3c52177

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

kernelspec-spec/kernelspec-spec.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: kernelspec specification
3+
authors: Johan Mabille
4+
issue-number: XX
5+
pr-number: [#105](https://github.com/jupyter/enhancement-proposals/pull/105)
6+
date-started: "2023-04-19"
7+
---
8+
9+
# Specification of the kernelspec
10+
11+
## Problem
12+
13+
The kernelspec configuration file is [documented](https://github.com/jupyter/jupyter_client/blob/main/docs/kernels.rst) aside the kernel protocol documentation, and an [implementation](https://github.com/jupyter/jupyter_client/blob/main/jupyter_client/kernelspec.py#L21) is available, but it is not *specified*. Besides, it might be unclear whether the kernelspec is part of the kernel protocol, or independent.
14+
15+
## Proposed Enhancement
16+
17+
We propose to specify the kernelspec with the JSON schema joined in this PR. The specification would reflect
18+
[the current description of the kernelspec](https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-specs),
19+
and adds an optional `kernel_protocol_version` field.
20+
21+
The documentation of the kernelspec will be stored aside [that of the kernel protocol](https://github.com/jupyter-standards/kernel-protocol). The schema will be stored in the [dedicated repo for all Jupyter schemas](https://github.com/jupyter/schema).
22+
23+
### Impact on existing implementations
24+
25+
None, this JEP only adds an optional field in the kernelspec.
26+
+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://schema.jupyter.org/kernelspec-v1.0.schema.json",
4+
"title": "Jupyter Kernelspec",
5+
"description": "A description of the data required to start and manage a Jupyter Kernel",
6+
"type": "object",
7+
8+
"definitions": {
9+
"kernel_arguments": {
10+
"type": "object",
11+
"required": ["argv"],
12+
"properties": {
13+
"argv": {
14+
"description": "A list of command line arguments used to start the kernel. The text {connection_file} in any argument will be replaced with the path to the connection file.",
15+
"type": "array",
16+
"items": {
17+
"type": "string"
18+
},
19+
"minItems": 1
20+
}
21+
}
22+
},
23+
"display_name": {
24+
"type": "object",
25+
"required": ["display_name"],
26+
"properties": {
27+
"display_name": {
28+
"description": "The kernel’s name as it should be displayed in the UI. Unlike the kernel name used in the API, this can contain arbitrary unicode characters.",
29+
"type": "string"
30+
}
31+
}
32+
},
33+
"language": {
34+
"type": "object",
35+
"required": ["language"],
36+
"properties": {
37+
"language": {
38+
"description": "The name of the language of the kernel. When loading notebooks, if no matching kernelspec key (may differ across machines) is found, a kernel with a matching language will be used. This allows a notebook written on any Python or Julia kernel to be properly associated with the user’s Python or Julia kernel, even if they aren’t listed under the same name as the author’s.",
39+
"type": "string"
40+
}
41+
}
42+
},
43+
"kernel_protocol_version": {
44+
"type": "object",
45+
"required": ["kernel_protocol_version"],
46+
"properties": {
47+
"kernel_protocol_version": {
48+
"description": "The version of protocol this kernel implements. If not specified, the client will assume the version is <5.5 until it can get it via the kernel_info request. The kernel protocol uses semantic versioning (SemVer).",
49+
"type": "string",
50+
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
51+
}
52+
}
53+
},
54+
"interrupt_mode": {
55+
"type": "object",
56+
"required": ["interrupt_mode"],
57+
"properties": {
58+
"interrupt_mode": {
59+
"description": "May be either signal or message and specifies how a client is supposed to interrupt cell execution on this kernel, either by sending an interrupt signal via the operating system’s signalling facilities (e.g. SIGINT on POSIX systems), or by sending an interrupt_request message on the control channel (see Kernel interrupt). If this is not specified the client will default to signal mode.",
60+
"type": "string",
61+
"enum": ["signal", "message"]
62+
}
63+
}
64+
},
65+
"env": {
66+
"type": "object",
67+
"required": ["env"],
68+
"properties": {
69+
"env": {
70+
"description": "A dictionary of environment variables to set for the kernel. These will be added to the current environment variables before the kernel is started. Existing environment variables can be referenced using ${<ENV_VAR>} and will be substituted with the corresponding value. Administrators should note that use of ${<ENV_VAR>} can expose sensitive variables and should use only in controlled circumstances.",
71+
"type": "object",
72+
"additionalProperties": {"type": "string" }
73+
}
74+
}
75+
},
76+
"metadata": {
77+
"type": "object",
78+
"required": ["metadata"],
79+
"properties": {
80+
"metadata": {
81+
"description": "A dictionary of additional attributes about this kernel; used by clients to aid in kernel selection. Metadata added here should be namespaced for the tool reading and writing that metadata.",
82+
"type": "object",
83+
"additionalProperties": {"type": "object"}
84+
}
85+
}
86+
}
87+
},
88+
"anyOf": [
89+
{ "$ref": "#/definitions/argv" },
90+
{ "$ref": "#/definitions/display_name" },
91+
{ "$ref": "#/definitions/language" },
92+
{ "$ref": "#/definitions/kernel_protocol_version" },
93+
{ "$ref": "#/definitions/interrupt_mode" },
94+
{ "$ref": "#/definitions/env" },
95+
{ "$ref": "#/definitions/metadata" }
96+
],
97+
"required": ["argv", "display_name", "language"]
98+
}

0 commit comments

Comments
 (0)