diff --git a/docs/api/kernelspec.rst b/docs/api/kernelspec.rst index c2164eae5..942a69450 100644 --- a/docs/api/kernelspec.rst +++ b/docs/api/kernelspec.rst @@ -25,6 +25,11 @@ kernelspec - discovering kernels The name of the language the kernel implements, to help with picking appropriate kernels when loading notebooks. + .. attribute:: metadata + + Additional kernel-specific metadata; clients can use this as needed, + for instance to aid in kernel selection and filtering. + .. attribute:: resource_dir The path to the directory with this kernel's resources, such as icons. diff --git a/docs/kernels.rst b/docs/kernels.rst index 42101c35f..780bac769 100644 --- a/docs/kernels.rst +++ b/docs/kernels.rst @@ -135,6 +135,8 @@ JSON serialised dictionary containing the following keys and values: - **env** (optional): A dictionary of environment variables to set for the kernel. These will be added to the current environment variables before the kernel is started. +- **metadata** (optional): A dictionary of additional attributes about this + kernel; used by clients to aid clients in kernel selection. For example, the kernel.json file for IPython looks like this:: diff --git a/jupyter_client/kernelspec.py b/jupyter_client/kernelspec.py index 0b882ad5a..3465ac7a4 100644 --- a/jupyter_client/kernelspec.py +++ b/jupyter_client/kernelspec.py @@ -28,6 +28,7 @@ class KernelSpec(HasTraits): language = Unicode() env = Dict() resource_dir = Unicode() + metadata = Dict() @classmethod def from_resource_dir(cls, resource_dir): @@ -45,6 +46,7 @@ def to_dict(self): env=self.env, display_name=self.display_name, language=self.language, + metadata=self.metadata, ) return d diff --git a/jupyter_client/tests/test_kernelspec.py b/jupyter_client/tests/test_kernelspec.py index b02dd75a0..b2ec4195c 100644 --- a/jupyter_client/tests/test_kernelspec.py +++ b/jupyter_client/tests/test_kernelspec.py @@ -67,6 +67,7 @@ def test_get_kernel_spec(self): self.assertEqual(ks.argv, sample_kernel_json['argv']) self.assertEqual(ks.display_name, sample_kernel_json['display_name']) self.assertEqual(ks.env, {}) + self.assertEqual(ks.metadata, {}) def test_find_all_specs(self): kernels = self.ksm.get_all_specs()