Skip to content

Commit a9eda92

Browse files
committed
Added remote example notebook
1 parent e1a9d87 commit a9eda92

File tree

1 file changed

+182
-0
lines changed

1 file changed

+182
-0
lines changed

doc/remote_example.ipynb

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "76b9af91-1233-485b-a616-826a8ccfcbc8",
6+
"metadata": {},
7+
"source": [
8+
"DataLab remote control example\n",
9+
"==============================\n",
10+
"\n",
11+
"Example of remote control of DataLab current session, \n",
12+
"from asimple notebook.\n",
13+
"\n",
14+
"The only requirement is to install the *DataLab Simple Client* package (using `pip install cdlclient`, for example).b"
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": 19,
20+
"id": "47c889ba-ca07-46dd-bec0-b08d67bd1eb2",
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"import numpy as np\n",
25+
"from cdlclient import SimpleRemoteProxy\n",
26+
"proxy = SimpleRemoteProxy()"
27+
]
28+
},
29+
{
30+
"cell_type": "markdown",
31+
"id": "721d52f6-2df8-4559-89d2-f7088a5e2ee2",
32+
"metadata": {},
33+
"source": [
34+
"Connecting to DataLab current session:"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": 20,
40+
"id": "1de8616a-619c-4d5b-869f-fb41cf72b7cf",
41+
"metadata": {},
42+
"outputs": [
43+
{
44+
"name": "stdout",
45+
"output_type": "stream",
46+
"text": [
47+
"Connecting to DataLab XML-RPC server...OK (port: 62547)\n"
48+
]
49+
}
50+
],
51+
"source": [
52+
"proxy.connect()"
53+
]
54+
},
55+
{
56+
"cell_type": "markdown",
57+
"id": "9246a105-d73d-4ba3-81e1-4fadd042a4c6",
58+
"metadata": {},
59+
"source": [
60+
"Executing commands in DataLab:"
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": 21,
66+
"id": "ccdddb07-cc54-42dd-b744-751516ae73d9",
67+
"metadata": {},
68+
"outputs": [
69+
{
70+
"data": {
71+
"text/plain": [
72+
"True"
73+
]
74+
},
75+
"execution_count": 21,
76+
"metadata": {},
77+
"output_type": "execute_result"
78+
}
79+
],
80+
"source": [
81+
"z = np.random.rand(20, 20)\n",
82+
"proxy.add_image(\"toto\", z)"
83+
]
84+
},
85+
{
86+
"cell_type": "code",
87+
"execution_count": 22,
88+
"id": "7216fc12-2675-48ff-a62a-64b5516c2e09",
89+
"metadata": {},
90+
"outputs": [
91+
{
92+
"data": {
93+
"text/plain": [
94+
"True"
95+
]
96+
},
97+
"execution_count": 22,
98+
"metadata": {},
99+
"output_type": "execute_result"
100+
}
101+
],
102+
"source": [
103+
"x = np.array([1.0, 2.0, 3.0])\n",
104+
"y = np.array([4.0, 5.0, -1.0])\n",
105+
"proxy.add_signal(\"toto\", x, y)"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": 23,
111+
"id": "4a094ecb-5314-42d8-be60-0ce419275e8f",
112+
"metadata": {},
113+
"outputs": [
114+
{
115+
"data": {
116+
"text/plain": [
117+
"True"
118+
]
119+
},
120+
"execution_count": 23,
121+
"metadata": {},
122+
"output_type": "execute_result"
123+
}
124+
],
125+
"source": [
126+
"proxy.compute_derivative()"
127+
]
128+
},
129+
{
130+
"cell_type": "code",
131+
"execution_count": 24,
132+
"id": "94fc3b6d-8d4a-40d6-ad34-9ecb4888db58",
133+
"metadata": {},
134+
"outputs": [],
135+
"source": [
136+
"proxy.set_current_panel(\"image\")"
137+
]
138+
},
139+
{
140+
"cell_type": "code",
141+
"execution_count": 25,
142+
"id": "2b0b4fc7-c282-4c2c-bb57-6df3241524ce",
143+
"metadata": {},
144+
"outputs": [
145+
{
146+
"data": {
147+
"text/plain": [
148+
"True"
149+
]
150+
},
151+
"execution_count": 25,
152+
"metadata": {},
153+
"output_type": "execute_result"
154+
}
155+
],
156+
"source": [
157+
"proxy.compute_fft()"
158+
]
159+
}
160+
],
161+
"metadata": {
162+
"kernelspec": {
163+
"display_name": "Python 3 (ipykernel)",
164+
"language": "python",
165+
"name": "python3"
166+
},
167+
"language_info": {
168+
"codemirror_mode": {
169+
"name": "ipython",
170+
"version": 3
171+
},
172+
"file_extension": ".py",
173+
"mimetype": "text/x-python",
174+
"name": "python",
175+
"nbconvert_exporter": "python",
176+
"pygments_lexer": "ipython3",
177+
"version": "3.11.6"
178+
}
179+
},
180+
"nbformat": 4,
181+
"nbformat_minor": 5
182+
}

0 commit comments

Comments
 (0)