Skip to content
Merged

Fix CI #1193

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
2 changes: 1 addition & 1 deletion tests/app/preheat_multiple_notebooks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

BASE_DIR = os.path.dirname(__file__)
NOTEBOOK_EXECUTION_TIME = 2
NOTEBOOK_EXECUTION_TIME = 3
NUMBER_PREHEATED_KERNEL = 2
TIME_THRESHOLD = 1

Expand Down
21 changes: 15 additions & 6 deletions tests/execute_output_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def normalize_output(output):
if 'traceback' in output:
del output['traceback']
if 'application/vnd.jupyter.widget-view+json' in output.get('data', {}):
output['data']['application/vnd.jupyter.widget-view+json']['model_id'] = '<MODEL_ID>'
output['data']['application/vnd.jupyter.widget-view+json'][
'model_id'
] = '<MODEL_ID>'


def normalize_outputs(outputs):
Expand All @@ -34,24 +36,31 @@ def normalize_outputs(outputs):


def test_execute_output():
path = os.path.join(BASE_DIR, "notebooks/output.ipynb")
path = os.path.join(BASE_DIR, 'notebooks/output.ipynb')
nb = read(path, NO_CONVERT)
nb_voila = deepcopy(nb)
executenb(nb_voila)

widget_states = nb.metadata.widgets[WIDGET_MIME_TYPE_STATE]['state']
widget_states_voila = nb_voila.metadata.widgets[WIDGET_MIME_TYPE_STATE]['state']
widget_states_voila = nb_voila.metadata.widgets[WIDGET_MIME_TYPE_STATE][
'state'
]

for cell_voila, cell in zip(nb_voila.cells, nb.cells):
for output_voila, output in zip(cell_voila.outputs, cell.outputs):
if 'data' in output and WIDGET_MIME_TYPE_VIEW in output['data']:
widget_id = output['data'][WIDGET_MIME_TYPE_VIEW]['model_id']
widget_id_voila = output_voila['data'][WIDGET_MIME_TYPE_VIEW]['model_id']
widget_id_voila = output_voila['data'][WIDGET_MIME_TYPE_VIEW][
'model_id'
]
widget_state = widget_states[widget_id]
widget_state_voila = widget_states_voila[widget_id_voila]
# if the widget is an output widget, it has the outputs, which we also check
assert normalize_outputs(widget_state.state.get('outputs', [])) ==\
normalize_outputs(widget_state_voila.state.get('outputs', []))
assert normalize_outputs(
widget_state.state.get('outputs', [])
) == normalize_outputs(
widget_state_voila.state.get('outputs', [])
)
normalize_output(output_voila)
normalize_output(output)
assert output_voila == output
36 changes: 26 additions & 10 deletions tests/notebooks/output.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"Output()"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the diff also includes formatting changes, wondering if this switch of output_type is the one that did the trick?

Copy link
Member Author

@trungleduc trungleduc Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, since we are testing against ipywidgets 8, the output of the widgets is now of type execute_result instead of display_data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thanks 👍

}
],
"source": [
Expand Down Expand Up @@ -72,8 +73,9 @@
"Output()"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -118,8 +120,9 @@
"Output()"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -165,8 +168,9 @@
"Output()"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -211,8 +215,9 @@
"Output()"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -249,8 +254,9 @@
"Output()"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
Expand All @@ -276,8 +282,9 @@
"Output()"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
Expand All @@ -296,11 +303,20 @@
" print('in outer')\n",
" print('also in inner')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"language": "python"
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -312,7 +328,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.9.13"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down Expand Up @@ -772,5 +788,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}