Skip to content

Commit 0417f8b

Browse files
authored
Add Minimal Notebook Validation (#11440)
### Related #11416 I requested the notebooks get moved so our automated examples test would make sure the notebooks aren't broken. Unfortunately we don't test any of our notebooks so most were broken. A little bit related to broader notebook testing improvement https://linear.app/rerun/issue/RR-1880/test-our-jupyter-notebooks-on-ci ### What I highly recommend reviewing with rich diff for notebooks enabled. * Adds nbqa so we can run mypy on the notebooks to at least ensure the apis align * I couldn't get the config working so unfortunately I just have the directories to search listed in the pixi command * Adds nbstripout but doesn't yet tie it to our py-fmt. Jupyter notebook outputs are just binary so that will bloat the repo and complicate diffs. Unfortunately nbstripout doesn't have a nice config setup so I just put together a simple wrapper. * I made two actual code changes not just in tests since it made sense to resolve notebook mypy errors 1. I made component_type a class method. We basically have component type raw strings everywhere probably because it wasn't easy before to grab them from the class definition rather than instance 2. If we have a recording string the api should actually be a little different than asking globally. I assume we'll always find the id so we universally return a string. This still doesn't execute our notebooks which is probably a worthwhile followup issue.
1 parent c1dfb27 commit 0417f8b

File tree

17 files changed

+1777
-1429
lines changed

17 files changed

+1777
-1429
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ You can now log URDF files directly to Rerun using the `log_file` API.
462462
- Make `archetype_field_name` mandatory in `ComponentDescriptor` [#10082](https://github.com/rerun-io/rerun/pull/10082)
463463

464464
#### 📦 Dependencies
465-
- Update to wgpu 0.25 [#10009](https://github.com/rerun-io/rerun/pull/10009) (thanks [@Vrixyz](https://github.com/Vrixyz)!)
465+
- Update to wgpu 0.25 [#10009](https://github.com/rerun-io/rerun/pull/10009) (thanks [@ThierryBerger](https://github.com/ThierryBerger)!)
466466
- Update Arrow and DataFusion dedpendencies [#10195](https://github.com/rerun-io/rerun/pull/10195)
467467
- Update egui to 0.32 [#10604](https://github.com/rerun-io/rerun/pull/10604)
468468

docs/content/howto/integrations/embed-notebooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ display(viewer)
101101
Whenever an entity is selected in the Viewer, `selected_entities.value` changes. The payload includes other useful information,
102102
such as the position of the selection within a 2D or 3D view.
103103

104-
For a more complete example, see [callbacks.ipynb](https://github.com/rerun-io/rerun/blob/main/rerun_notebook/callbacks.ipynb).
104+
For a more complete example, see [callbacks.ipynb](https://github.com/rerun-io/rerun/blob/main/examples/python/notebook_callbacks/notebook_callbacks.ipynb).
105105

106106
## Working with blueprints
107107

examples/python/notebook/cube.ipynb

Lines changed: 35 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "b31c0a84",
5+
"id": "0",
66
"metadata": {},
77
"source": [
88
"## Rerun imports and initialization"
@@ -11,7 +11,7 @@
1111
{
1212
"cell_type": "code",
1313
"execution_count": null,
14-
"id": "1076c3a0",
14+
"id": "1",
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
@@ -31,7 +31,7 @@
3131
{
3232
"attachments": {},
3333
"cell_type": "markdown",
34-
"id": "bf894a1f",
34+
"id": "2",
3535
"metadata": {},
3636
"source": [
3737
"## Helper to create the colored cube\n",
@@ -42,7 +42,7 @@
4242
{
4343
"cell_type": "code",
4444
"execution_count": null,
45-
"id": "f709925e",
45+
"id": "3",
4646
"metadata": {
4747
"jupyter": {
4848
"source_hidden": true
@@ -97,7 +97,7 @@
9797
},
9898
{
9999
"cell_type": "markdown",
100-
"id": "04c095ef",
100+
"id": "4",
101101
"metadata": {},
102102
"source": [
103103
"## Logging some data\n",
@@ -110,7 +110,7 @@
110110
{
111111
"cell_type": "code",
112112
"execution_count": null,
113-
"id": "92871ea1",
113+
"id": "5",
114114
"metadata": {},
115115
"outputs": [],
116116
"source": [
@@ -128,7 +128,7 @@
128128
},
129129
{
130130
"cell_type": "markdown",
131-
"id": "187430e1",
131+
"id": "6",
132132
"metadata": {},
133133
"source": [
134134
"## Logging live data\n",
@@ -141,7 +141,7 @@
141141
{
142142
"cell_type": "code",
143143
"execution_count": null,
144-
"id": "246c8eb8",
144+
"id": "7",
145145
"metadata": {},
146146
"outputs": [],
147147
"source": [
@@ -162,7 +162,7 @@
162162
},
163163
{
164164
"cell_type": "markdown",
165-
"id": "649b8e80-e69d-4b6b-be51-50cbf4c20495",
165+
"id": "8",
166166
"metadata": {},
167167
"source": [
168168
"## Incremental logging\n",
@@ -175,7 +175,7 @@
175175
{
176176
"cell_type": "code",
177177
"execution_count": null,
178-
"id": "7e4a9831-ac6c-4503-bcd7-b1212d0d542b",
178+
"id": "9",
179179
"metadata": {},
180180
"outputs": [],
181181
"source": [
@@ -187,7 +187,7 @@
187187
},
188188
{
189189
"cell_type": "markdown",
190-
"id": "36f9f61b",
190+
"id": "10",
191191
"metadata": {},
192192
"source": [
193193
"## Starting a new recording\n",
@@ -198,7 +198,7 @@
198198
{
199199
"cell_type": "code",
200200
"execution_count": null,
201-
"id": "c4cc33fd",
201+
"id": "11",
202202
"metadata": {},
203203
"outputs": [],
204204
"source": [
@@ -218,7 +218,7 @@
218218
},
219219
{
220220
"cell_type": "markdown",
221-
"id": "31d392a8",
221+
"id": "12",
222222
"metadata": {},
223223
"source": [
224224
"## Adjusting the view\n",
@@ -229,7 +229,7 @@
229229
{
230230
"cell_type": "code",
231231
"execution_count": null,
232-
"id": "1a1b0f66-4287-4705-8be5-ae837ffe3f90",
232+
"id": "13",
233233
"metadata": {
234234
"tags": []
235235
},
@@ -240,12 +240,12 @@
240240
"small_cube = build_color_grid(3, 3, 3, twist=0)\n",
241241
"rr.log(\"small_cube\", rr.Points3D(small_cube.positions, colors=small_cube.colors, radii=0.5))\n",
242242
"\n",
243-
"rr.notebook_show(width=\"auto\", height=400)"
243+
"rr.notebook_show(height=400)"
244244
]
245245
},
246246
{
247247
"cell_type": "markdown",
248-
"id": "ff84c840",
248+
"id": "14",
249249
"metadata": {},
250250
"source": [
251251
"To update the default width and height, you can use the `rerun.notebook.set_default_size` function.\n",
@@ -256,7 +256,7 @@
256256
{
257257
"cell_type": "code",
258258
"execution_count": null,
259-
"id": "81157021",
259+
"id": "15",
260260
"metadata": {},
261261
"outputs": [],
262262
"source": [
@@ -275,7 +275,7 @@
275275
{
276276
"cell_type": "code",
277277
"execution_count": null,
278-
"id": "755957e0",
278+
"id": "16",
279279
"metadata": {},
280280
"outputs": [],
281281
"source": [
@@ -284,7 +284,7 @@
284284
},
285285
{
286286
"cell_type": "markdown",
287-
"id": "a9812634-067f-4e07-95fb-cb9a506c42d3",
287+
"id": "17",
288288
"metadata": {},
289289
"source": [
290290
"## Using blueprints\n",
@@ -297,7 +297,7 @@
297297
{
298298
"cell_type": "code",
299299
"execution_count": null,
300-
"id": "eb8f7701",
300+
"id": "18",
301301
"metadata": {},
302302
"outputs": [],
303303
"source": [
@@ -326,7 +326,7 @@
326326
},
327327
{
328328
"cell_type": "markdown",
329-
"id": "a63b30d7",
329+
"id": "19",
330330
"metadata": {},
331331
"source": [
332332
"## Extra convenience\n",
@@ -339,7 +339,7 @@
339339
{
340340
"cell_type": "code",
341341
"execution_count": null,
342-
"id": "6d1bf2ab",
342+
"id": "20",
343343
"metadata": {},
344344
"outputs": [],
345345
"source": [
@@ -359,7 +359,7 @@
359359
},
360360
{
361361
"cell_type": "markdown",
362-
"id": "ef9087de-d090-4c90-ab3e-18c20c92bff6",
362+
"id": "21",
363363
"metadata": {},
364364
"source": [
365365
"## Working with non-global streams\n",
@@ -372,7 +372,7 @@
372372
{
373373
"cell_type": "code",
374374
"execution_count": null,
375-
"id": "ed86cc19-45cf-4c21-9a94-c4ce2ade7f65",
375+
"id": "22",
376376
"metadata": {},
377377
"outputs": [],
378378
"source": [
@@ -388,7 +388,7 @@
388388
},
389389
{
390390
"cell_type": "markdown",
391-
"id": "c1787330-5301-4ab7-8ccb-feda3c6a1ed0",
391+
"id": "23",
392392
"metadata": {},
393393
"source": [
394394
"## Using the Viewer object directly\n",
@@ -401,24 +401,9 @@
401401
{
402402
"cell_type": "code",
403403
"execution_count": null,
404-
"id": "119ef07e-a775-4fce-a50b-f5d966c6507e",
404+
"id": "24",
405405
"metadata": {},
406-
"outputs": [
407-
{
408-
"data": {
409-
"application/vnd.jupyter.widget-view+json": {
410-
"model_id": "c9fb0cf8b1604199b821fe6a9da5eeb2",
411-
"version_major": 2,
412-
"version_minor": 1
413-
},
414-
"text/plain": [
415-
"Viewer()"
416-
]
417-
},
418-
"metadata": {},
419-
"output_type": "display_data"
420-
}
421-
],
406+
"outputs": [],
422407
"source": [
423408
"rec = rr.RecordingStream(\"rerun_example_multi_recording\", recording_id=uuid.uuid4())\n",
424409
"\n",
@@ -432,7 +417,7 @@
432417
{
433418
"cell_type": "code",
434419
"execution_count": null,
435-
"id": "40354733-7feb-45fe-8ba6-dbbdbc070983",
420+
"id": "25",
436421
"metadata": {},
437422
"outputs": [],
438423
"source": [
@@ -450,7 +435,7 @@
450435
},
451436
{
452437
"cell_type": "markdown",
453-
"id": "e9737edc",
438+
"id": "26",
454439
"metadata": {},
455440
"source": [
456441
"## Controlling the Viewer\n",
@@ -461,7 +446,7 @@
461446
{
462447
"cell_type": "code",
463448
"execution_count": null,
464-
"id": "6eccfbe2",
449+
"id": "27",
465450
"metadata": {},
466451
"outputs": [],
467452
"source": [
@@ -489,7 +474,7 @@
489474
},
490475
{
491476
"cell_type": "markdown",
492-
"id": "5a1e0d1f",
477+
"id": "28",
493478
"metadata": {},
494479
"source": [
495480
"The state of each panel in the viewer can be overridden, locking it in the specified state."
@@ -498,7 +483,7 @@
498483
{
499484
"cell_type": "code",
500485
"execution_count": null,
501-
"id": "3d6804d6",
486+
"id": "29",
502487
"metadata": {},
503488
"outputs": [],
504489
"source": [
@@ -507,7 +492,7 @@
507492
},
508493
{
509494
"cell_type": "markdown",
510-
"id": "5cdad3c3",
495+
"id": "30",
511496
"metadata": {},
512497
"source": [
513498
"In multi-recording scenarios, the active recording can be set using `set_active_recording`. The timeline panel's state for the currently active recording can be controlled using `set_time_ctrl`."
@@ -516,7 +501,7 @@
516501
{
517502
"cell_type": "code",
518503
"execution_count": null,
519-
"id": "30d0107b",
504+
"id": "31",
520505
"metadata": {},
521506
"outputs": [],
522507
"source": [
@@ -528,7 +513,7 @@
528513
},
529514
{
530515
"cell_type": "markdown",
531-
"id": "49cd6abd",
516+
"id": "32",
532517
"metadata": {},
533518
"source": [
534519
"Switch between the two recordings in the blueprint panel to see the updated timelines."

0 commit comments

Comments
 (0)