obi-notebook 0.2.dev1__tar.gz → 0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/PKG-INFO +1 -1
- obi_notebook-0.3/example.ipynb +397 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/src/obi_notebook/get_entities.py +7 -2
- obi_notebook-0.3/src/obi_notebook/get_environment.py +25 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/src/obi_notebook/get_projects.py +5 -1
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/src/obi_notebook.egg-info/PKG-INFO +1 -1
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/src/obi_notebook.egg-info/SOURCES.txt +1 -0
- obi_notebook-0.2.dev1/example.ipynb +0 -183
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/.github/workflows/sdist.yml +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/.github/workflows/tox.yml +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/.gitignore +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/CHANGELOG.rst +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/LICENSE.txt +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/README.md +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/demo.gif +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/pyproject.toml +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/setup.cfg +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/src/obi_notebook/__init__.py +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/src/obi_notebook.egg-info/dependency_links.txt +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/src/obi_notebook.egg-info/requires.txt +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/src/obi_notebook.egg-info/top_level.txt +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/tox.ini +0 -0
- {obi_notebook-0.2.dev1 → obi_notebook-0.3}/uv.lock +0 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "code",
|
|
5
|
+
"execution_count": 1,
|
|
6
|
+
"id": "d139baec",
|
|
7
|
+
"metadata": {},
|
|
8
|
+
"outputs": [
|
|
9
|
+
{
|
|
10
|
+
"name": "stdout",
|
|
11
|
+
"output_type": "stream",
|
|
12
|
+
"text": [
|
|
13
|
+
"production\n"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "stderr",
|
|
18
|
+
"output_type": "stream",
|
|
19
|
+
"text": [
|
|
20
|
+
"/Users/mwr/Documents/repositories/obi-notebook/.venv/lib/python3.13/site-packages/obi_notebook/get_environment.py:22: RuntimeWarning: No environment specified. Using production.\n",
|
|
21
|
+
" warnings.warn(f\"No environment specified. Using production.\",\n"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"source": [
|
|
26
|
+
"import os\n",
|
|
27
|
+
"\n",
|
|
28
|
+
"import obi_auth\n",
|
|
29
|
+
"\n",
|
|
30
|
+
"from obi_notebook import get_entities, get_environment, get_projects\n",
|
|
31
|
+
"from obi_notebook.get_environment import VAR_ENVIRONMENT\n",
|
|
32
|
+
"\n",
|
|
33
|
+
"# Should raise warning: Environment not selected.\n",
|
|
34
|
+
"environment_str = get_environment.get_environment()\n",
|
|
35
|
+
"print(environment_str)"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"cell_type": "code",
|
|
40
|
+
"execution_count": 2,
|
|
41
|
+
"id": "304f4266",
|
|
42
|
+
"metadata": {},
|
|
43
|
+
"outputs": [
|
|
44
|
+
{
|
|
45
|
+
"name": "stdout",
|
|
46
|
+
"output_type": "stream",
|
|
47
|
+
"text": [
|
|
48
|
+
"production\n"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "stderr",
|
|
53
|
+
"output_type": "stream",
|
|
54
|
+
"text": [
|
|
55
|
+
"/Users/mwr/Documents/repositories/obi-notebook/.venv/lib/python3.13/site-packages/obi_notebook/get_environment.py:19: RuntimeWarning: Specified environment 'invalid' unknown. Using production.\n",
|
|
56
|
+
" warnings.warn(f\"Specified environment '{var}' unknown. Using production.\",\n"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"source": [
|
|
61
|
+
"os.environ[VAR_ENVIRONMENT] = \"invalid\"\n",
|
|
62
|
+
"\n",
|
|
63
|
+
"# Should raise warning: Environment unknown.\n",
|
|
64
|
+
"environment_str = get_environment.get_environment()\n",
|
|
65
|
+
"print(environment_str)"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"cell_type": "code",
|
|
70
|
+
"execution_count": 3,
|
|
71
|
+
"id": "7eb47475-67c6-499a-a2b4-19f8a64974d0",
|
|
72
|
+
"metadata": {},
|
|
73
|
+
"outputs": [
|
|
74
|
+
{
|
|
75
|
+
"name": "stdout",
|
|
76
|
+
"output_type": "stream",
|
|
77
|
+
"text": [
|
|
78
|
+
"staging\n"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"source": [
|
|
83
|
+
"os.environ[VAR_ENVIRONMENT] = \"staging\"\n",
|
|
84
|
+
"environment_str = get_environment.get_environment()\n",
|
|
85
|
+
"print(environment_str)"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"cell_type": "markdown",
|
|
90
|
+
"id": "4d984b92-cadd-4b07-9813-b2333272610f",
|
|
91
|
+
"metadata": {},
|
|
92
|
+
"source": [
|
|
93
|
+
"get authentication token"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"cell_type": "code",
|
|
98
|
+
"execution_count": 4,
|
|
99
|
+
"id": "323cb45c-91e3-451f-8a80-374e61433d31",
|
|
100
|
+
"metadata": {},
|
|
101
|
+
"outputs": [],
|
|
102
|
+
"source": [
|
|
103
|
+
"token = obi_auth.get_token(environment=environment_str)"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"cell_type": "markdown",
|
|
108
|
+
"id": "b60e8643-3ad5-4619-a052-5bd8b64713fd",
|
|
109
|
+
"metadata": {},
|
|
110
|
+
"source": [
|
|
111
|
+
"a widget to select project to use"
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"cell_type": "code",
|
|
116
|
+
"execution_count": 5,
|
|
117
|
+
"id": "77c47560-1163-4466-83fc-43abc6e0801a",
|
|
118
|
+
"metadata": {},
|
|
119
|
+
"outputs": [
|
|
120
|
+
{
|
|
121
|
+
"data": {
|
|
122
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
123
|
+
"model_id": "45fd425a2ed84685b37a3f567f960a23",
|
|
124
|
+
"version_major": 2,
|
|
125
|
+
"version_minor": 0
|
|
126
|
+
},
|
|
127
|
+
"text/plain": [
|
|
128
|
+
"Dropdown(description='Select:', options=(('Proximal vs. distal inhibition', {'id': '32008ab5-76cf-47cd-b98b-a5…"
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
"metadata": {},
|
|
132
|
+
"output_type": "display_data"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"source": [
|
|
136
|
+
"project_context = get_projects.get_projects(token)"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"cell_type": "code",
|
|
141
|
+
"execution_count": 6,
|
|
142
|
+
"id": "d538dcac-1bdc-496b-8840-a7b32ea842ed",
|
|
143
|
+
"metadata": {},
|
|
144
|
+
"outputs": [
|
|
145
|
+
{
|
|
146
|
+
"data": {
|
|
147
|
+
"text/plain": [
|
|
148
|
+
"ProjectContext(project_id=UUID('32008ab5-76cf-47cd-b98b-a5013b30b533'), virtual_lab_id=UUID('1d8cccc0-f992-46aa-aac6-88e63c914314'), environment=<DeploymentEnvironment.staging: 'staging'>)"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"execution_count": 6,
|
|
152
|
+
"metadata": {},
|
|
153
|
+
"output_type": "execute_result"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"source": [
|
|
157
|
+
"project_context"
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"cell_type": "code",
|
|
162
|
+
"execution_count": 7,
|
|
163
|
+
"id": "93029f77-d71f-40f4-8c4d-9f23d2b650bc",
|
|
164
|
+
"metadata": {},
|
|
165
|
+
"outputs": [
|
|
166
|
+
{
|
|
167
|
+
"data": {
|
|
168
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
169
|
+
"model_id": "b92bedf59a6a49c4b0c6d9dcf5da4268",
|
|
170
|
+
"version_major": 2,
|
|
171
|
+
"version_minor": 0
|
|
172
|
+
},
|
|
173
|
+
"text/plain": [
|
|
174
|
+
"HBox(children=(Dropdown(description='Scale:', index=1, options=('pair', 'small', 'microcircuit', 'region', 'sy…"
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
"metadata": {},
|
|
178
|
+
"output_type": "display_data"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"data": {
|
|
182
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
183
|
+
"model_id": "36957a0de8ea476f9fc97dbd665740d3",
|
|
184
|
+
"version_major": 2,
|
|
185
|
+
"version_minor": 0
|
|
186
|
+
},
|
|
187
|
+
"text/plain": [
|
|
188
|
+
"Output()"
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
"metadata": {},
|
|
192
|
+
"output_type": "display_data"
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"source": [
|
|
196
|
+
"circuit_ids = []\n",
|
|
197
|
+
"circuit_ids = get_entities.get_entities(\n",
|
|
198
|
+
" \"circuit\",\n",
|
|
199
|
+
" token,\n",
|
|
200
|
+
" circuit_ids,\n",
|
|
201
|
+
" return_entities=False,\n",
|
|
202
|
+
" multi_select=True,\n",
|
|
203
|
+
" show_pages=True,\n",
|
|
204
|
+
" project_context=project_context,\n",
|
|
205
|
+
" page_size=10,\n",
|
|
206
|
+
" default_scale=\"small\",\n",
|
|
207
|
+
" exclude_scales=[\"single\"],\n",
|
|
208
|
+
" add_columns=[\"subject.name\"],\n",
|
|
209
|
+
")"
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"cell_type": "code",
|
|
214
|
+
"execution_count": 8,
|
|
215
|
+
"id": "da699ed4-39fd-4602-b54d-58a0b58c2539",
|
|
216
|
+
"metadata": {},
|
|
217
|
+
"outputs": [
|
|
218
|
+
{
|
|
219
|
+
"data": {
|
|
220
|
+
"text/plain": [
|
|
221
|
+
"['c940188a-5408-4185-ab3b-dbb20de16621']"
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
"execution_count": 8,
|
|
225
|
+
"metadata": {},
|
|
226
|
+
"output_type": "execute_result"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"source": [
|
|
230
|
+
"circuit_ids"
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"cell_type": "code",
|
|
235
|
+
"execution_count": 9,
|
|
236
|
+
"id": "a5f5445d-a61a-4fbe-962f-51e701434771",
|
|
237
|
+
"metadata": {},
|
|
238
|
+
"outputs": [
|
|
239
|
+
{
|
|
240
|
+
"data": {
|
|
241
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
242
|
+
"model_id": "04360c5e3d5a4d318fa446f3e06e9853",
|
|
243
|
+
"version_major": 2,
|
|
244
|
+
"version_minor": 0
|
|
245
|
+
},
|
|
246
|
+
"text/plain": [
|
|
247
|
+
"HBox(children=(Combobox(value='', description='M-Type:', ensure_option=True, options=('A_BC', 'A_BFP', 'ACB_CT…"
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
"metadata": {},
|
|
251
|
+
"output_type": "display_data"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"data": {
|
|
255
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
256
|
+
"model_id": "9247a1fde0a7438d853325c8a0eaf428",
|
|
257
|
+
"version_major": 2,
|
|
258
|
+
"version_minor": 0
|
|
259
|
+
},
|
|
260
|
+
"text/plain": [
|
|
261
|
+
"Output()"
|
|
262
|
+
]
|
|
263
|
+
},
|
|
264
|
+
"metadata": {},
|
|
265
|
+
"output_type": "display_data"
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
"source": [
|
|
269
|
+
"morph_ids = []\n",
|
|
270
|
+
"morph_ids = get_entities.get_entities(\n",
|
|
271
|
+
" \"cell-morphology\",\n",
|
|
272
|
+
" token,\n",
|
|
273
|
+
" morph_ids,\n",
|
|
274
|
+
" return_entities=False,\n",
|
|
275
|
+
" multi_select=True,\n",
|
|
276
|
+
" show_pages=True,\n",
|
|
277
|
+
" project_context=project_context,\n",
|
|
278
|
+
" page_size=100,\n",
|
|
279
|
+
" add_columns=[\"mtypes\"],\n",
|
|
280
|
+
")"
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"cell_type": "code",
|
|
285
|
+
"execution_count": 10,
|
|
286
|
+
"id": "2c9d28c4",
|
|
287
|
+
"metadata": {},
|
|
288
|
+
"outputs": [
|
|
289
|
+
{
|
|
290
|
+
"data": {
|
|
291
|
+
"text/plain": [
|
|
292
|
+
"['afa2434f-1ccc-4fff-a047-d399e59768c9']"
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
"execution_count": 10,
|
|
296
|
+
"metadata": {},
|
|
297
|
+
"output_type": "execute_result"
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
"source": [
|
|
301
|
+
"morph_ids"
|
|
302
|
+
]
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"cell_type": "code",
|
|
306
|
+
"execution_count": 11,
|
|
307
|
+
"id": "90757b52",
|
|
308
|
+
"metadata": {},
|
|
309
|
+
"outputs": [
|
|
310
|
+
{
|
|
311
|
+
"data": {
|
|
312
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
313
|
+
"model_id": "a3915f160d944f14b1a401e643b1f7e1",
|
|
314
|
+
"version_major": 2,
|
|
315
|
+
"version_minor": 0
|
|
316
|
+
},
|
|
317
|
+
"text/plain": [
|
|
318
|
+
"HBox(children=(Combobox(value='', description='EM-Dataset:', ensure_option=True, options=('Portion 65 of the I…"
|
|
319
|
+
]
|
|
320
|
+
},
|
|
321
|
+
"metadata": {},
|
|
322
|
+
"output_type": "display_data"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"data": {
|
|
326
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
327
|
+
"model_id": "d1b44ab0d11146a1a11e3f32df4ceeba",
|
|
328
|
+
"version_major": 2,
|
|
329
|
+
"version_minor": 0
|
|
330
|
+
},
|
|
331
|
+
"text/plain": [
|
|
332
|
+
"Output()"
|
|
333
|
+
]
|
|
334
|
+
},
|
|
335
|
+
"metadata": {},
|
|
336
|
+
"output_type": "display_data"
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
"source": [
|
|
340
|
+
"cell_mesh_ids = []\n",
|
|
341
|
+
"cell_mesh_ids = get_entities.get_entities(\n",
|
|
342
|
+
" \"em-cell-mesh\",\n",
|
|
343
|
+
" token,\n",
|
|
344
|
+
" cell_mesh_ids,\n",
|
|
345
|
+
" return_entities=False,\n",
|
|
346
|
+
" multi_select=True,\n",
|
|
347
|
+
" show_pages=True,\n",
|
|
348
|
+
" project_context=project_context,\n",
|
|
349
|
+
" page_size=10,\n",
|
|
350
|
+
" add_columns=[\"dense_reconstruction_cell_id\", \"subject.name\"],\n",
|
|
351
|
+
")"
|
|
352
|
+
]
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"cell_type": "code",
|
|
356
|
+
"execution_count": 12,
|
|
357
|
+
"id": "6964ebe2",
|
|
358
|
+
"metadata": {},
|
|
359
|
+
"outputs": [
|
|
360
|
+
{
|
|
361
|
+
"data": {
|
|
362
|
+
"text/plain": [
|
|
363
|
+
"['e915d259-d03a-4544-8109-a86bbd4cd722']"
|
|
364
|
+
]
|
|
365
|
+
},
|
|
366
|
+
"execution_count": 12,
|
|
367
|
+
"metadata": {},
|
|
368
|
+
"output_type": "execute_result"
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
"source": [
|
|
372
|
+
"cell_mesh_ids"
|
|
373
|
+
]
|
|
374
|
+
}
|
|
375
|
+
],
|
|
376
|
+
"metadata": {
|
|
377
|
+
"kernelspec": {
|
|
378
|
+
"display_name": ".venv (3.13.1)",
|
|
379
|
+
"language": "python",
|
|
380
|
+
"name": "python3"
|
|
381
|
+
},
|
|
382
|
+
"language_info": {
|
|
383
|
+
"codemirror_mode": {
|
|
384
|
+
"name": "ipython",
|
|
385
|
+
"version": 3
|
|
386
|
+
},
|
|
387
|
+
"file_extension": ".py",
|
|
388
|
+
"mimetype": "text/x-python",
|
|
389
|
+
"name": "python",
|
|
390
|
+
"nbconvert_exporter": "python",
|
|
391
|
+
"pygments_lexer": "ipython3",
|
|
392
|
+
"version": "3.13.1"
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
"nbformat": 4,
|
|
396
|
+
"nbformat_minor": 5
|
|
397
|
+
}
|
|
@@ -8,6 +8,8 @@ from entitysdk import Client, models, types
|
|
|
8
8
|
from ipydatagrid import DataGrid, TextRenderer
|
|
9
9
|
from IPython.display import clear_output, display
|
|
10
10
|
|
|
11
|
+
from obi_notebook.get_environment import get_environment
|
|
12
|
+
|
|
11
13
|
LST_MTYPES_ = None
|
|
12
14
|
LST_SPECIES_ = None
|
|
13
15
|
LST_EMDATASETS_ = None
|
|
@@ -86,7 +88,7 @@ def get_entities(
|
|
|
86
88
|
entity_type,
|
|
87
89
|
token,
|
|
88
90
|
result,
|
|
89
|
-
env=
|
|
91
|
+
env=None,
|
|
90
92
|
project_context=None,
|
|
91
93
|
return_entities=False,
|
|
92
94
|
multi_select=True,
|
|
@@ -101,6 +103,8 @@ def get_entities(
|
|
|
101
103
|
Note: The 'result' parameter is a mutable object (a list) that is modified in-place
|
|
102
104
|
and also returned.
|
|
103
105
|
"""
|
|
106
|
+
if env is None:
|
|
107
|
+
env = get_environment()
|
|
104
108
|
if page_size is not None:
|
|
105
109
|
if page_size <= 0:
|
|
106
110
|
raise ValueError("ERROR: Page size must be larger than 0!")
|
|
@@ -129,7 +133,7 @@ def get_entities(
|
|
|
129
133
|
)
|
|
130
134
|
filters_dict["scale"] = scale_filter
|
|
131
135
|
filters_dict["name__ilike"] = widgets.Text(description="Name:")
|
|
132
|
-
elif entity_type == "reconstruction-morphology":
|
|
136
|
+
elif entity_type == "reconstruction-morphology" or entity_type == "cell-morphology":
|
|
133
137
|
lst_mtypes = _list_of_existing_mtypes(entity_core_url, token) + [""]
|
|
134
138
|
mtype_filter = widgets.Combobox(
|
|
135
139
|
placeholder="Select M-Type",
|
|
@@ -295,6 +299,7 @@ def get_entities(
|
|
|
295
299
|
result.extend(l_ids)
|
|
296
300
|
|
|
297
301
|
grid.observe(on_selection_change, names="selections")
|
|
302
|
+
grid.selections = [{"r1": 0, "r2": 0, "c1": 0, "c2": len(column_widths)}]
|
|
298
303
|
|
|
299
304
|
for filter_ in filters_dict.values():
|
|
300
305
|
filter_.observe(on_change, names="value")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Code for handling the deployment environment."""
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
from os import getenv
|
|
5
|
+
|
|
6
|
+
from obi_auth.typedef import DeploymentEnvironment
|
|
7
|
+
|
|
8
|
+
VAR_ENVIRONMENT = "OBI_ENVIRONMENT"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_environment():
|
|
12
|
+
"""Try to get the environment to run in from environment variable."""
|
|
13
|
+
var = getenv(VAR_ENVIRONMENT)
|
|
14
|
+
if var is not None:
|
|
15
|
+
if var in DeploymentEnvironment._member_map_:
|
|
16
|
+
return DeploymentEnvironment(var)
|
|
17
|
+
else:
|
|
18
|
+
warnings.warn(
|
|
19
|
+
f"Specified environment '{var}' unknown. Using production.",
|
|
20
|
+
RuntimeWarning,
|
|
21
|
+
stacklevel=2,
|
|
22
|
+
)
|
|
23
|
+
else:
|
|
24
|
+
warnings.warn("No environment specified. Using production.", RuntimeWarning, stacklevel=2)
|
|
25
|
+
return DeploymentEnvironment.production
|
|
@@ -5,11 +5,15 @@ import requests
|
|
|
5
5
|
from entitysdk import ProjectContext
|
|
6
6
|
from IPython.display import display
|
|
7
7
|
|
|
8
|
+
from obi_notebook.get_environment import get_environment
|
|
9
|
+
|
|
8
10
|
selected_project = None # Global variable
|
|
9
11
|
|
|
10
12
|
|
|
11
|
-
def get_projects(token, env=
|
|
13
|
+
def get_projects(token, env=None):
|
|
12
14
|
"""Returns available project for the end user."""
|
|
15
|
+
if env is None:
|
|
16
|
+
env = get_environment()
|
|
13
17
|
|
|
14
18
|
def project_handler(selected, project_context):
|
|
15
19
|
project_context.project_id = selected["id"]
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cells": [
|
|
3
|
-
{
|
|
4
|
-
"cell_type": "code",
|
|
5
|
-
"execution_count": null,
|
|
6
|
-
"id": "7eb47475-67c6-499a-a2b4-19f8a64974d0",
|
|
7
|
-
"metadata": {},
|
|
8
|
-
"outputs": [],
|
|
9
|
-
"source": [
|
|
10
|
-
"import obi_auth\n",
|
|
11
|
-
"\n",
|
|
12
|
-
"from obi_notebook import get_entities, get_projects\n",
|
|
13
|
-
"\n",
|
|
14
|
-
"environment_str = \"staging\""
|
|
15
|
-
]
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"cell_type": "markdown",
|
|
19
|
-
"id": "4d984b92-cadd-4b07-9813-b2333272610f",
|
|
20
|
-
"metadata": {},
|
|
21
|
-
"source": [
|
|
22
|
-
"get authentication token for production"
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"cell_type": "code",
|
|
27
|
-
"execution_count": null,
|
|
28
|
-
"id": "323cb45c-91e3-451f-8a80-374e61433d31",
|
|
29
|
-
"metadata": {},
|
|
30
|
-
"outputs": [],
|
|
31
|
-
"source": [
|
|
32
|
-
"token = obi_auth.get_token(environment=environment_str)"
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"cell_type": "markdown",
|
|
37
|
-
"id": "b60e8643-3ad5-4619-a052-5bd8b64713fd",
|
|
38
|
-
"metadata": {},
|
|
39
|
-
"source": [
|
|
40
|
-
"a widget to select project to use"
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"cell_type": "code",
|
|
45
|
-
"execution_count": null,
|
|
46
|
-
"id": "77c47560-1163-4466-83fc-43abc6e0801a",
|
|
47
|
-
"metadata": {},
|
|
48
|
-
"outputs": [],
|
|
49
|
-
"source": [
|
|
50
|
-
"project_context = get_projects.get_projects(token, env=\"staging\")"
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"cell_type": "code",
|
|
55
|
-
"execution_count": null,
|
|
56
|
-
"id": "d538dcac-1bdc-496b-8840-a7b32ea842ed",
|
|
57
|
-
"metadata": {},
|
|
58
|
-
"outputs": [],
|
|
59
|
-
"source": [
|
|
60
|
-
"project_context"
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"cell_type": "code",
|
|
65
|
-
"execution_count": null,
|
|
66
|
-
"id": "93029f77-d71f-40f4-8c4d-9f23d2b650bc",
|
|
67
|
-
"metadata": {},
|
|
68
|
-
"outputs": [],
|
|
69
|
-
"source": [
|
|
70
|
-
"circuit_ids = []\n",
|
|
71
|
-
"circuit_ids = get_entities.get_entities(\n",
|
|
72
|
-
" \"circuit\",\n",
|
|
73
|
-
" token,\n",
|
|
74
|
-
" circuit_ids,\n",
|
|
75
|
-
" return_entities=False,\n",
|
|
76
|
-
" multi_select=True,\n",
|
|
77
|
-
" show_pages=True,\n",
|
|
78
|
-
" project_context=project_context,\n",
|
|
79
|
-
" page_size=10,\n",
|
|
80
|
-
" default_scale=\"small\",\n",
|
|
81
|
-
" exclude_scales=[\"single\"],\n",
|
|
82
|
-
" add_columns=[\"subject.name\"],\n",
|
|
83
|
-
" env=environment_str,\n",
|
|
84
|
-
")"
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"cell_type": "code",
|
|
89
|
-
"execution_count": null,
|
|
90
|
-
"id": "da699ed4-39fd-4602-b54d-58a0b58c2539",
|
|
91
|
-
"metadata": {},
|
|
92
|
-
"outputs": [],
|
|
93
|
-
"source": [
|
|
94
|
-
"circuit_ids"
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"cell_type": "code",
|
|
99
|
-
"execution_count": null,
|
|
100
|
-
"id": "a5f5445d-a61a-4fbe-962f-51e701434771",
|
|
101
|
-
"metadata": {},
|
|
102
|
-
"outputs": [],
|
|
103
|
-
"source": [
|
|
104
|
-
"morph_ids = []\n",
|
|
105
|
-
"morph_ids = get_entities.get_entities(\n",
|
|
106
|
-
" \"reconstruction-morphology\",\n",
|
|
107
|
-
" token,\n",
|
|
108
|
-
" morph_ids,\n",
|
|
109
|
-
" return_entities=False,\n",
|
|
110
|
-
" multi_select=True,\n",
|
|
111
|
-
" show_pages=True,\n",
|
|
112
|
-
" project_context=project_context,\n",
|
|
113
|
-
" page_size=100,\n",
|
|
114
|
-
" add_columns=[\"mtypes\"],\n",
|
|
115
|
-
" env=environment_str,\n",
|
|
116
|
-
")"
|
|
117
|
-
]
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"cell_type": "code",
|
|
121
|
-
"execution_count": null,
|
|
122
|
-
"id": "2c9d28c4",
|
|
123
|
-
"metadata": {},
|
|
124
|
-
"outputs": [],
|
|
125
|
-
"source": [
|
|
126
|
-
"morph_ids"
|
|
127
|
-
]
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
"cell_type": "code",
|
|
131
|
-
"execution_count": null,
|
|
132
|
-
"id": "90757b52",
|
|
133
|
-
"metadata": {},
|
|
134
|
-
"outputs": [],
|
|
135
|
-
"source": [
|
|
136
|
-
"cell_mesh_ids = []\n",
|
|
137
|
-
"circuit_ids = get_entities.get_entities(\n",
|
|
138
|
-
" \"em-cell-mesh\",\n",
|
|
139
|
-
" token,\n",
|
|
140
|
-
" cell_mesh_ids,\n",
|
|
141
|
-
" return_entities=False,\n",
|
|
142
|
-
" multi_select=True,\n",
|
|
143
|
-
" show_pages=True,\n",
|
|
144
|
-
" project_context=project_context,\n",
|
|
145
|
-
" page_size=10,\n",
|
|
146
|
-
" env=environment_str,\n",
|
|
147
|
-
" add_columns=[\"dense_reconstruction_cell_id\", \"subject.name\"],\n",
|
|
148
|
-
")"
|
|
149
|
-
]
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"cell_type": "code",
|
|
153
|
-
"execution_count": null,
|
|
154
|
-
"id": "6964ebe2",
|
|
155
|
-
"metadata": {},
|
|
156
|
-
"outputs": [],
|
|
157
|
-
"source": [
|
|
158
|
-
"cell_mesh_ids"
|
|
159
|
-
]
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
"metadata": {
|
|
163
|
-
"kernelspec": {
|
|
164
|
-
"display_name": ".venv (3.13.1)",
|
|
165
|
-
"language": "python",
|
|
166
|
-
"name": "python3"
|
|
167
|
-
},
|
|
168
|
-
"language_info": {
|
|
169
|
-
"codemirror_mode": {
|
|
170
|
-
"name": "ipython",
|
|
171
|
-
"version": 3
|
|
172
|
-
},
|
|
173
|
-
"file_extension": ".py",
|
|
174
|
-
"mimetype": "text/x-python",
|
|
175
|
-
"name": "python",
|
|
176
|
-
"nbconvert_exporter": "python",
|
|
177
|
-
"pygments_lexer": "ipython3",
|
|
178
|
-
"version": "3.13.1"
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
"nbformat": 4,
|
|
182
|
-
"nbformat_minor": 5
|
|
183
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|