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 execution timings in code cell metadata for v4 spec #144

Merged
merged 3 commits into from
Dec 12, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions nbformat/tests/test4jupyter_metadata_timings.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 7 additions & 0 deletions nbformat/tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 28 additions & 0 deletions nbformat/v4/nbformat.v4.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down