Skip to content

Commit

Permalink
Fix CI (#1193)
Browse files Browse the repository at this point in the history
* Pin `tornado`

* Add 'ipywidgets' version bound in test

* Remove version pins

* Update `ouput.ipynb` notebook
  • Loading branch information
trungleduc authored Aug 31, 2022
1 parent 636e1d9 commit 249b077
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
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"
}
],
"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
}

0 comments on commit 249b077

Please sign in to comment.