Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a metadata field to kernelspecs. #274

Merged
merged 1 commit into from Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/api/kernelspec.rst
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions docs/kernels.rst
Expand Up @@ -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::

Expand Down
2 changes: 2 additions & 0 deletions jupyter_client/kernelspec.py
Expand Up @@ -28,6 +28,7 @@ class KernelSpec(HasTraits):
language = Unicode()
env = Dict()
resource_dir = Unicode()
metadata = Dict()

@classmethod
def from_resource_dir(cls, resource_dir):
Expand All @@ -45,6 +46,7 @@ def to_dict(self):
env=self.env,
display_name=self.display_name,
language=self.language,
metadata=self.metadata,
)

return d
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/tests/test_kernelspec.py
Expand Up @@ -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()
Expand Down