nbformat.v4.schema.json 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. {
  2. "$schema": "http://json-schema.org/draft-04/schema#",
  3. "description": "Jupyter Notebook v4.5 JSON schema.",
  4. "type": "object",
  5. "additionalProperties": false,
  6. "required": ["metadata", "nbformat_minor", "nbformat", "cells"],
  7. "properties": {
  8. "metadata": {
  9. "description": "Notebook root-level metadata.",
  10. "type": "object",
  11. "additionalProperties": true,
  12. "properties": {
  13. "kernelspec": {
  14. "description": "Kernel information.",
  15. "type": "object",
  16. "required": ["name", "display_name"],
  17. "properties": {
  18. "name": {
  19. "description": "Name of the kernel specification.",
  20. "type": "string"
  21. },
  22. "display_name": {
  23. "description": "Name to display in UI.",
  24. "type": "string"
  25. }
  26. }
  27. },
  28. "language_info": {
  29. "description": "Kernel information.",
  30. "type": "object",
  31. "required": ["name"],
  32. "properties": {
  33. "name": {
  34. "description": "The programming language which this kernel runs.",
  35. "type": "string"
  36. },
  37. "codemirror_mode": {
  38. "description": "The codemirror mode to use for code in this language.",
  39. "oneOf": [{ "type": "string" }, { "type": "object" }]
  40. },
  41. "file_extension": {
  42. "description": "The file extension for files in this language.",
  43. "type": "string"
  44. },
  45. "mimetype": {
  46. "description": "The mimetype corresponding to files in this language.",
  47. "type": "string"
  48. },
  49. "pygments_lexer": {
  50. "description": "The pygments lexer to use for code in this language.",
  51. "type": "string"
  52. }
  53. }
  54. },
  55. "orig_nbformat": {
  56. "description": "Original notebook format (major number) before converting the notebook between versions. This should never be written to a file.",
  57. "type": "integer",
  58. "minimum": 1
  59. },
  60. "title": {
  61. "description": "The title of the notebook document",
  62. "type": "string"
  63. },
  64. "authors": {
  65. "description": "The author(s) of the notebook document",
  66. "type": "array",
  67. "item": {
  68. "type": "object",
  69. "properties": {
  70. "name": {
  71. "type": "string"
  72. }
  73. },
  74. "additionalProperties": true
  75. }
  76. }
  77. }
  78. },
  79. "nbformat_minor": {
  80. "description": "Notebook format (minor number). Incremented for backward compatible changes to the notebook format.",
  81. "type": "integer",
  82. "minimum": 5
  83. },
  84. "nbformat": {
  85. "description": "Notebook format (major number). Incremented between backwards incompatible changes to the notebook format.",
  86. "type": "integer",
  87. "minimum": 4,
  88. "maximum": 4
  89. },
  90. "cells": {
  91. "description": "Array of cells of the current notebook.",
  92. "type": "array",
  93. "items": { "$ref": "#/definitions/cell" }
  94. }
  95. },
  96. "definitions": {
  97. "cell_id": {
  98. "description": "A string field representing the identifier of this particular cell.",
  99. "type": "string",
  100. "pattern": "^[a-zA-Z0-9-_]+$",
  101. "minLength": 1,
  102. "maxLength": 64
  103. },
  104. "cell": {
  105. "type": "object",
  106. "oneOf": [
  107. { "$ref": "#/definitions/raw_cell" },
  108. { "$ref": "#/definitions/markdown_cell" },
  109. { "$ref": "#/definitions/code_cell" }
  110. ]
  111. },
  112. "raw_cell": {
  113. "description": "Notebook raw nbconvert cell.",
  114. "type": "object",
  115. "additionalProperties": false,
  116. "required": ["id", "cell_type", "metadata", "source"],
  117. "properties": {
  118. "id": { "$ref": "#/definitions/cell_id" },
  119. "cell_type": {
  120. "description": "String identifying the type of cell.",
  121. "enum": ["raw"]
  122. },
  123. "metadata": {
  124. "description": "Cell-level metadata.",
  125. "type": "object",
  126. "additionalProperties": true,
  127. "properties": {
  128. "format": {
  129. "description": "Raw cell metadata format for nbconvert.",
  130. "type": "string"
  131. },
  132. "jupyter": {
  133. "description": "Official Jupyter Metadata for Raw Cells",
  134. "type": "object",
  135. "additionalProperties": true,
  136. "source_hidden": {
  137. "description": "Whether the source is hidden.",
  138. "type": "boolean"
  139. }
  140. },
  141. "name": { "$ref": "#/definitions/misc/metadata_name" },
  142. "tags": { "$ref": "#/definitions/misc/metadata_tags" }
  143. }
  144. },
  145. "attachments": { "$ref": "#/definitions/misc/attachments" },
  146. "source": { "$ref": "#/definitions/misc/source" }
  147. }
  148. },
  149. "markdown_cell": {
  150. "description": "Notebook markdown cell.",
  151. "type": "object",
  152. "additionalProperties": false,
  153. "required": ["id", "cell_type", "metadata", "source"],
  154. "properties": {
  155. "id": { "$ref": "#/definitions/cell_id" },
  156. "cell_type": {
  157. "description": "String identifying the type of cell.",
  158. "enum": ["markdown"]
  159. },
  160. "metadata": {
  161. "description": "Cell-level metadata.",
  162. "type": "object",
  163. "properties": {
  164. "name": { "$ref": "#/definitions/misc/metadata_name" },
  165. "tags": { "$ref": "#/definitions/misc/metadata_tags" },
  166. "jupyter": {
  167. "description": "Official Jupyter Metadata for Markdown Cells",
  168. "type": "object",
  169. "additionalProperties": true,
  170. "source_hidden": {
  171. "description": "Whether the source is hidden.",
  172. "type": "boolean"
  173. }
  174. }
  175. },
  176. "additionalProperties": true
  177. },
  178. "attachments": { "$ref": "#/definitions/misc/attachments" },
  179. "source": { "$ref": "#/definitions/misc/source" }
  180. }
  181. },
  182. "code_cell": {
  183. "description": "Notebook code cell.",
  184. "type": "object",
  185. "additionalProperties": false,
  186. "required": [
  187. "id",
  188. "cell_type",
  189. "metadata",
  190. "source",
  191. "outputs",
  192. "execution_count"
  193. ],
  194. "properties": {
  195. "id": { "$ref": "#/definitions/cell_id" },
  196. "cell_type": {
  197. "description": "String identifying the type of cell.",
  198. "enum": ["code"]
  199. },
  200. "metadata": {
  201. "description": "Cell-level metadata.",
  202. "type": "object",
  203. "additionalProperties": true,
  204. "properties": {
  205. "jupyter": {
  206. "description": "Official Jupyter Metadata for Code Cells",
  207. "type": "object",
  208. "additionalProperties": true,
  209. "source_hidden": {
  210. "description": "Whether the source is hidden.",
  211. "type": "boolean"
  212. },
  213. "outputs_hidden": {
  214. "description": "Whether the outputs are hidden.",
  215. "type": "boolean"
  216. }
  217. },
  218. "execution": {
  219. "description": "Execution time for the code in the cell. This tracks time at which messages are received from iopub or shell channels",
  220. "type": "object",
  221. "properties": {
  222. "iopub.execute_input": {
  223. "description": "header.date (in ISO 8601 format) of iopub channel's execute_input message. It indicates the time at which the kernel broadcasts an execute_input message to connected frontends",
  224. "type": "string"
  225. },
  226. "iopub.status.busy": {
  227. "description": "header.date (in ISO 8601 format) of iopub channel's kernel status message when the status is 'busy'",
  228. "type": "string"
  229. },
  230. "shell.execute_reply": {
  231. "description": "header.date (in ISO 8601 format) of the shell channel's execute_reply message. It indicates the time at which the execute_reply message was created",
  232. "type": "string"
  233. },
  234. "iopub.status.idle": {
  235. "description": "header.date (in ISO 8601 format) of iopub channel's kernel status message when the status is 'idle'. It indicates the time at which kernel finished processing the associated request",
  236. "type": "string"
  237. }
  238. },
  239. "additionalProperties": true,
  240. "patternProperties": {
  241. "^.*$": {
  242. "type": "string"
  243. }
  244. }
  245. },
  246. "collapsed": {
  247. "description": "Whether the cell's output is collapsed/expanded.",
  248. "type": "boolean"
  249. },
  250. "scrolled": {
  251. "description": "Whether the cell's output is scrolled, unscrolled, or autoscrolled.",
  252. "enum": [true, false, "auto"]
  253. },
  254. "name": { "$ref": "#/definitions/misc/metadata_name" },
  255. "tags": { "$ref": "#/definitions/misc/metadata_tags" }
  256. }
  257. },
  258. "source": { "$ref": "#/definitions/misc/source" },
  259. "outputs": {
  260. "description": "Execution, display, or stream outputs.",
  261. "type": "array",
  262. "items": { "$ref": "#/definitions/output" }
  263. },
  264. "execution_count": {
  265. "description": "The code cell's prompt number. Will be null if the cell has not been run.",
  266. "type": ["integer", "null"],
  267. "minimum": 0
  268. }
  269. }
  270. },
  271. "unrecognized_cell": {
  272. "description": "Unrecognized cell from a future minor-revision to the notebook format.",
  273. "type": "object",
  274. "additionalProperties": true,
  275. "required": ["cell_type", "metadata"],
  276. "properties": {
  277. "cell_type": {
  278. "description": "String identifying the type of cell.",
  279. "not": {
  280. "enum": ["markdown", "code", "raw"]
  281. }
  282. },
  283. "metadata": {
  284. "description": "Cell-level metadata.",
  285. "type": "object",
  286. "properties": {
  287. "name": { "$ref": "#/definitions/misc/metadata_name" },
  288. "tags": { "$ref": "#/definitions/misc/metadata_tags" }
  289. },
  290. "additionalProperties": true
  291. }
  292. }
  293. },
  294. "output": {
  295. "type": "object",
  296. "oneOf": [
  297. { "$ref": "#/definitions/execute_result" },
  298. { "$ref": "#/definitions/display_data" },
  299. { "$ref": "#/definitions/stream" },
  300. { "$ref": "#/definitions/error" }
  301. ]
  302. },
  303. "execute_result": {
  304. "description": "Result of executing a code cell.",
  305. "type": "object",
  306. "additionalProperties": false,
  307. "required": ["output_type", "data", "metadata", "execution_count"],
  308. "properties": {
  309. "output_type": {
  310. "description": "Type of cell output.",
  311. "enum": ["execute_result"]
  312. },
  313. "execution_count": {
  314. "description": "A result's prompt number.",
  315. "type": ["integer", "null"],
  316. "minimum": 0
  317. },
  318. "data": { "$ref": "#/definitions/misc/mimebundle" },
  319. "metadata": { "$ref": "#/definitions/misc/output_metadata" }
  320. }
  321. },
  322. "display_data": {
  323. "description": "Data displayed as a result of code cell execution.",
  324. "type": "object",
  325. "additionalProperties": false,
  326. "required": ["output_type", "data", "metadata"],
  327. "properties": {
  328. "output_type": {
  329. "description": "Type of cell output.",
  330. "enum": ["display_data"]
  331. },
  332. "data": { "$ref": "#/definitions/misc/mimebundle" },
  333. "metadata": { "$ref": "#/definitions/misc/output_metadata" }
  334. }
  335. },
  336. "stream": {
  337. "description": "Stream output from a code cell.",
  338. "type": "object",
  339. "additionalProperties": false,
  340. "required": ["output_type", "name", "text"],
  341. "properties": {
  342. "output_type": {
  343. "description": "Type of cell output.",
  344. "enum": ["stream"]
  345. },
  346. "name": {
  347. "description": "The name of the stream (stdout, stderr).",
  348. "type": "string"
  349. },
  350. "text": {
  351. "description": "The stream's text output, represented as an array of strings.",
  352. "$ref": "#/definitions/misc/multiline_string"
  353. }
  354. }
  355. },
  356. "error": {
  357. "description": "Output of an error that occurred during code cell execution.",
  358. "type": "object",
  359. "additionalProperties": false,
  360. "required": ["output_type", "ename", "evalue", "traceback"],
  361. "properties": {
  362. "output_type": {
  363. "description": "Type of cell output.",
  364. "enum": ["error"]
  365. },
  366. "ename": {
  367. "description": "The name of the error.",
  368. "type": "string"
  369. },
  370. "evalue": {
  371. "description": "The value, or message, of the error.",
  372. "type": "string"
  373. },
  374. "traceback": {
  375. "description": "The error's traceback, represented as an array of strings.",
  376. "type": "array",
  377. "items": { "type": "string" }
  378. }
  379. }
  380. },
  381. "unrecognized_output": {
  382. "description": "Unrecognized output from a future minor-revision to the notebook format.",
  383. "type": "object",
  384. "additionalProperties": true,
  385. "required": ["output_type"],
  386. "properties": {
  387. "output_type": {
  388. "description": "Type of cell output.",
  389. "not": {
  390. "enum": ["execute_result", "display_data", "stream", "error"]
  391. }
  392. }
  393. }
  394. },
  395. "misc": {
  396. "metadata_name": {
  397. "description": "The cell's name. If present, must be a non-empty string. Cell names are expected to be unique across all the cells in a given notebook. This criterion cannot be checked by the json schema and must be established by an additional check.",
  398. "type": "string",
  399. "pattern": "^.+$"
  400. },
  401. "metadata_tags": {
  402. "description": "The cell's tags. Tags must be unique, and must not contain commas.",
  403. "type": "array",
  404. "uniqueItems": true,
  405. "items": {
  406. "type": "string",
  407. "pattern": "^[^,]+$"
  408. }
  409. },
  410. "attachments": {
  411. "description": "Media attachments (e.g. inline images), stored as mimebundle keyed by filename.",
  412. "type": "object",
  413. "patternProperties": {
  414. ".*": {
  415. "description": "The attachment's data stored as a mimebundle.",
  416. "$ref": "#/definitions/misc/mimebundle"
  417. }
  418. }
  419. },
  420. "source": {
  421. "description": "Contents of the cell, represented as an array of lines.",
  422. "$ref": "#/definitions/misc/multiline_string"
  423. },
  424. "execution_count": {
  425. "description": "The code cell's prompt number. Will be null if the cell has not been run.",
  426. "type": ["integer", "null"],
  427. "minimum": 0
  428. },
  429. "mimebundle": {
  430. "description": "A mime-type keyed dictionary of data",
  431. "type": "object",
  432. "additionalProperties": {
  433. "description": "mimetype output (e.g. text/plain), represented as either an array of strings or a string.",
  434. "$ref": "#/definitions/misc/multiline_string"
  435. },
  436. "patternProperties": {
  437. "^application/(.*\\+)?json$": {
  438. "description": "Mimetypes with JSON output, can be any type"
  439. }
  440. }
  441. },
  442. "output_metadata": {
  443. "description": "Cell output metadata.",
  444. "type": "object",
  445. "additionalProperties": true
  446. },
  447. "multiline_string": {
  448. "oneOf": [
  449. { "type": "string" },
  450. {
  451. "type": "array",
  452. "items": { "type": "string" }
  453. }
  454. ]
  455. }
  456. }
  457. }
  458. }