Skip to content

Commit 5e4302b

Browse files
committed
Hide the magic display function in docs
1 parent 387c054 commit 5e4302b

File tree

1 file changed

+77
-19
lines changed

1 file changed

+77
-19
lines changed

docs/examples/example.ipynb

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,66 @@
6262
},
6363
{
6464
"cell_type": "code",
65-
"execution_count": 5,
65+
"execution_count": 3,
6666
"metadata": {
6767
"tags": [
6868
"hide-output"
6969
]
7070
},
7171
"outputs": [
7272
{
73-
"ename": "ImportError",
74-
"evalue": "cannot import name 'dial' from 'viam.rpc.dial' (/opt/homebrew/Caskroom/miniconda/base/envs/pysdk/lib/python3.10/site-packages/viam/rpc/dial.py)",
75-
"output_type": "error",
76-
"traceback": [
77-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
78-
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
79-
"Cell \u001b[0;32mIn [5], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mviam\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m logging\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mviam\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mrobot\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mclient\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m RobotClient\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mviam\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mrpc\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdial\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m DialOptions, dial\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mconnect_with_channel\u001b[39m() \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m RobotClient:\n\u001b[1;32m 6\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m dial(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlocalhost:9091\u001b[39m\u001b[38;5;124m'\u001b[39m, DialOptions(insecure\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, disable_webrtc\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)) \u001b[38;5;28;01mas\u001b[39;00m channel:\n",
80-
"\u001b[0;31mImportError\u001b[0m: cannot import name 'dial' from 'viam.rpc.dial' (/opt/homebrew/Caskroom/miniconda/base/envs/pysdk/lib/python3.10/site-packages/viam/rpc/dial.py)"
73+
"name": "stdout",
74+
"output_type": "stream",
75+
"text": [
76+
"[namespace: \"rdk\"\n",
77+
"type: \"component\"\n",
78+
"subtype: \"arm\"\n",
79+
"name: \"arm0\"\n",
80+
", namespace: \"rdk\"\n",
81+
"type: \"component\"\n",
82+
"subtype: \"audio_input\"\n",
83+
"name: \"audio_input0\"\n",
84+
", namespace: \"rdk\"\n",
85+
"type: \"component\"\n",
86+
"subtype: \"base\"\n",
87+
"name: \"base0\"\n",
88+
", namespace: \"rdk\"\n",
89+
"type: \"component\"\n",
90+
"subtype: \"board\"\n",
91+
"name: \"board\"\n",
92+
", namespace: \"rdk\"\n",
93+
"type: \"component\"\n",
94+
"subtype: \"camera\"\n",
95+
"name: \"camera0\"\n",
96+
", namespace: \"rdk\"\n",
97+
"type: \"component\"\n",
98+
"subtype: \"gantry\"\n",
99+
"name: \"gantry0\"\n",
100+
", namespace: \"rdk\"\n",
101+
"type: \"component\"\n",
102+
"subtype: \"gripper\"\n",
103+
"name: \"gripper0\"\n",
104+
", namespace: \"rdk\"\n",
105+
"type: \"component\"\n",
106+
"subtype: \"motor\"\n",
107+
"name: \"motor0\"\n",
108+
", namespace: \"rdk\"\n",
109+
"type: \"component\"\n",
110+
"subtype: \"movement_sensor\"\n",
111+
"name: \"movement_sensor0\"\n",
112+
", namespace: \"rdk\"\n",
113+
"type: \"component\"\n",
114+
"subtype: \"pose_tracker\"\n",
115+
"name: \"pose_tracker0\"\n",
116+
", namespace: \"rdk\"\n",
117+
"type: \"component\"\n",
118+
"subtype: \"sensor\"\n",
119+
"name: \"sensor0\"\n",
120+
", namespace: \"rdk\"\n",
121+
"type: \"component\"\n",
122+
"subtype: \"servo\"\n",
123+
"name: \"servo0\"\n",
124+
"]\n"
81125
]
82126
}
83127
],
@@ -110,6 +154,29 @@
110154
"hide-output"
111155
]
112156
},
157+
"outputs": [],
158+
"source": [
159+
"from viam.components.camera import Camera\n",
160+
"from viam.media.video import CameraMimeType\n",
161+
"\n",
162+
"robot = await connect_with_channel()\n",
163+
"camera = Camera.from_robot(robot, \"camera0\")\n",
164+
"image = await camera.get_image()\n",
165+
"image.save(\"foo.png\")\n",
166+
"\n",
167+
"# Don't forget to close the robot when you're done!\n",
168+
"await robot.close()\n"
169+
]
170+
},
171+
{
172+
"cell_type": "code",
173+
"execution_count": 7,
174+
"metadata": {
175+
"tags": [
176+
"hide-output",
177+
"remove-input"
178+
]
179+
},
113180
"outputs": [
114181
{
115182
"data": {
@@ -123,16 +190,7 @@
123190
}
124191
],
125192
"source": [
126-
"from viam.components.camera import Camera\n",
127-
"from viam.media.video import CameraMimeType\n",
128-
"\n",
129-
"robot = await connect_with_channel()\n",
130-
"camera = Camera.from_robot(robot, \"camera0\")\n",
131-
"image = await camera.get_image()\n",
132-
"display(image)\n",
133-
"\n",
134-
"# Don't forget to close the robot when you're done!\n",
135-
"await robot.close()\n"
193+
"display(image)"
136194
]
137195
},
138196
{

0 commit comments

Comments
 (0)