diff --git a/nbformat/tests/test4jupyter_metadata_timings.ipynb b/nbformat/tests/test4jupyter_metadata_timings.ipynb new file mode 100644 index 00000000..2e724a55 --- /dev/null +++ b/nbformat/tests/test4jupyter_metadata_timings.ipynb @@ -0,0 +1,61 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "execution": { + "iopub.execute_input": "2019-08-26T17:50:29.604738Z", + "iopub.status.busy": "2019-08-26T17:50:29.603423Z", + "iopub.status.idle": "2019-08-26T17:50:29.628032Z", + "shell.execute_reply": "2019-08-26T17:50:29.623438Z", + "shell.execute_reply.started": "2019-08-26T17:50:29.604616Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1+1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.0" + }, + "record_timing": true + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/nbformat/tests/test_validator.py b/nbformat/tests/test_validator.py index 70cf3d43..f9ab7550 100644 --- a/nbformat/tests/test_validator.py +++ b/nbformat/tests/test_validator.py @@ -55,6 +55,13 @@ def test_nb4jupyter_metadata(self): validate(nb) self.assertEqual(isvalid(nb), True) + def test_nb4jupyter_metadata_timings(self): + """Tests that a notebook with "timing" in metadata passes validation""" + with self.fopen(u'test4jupyter_metadata_timings.ipynb', u'r') as f: + nb = read(f, as_version=4) + validate(nb) + self.assertTrue(isvalid(nb)) + def test_invalid(self): """Test than an invalid notebook does not pass validation""" # this notebook has a few different errors: diff --git a/nbformat/v4/nbformat.v4.schema.json b/nbformat/v4/nbformat.v4.schema.json index fec1cb49..118414b4 100644 --- a/nbformat/v4/nbformat.v4.schema.json +++ b/nbformat/v4/nbformat.v4.schema.json @@ -205,6 +205,34 @@ "type": "boolean" } }, + "execution": { + "description": "Execution time for the code in the cell. This tracks time at which messages are recieved from iopub or shell channels", + "type": "object", + "properties": { + "iopub.execute_input": { + "description": "header.date (in ISO 8601 format) of iopub channel's execute_input message. It indicates the time at which the kernel broadcast an execute_input message to connected frontends", + "type": "string" + }, + "iopub.status.busy": { + "description": "header.date (in ISO 8601 format) of iopub channel's kernel status message when the status is 'busy'", + "type": "string" + }, + "shell.execute_reply": { + "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", + "type": "string" + }, + "iopub.status.idle": { + "description": "header.date (in ISO 8601 format) of iopub channel's execute_input message. It indicates the time at which kernel finished processing the associated request", + "type": "string" + } + }, + "additionalProperties": true, + "patternProperties": { + "^.*$": { + "type": "string" + } + } + }, "collapsed": { "description": "Whether the cell's output is collapsed/expanded.", "type": "boolean"