We propose to add a new top-level field, extraSchemas
to the notebook JSON schema, to allow for further schema validation in addition to the basic notebook format.
Today, the metadata fields in the notebook format are black boxes that cannot be validated or reasoned about by general tools. Furthermore, there is no notion of ownership over these metadata fields between extensions; extensions could conceivably conflict over the same names, with little indication to the user that this takes place.
By adding an extraSchemas
field, this JEP would permit third-party extension authors to define a formal specification for the kinds of data that they wish to store within a notebook. Additionally, by defining the schema of these data, it is possible for notebook consumers (e.g. frontends) to generate rich user interfaces that modify the notebook metadata.
In the instance that organisations wish to impose additional restrictions upon internally authored notebooks, e.g. banning keywords in notebook sources, or requiring the presence of organisation-specific metadata keys, the addition of a per-notebook schema would facilitate such a scenario.
Jupyter Notebooks are already validated against JSON Schemas by the nbformat library. An example schema is the v4.5 schema. These schemas provide the ability to specify the concept of a "valid" notebook using a well-established, declarative format.
The extraSchemas
field allows document authors to introduce additional constraints upon the notebook contents, extending the base notebook schema. In addition to the root $schema
, notebooks must satisfy each schema identified in the notebook's top-level extraSchemas
field, i.e. the true schema is given by allOf(schema, *schemas)
. These extra schemas MUST satisfy a particular metaschema <TODO>
that prohibits the addition of top-level properties to the cell
subschema, or the top level notebook schema. This restriction MAY be relaxed in a future JEP.
Example of valid notebook in 4.7 format:
{
"$schema": "https://jupyter.org/schema/notebook/4.6/notebook-4.6.schema.json"
"extraSchemas": [
"my-extension-schema-uri"
],
"metadata": {
"my-extension": { ... }
}
"cells": [ ... ]
}
Example of schema referenced in extraSchemas
("my-extension-schema-uri"
):
{
"$schema": "https://jupyter.org/schema/notebook/4.6/notebook-4.6.schema.json"
"metadata": {
"type": "object",
"required": ["my-extension"]
}
}
Example of invalid notebook in 4.7 format:
{
"$schema": "https://jupyter.org/schema/notebook/4.6/notebook-4.6.schema.json"
"extraSchemas": [
"my-extension-schema-uri"
],
"metadata": {}
"cells": [ ... ]
}
In the above example, the required
property need not be exhaustive; separate schemas may each require a different set of properties.
If schemas conflict with each other (for example, two schemas define incompatible restrictions on a metadata key), the notebook validation will fail.
Questions from the workshop:
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing