Skip to content

Commit

Permalink
Merge pull request #274 from craigcitro/kernelspec_metadata
Browse files Browse the repository at this point in the history
Add a `metadata` field to kernelspecs.
  • Loading branch information
rgbkrk authored Jul 6, 2017
2 parents f8886b8 + f27925b commit 5a8d7f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/api/kernelspec.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 5a8d7f8

Please sign in to comment.