entitysdk 0.5.0__tar.gz → 0.5.1__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.
- {entitysdk-0.5.0/src/entitysdk.egg-info → entitysdk-0.5.1}/PKG-INFO +1 -1
- entitysdk-0.5.1/examples/02_morphology.ipynb +498 -0
- entitysdk-0.5.0/examples/05_simulation_campaign.ipynb → entitysdk-0.5.1/examples/04_simulation_campaign.ipynb +32 -21
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/downloaders/emodel.py +1 -1
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/__init__.py +9 -0
- entitysdk-0.5.1/src/entitysdk/models/classification.py +38 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/core.py +0 -4
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/memodel.py +45 -7
- entitysdk-0.5.1/src/entitysdk/models/single_neuron_simulation.py +50 -0
- entitysdk-0.5.1/src/entitysdk/models/single_neuron_synaptome_simulation.py +51 -0
- entitysdk-0.5.1/src/entitysdk/models/synaptome.py +63 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/route.py +5 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/types.py +8 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1/src/entitysdk.egg-info}/PKG-INFO +1 -1
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk.egg-info/SOURCES.txt +6 -3
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/integration/test_searching.py +6 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/downloaders/test_emodel.py +1 -1
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/downloaders/test_memodel.py +1 -1
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_client.py +9 -29
- entitysdk-0.5.0/examples/02_morphology.ipynb +0 -640
- entitysdk-0.5.0/examples/03_contribution.ipynb +0 -209
- {entitysdk-0.5.0 → entitysdk-0.5.1}/.github/workflows/sdist.yml +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/.github/workflows/tox.yml +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/.gitignore +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/CHANGELOG.rst +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/CONTRIBUTING.md +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/LICENSE.txt +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/README.md +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/examples/01_searching.ipynb +0 -0
- /entitysdk-0.5.0/examples/04_circuit.ipynb → /entitysdk-0.5.1/examples/03_circuit.ipynb +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/pyproject.toml +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/setup.cfg +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/__init__.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/client.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/common.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/config.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/core.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/downloaders/__init__.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/downloaders/ion_channel_model.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/downloaders/memodel.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/downloaders/morphology.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/exception.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/mixin.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/agent.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/asset.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/base.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/brain_location.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/brain_region.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/circuit.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/contribution.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/electrical_cell_recording.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/emodel.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/entity.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/etype.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/ion_channel_model.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/license.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/memodelcalibrationresult.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/morphology.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/mtype.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/response.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/scientific_artifact.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/simulation.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/simulation_campaign.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/subject.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/taxonomy.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/models/validation_result.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/result.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/schemas/__init__.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/schemas/asset.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/schemas/base.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/schemas/memodel.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/serdes.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/token_manager.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/util.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/utils/__init__.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/utils/asset.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk/utils/filesystem.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk.egg-info/dependency_links.txt +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk.egg-info/requires.txt +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/src/entitysdk.egg-info/top_level.txt +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/__init__.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/integration/__init__.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/integration/conftest.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/__init__.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/conftest.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/downloaders/test_ion_channel_model.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/downloaders/test_morphology.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/__init__.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/data/.gitignore +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/data/circuit.json +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/data/electrical_cell_recording.json +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/data/ion_channel_model.json +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/data/memodel_calibration_result.json +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/data/reconstruction_morphology.json +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/data/simulation_campaign.json +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/data/validation_result.json +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_agent.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_asset.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_brain_region.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_circuit.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_contribution.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_electrical_cell_recording.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_init.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_ion_channel_model.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_memodel_calibration_result.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_morphology.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_simulation_campaign.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/models/test_validation_result.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_base.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_common.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_config.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_result.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_route.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_serdes.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_token_manager.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/test_util.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/util.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/utils/test_asset.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tests/unit/utils/test_filesystem.py +0 -0
- {entitysdk-0.5.0 → entitysdk-0.5.1}/tox.ini +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: entitysdk
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.1
|
4
4
|
Summary: Python library for interacting with the entitycore service
|
5
5
|
Author-email: Open Brain Institute <info@openbraininstitute.org>
|
6
6
|
Maintainer-email: Open Brain Institute <info@openbraininstitute.org>
|
@@ -0,0 +1,498 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "47471adc-9c79-4262-9fc4-66f5579f14a8",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"import io\n",
|
11
|
+
"import os\n",
|
12
|
+
"import tempfile\n",
|
13
|
+
"from pathlib import Path\n",
|
14
|
+
"\n",
|
15
|
+
"from rich import print as rprint\n",
|
16
|
+
"\n",
|
17
|
+
"from entitysdk.client import Client\n",
|
18
|
+
"from entitysdk.common import ProjectContext\n",
|
19
|
+
"from entitysdk.models import (\n",
|
20
|
+
" BrainLocation,\n",
|
21
|
+
" BrainRegion,\n",
|
22
|
+
" Contribution,\n",
|
23
|
+
" MTypeClass,\n",
|
24
|
+
" MTypeClassification,\n",
|
25
|
+
" Organization,\n",
|
26
|
+
" ReconstructionMorphology,\n",
|
27
|
+
" Role,\n",
|
28
|
+
" Species,\n",
|
29
|
+
" Strain,\n",
|
30
|
+
")"
|
31
|
+
]
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"cell_type": "markdown",
|
35
|
+
"id": "cacdf95f-d545-417b-b1bd-c8a5181c162f",
|
36
|
+
"metadata": {},
|
37
|
+
"source": [
|
38
|
+
"### Initialize the entitycore client"
|
39
|
+
]
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"cell_type": "code",
|
43
|
+
"execution_count": null,
|
44
|
+
"id": "5e4f4ff2-3d5b-4f3a-90a9-ea43d587ebce",
|
45
|
+
"metadata": {},
|
46
|
+
"outputs": [],
|
47
|
+
"source": [
|
48
|
+
"entitycore_api_url = \"http://127.0.0.1:8000\"\n",
|
49
|
+
"project_context = ProjectContext(\n",
|
50
|
+
" virtual_lab_id=\"a98b7abc-fc46-4700-9e3d-37137812c730\",\n",
|
51
|
+
" project_id=\"0dbced5f-cc3d-488a-8c7f-cfb8ea039dc6\",\n",
|
52
|
+
")\n",
|
53
|
+
"token = os.getenv(\"ACCESS_TOKEN\", \"XXX\")\n",
|
54
|
+
"client = Client(api_url=entitycore_api_url, project_context=project_context, token_manager=token)\n",
|
55
|
+
"\n",
|
56
|
+
"\n",
|
57
|
+
"# uncomment for staging\n",
|
58
|
+
"# from obi_auth import get_token\n",
|
59
|
+
"# token = get_token(environment=\"staging\")\n",
|
60
|
+
"# Replace this with your vlab project url in staging\n",
|
61
|
+
"# project_context = ProjectContext.from_vlab_url(\"https://staging.openbraininstitute.org/app/virtual-lab/lab/594fd60d-7a38-436f-939d-500feaa13bba/project/ff89ca07-6613-4922-9ab0-2637221db8b5/home\")\n",
|
62
|
+
"# client = Client(environment=\"staging\", project_context=project_context)"
|
63
|
+
]
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"cell_type": "markdown",
|
67
|
+
"id": "15b1762d-11df-42be-bcff-5f42b03ab2cd",
|
68
|
+
"metadata": {},
|
69
|
+
"source": [
|
70
|
+
"## Search for entities"
|
71
|
+
]
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"cell_type": "code",
|
75
|
+
"execution_count": null,
|
76
|
+
"id": "93d30bc5-c40c-4a5d-ad9e-9b0c4abc3ef4",
|
77
|
+
"metadata": {},
|
78
|
+
"outputs": [],
|
79
|
+
"source": [
|
80
|
+
"species = client.search_entity(entity_type=Species, query={\"name\": \"Mus musculus\"}, limit=10).one()"
|
81
|
+
]
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"cell_type": "code",
|
85
|
+
"execution_count": null,
|
86
|
+
"id": "2a697b1d-2bdc-488d-8ce6-5f7547af87fe",
|
87
|
+
"metadata": {},
|
88
|
+
"outputs": [],
|
89
|
+
"source": [
|
90
|
+
"rprint(species)"
|
91
|
+
]
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"cell_type": "code",
|
95
|
+
"execution_count": null,
|
96
|
+
"id": "0ea7fd15-bf51-4039-a1fd-c580ce813ff3",
|
97
|
+
"metadata": {},
|
98
|
+
"outputs": [],
|
99
|
+
"source": [
|
100
|
+
"strain = client.search_entity(entity_type=Strain, query={\"name\": \"Cux2-CreERT2\"}).one()"
|
101
|
+
]
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"cell_type": "code",
|
105
|
+
"execution_count": null,
|
106
|
+
"id": "e5dde536-0c58-4d42-a834-1b1a0ec17e9d",
|
107
|
+
"metadata": {},
|
108
|
+
"outputs": [],
|
109
|
+
"source": [
|
110
|
+
"rprint(strain)"
|
111
|
+
]
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"cell_type": "code",
|
115
|
+
"execution_count": null,
|
116
|
+
"id": "5d42a174-9737-4477-830a-3dc908dea925",
|
117
|
+
"metadata": {},
|
118
|
+
"outputs": [],
|
119
|
+
"source": [
|
120
|
+
"brain_region = client.search_entity(entity_type=BrainRegion, query={\"annotation_value\": 68}).one()"
|
121
|
+
]
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"cell_type": "code",
|
125
|
+
"execution_count": null,
|
126
|
+
"id": "282200cd-ad0c-4bb3-bc21-88de85289179",
|
127
|
+
"metadata": {},
|
128
|
+
"outputs": [],
|
129
|
+
"source": [
|
130
|
+
"rprint(brain_region)"
|
131
|
+
]
|
132
|
+
},
|
133
|
+
{
|
134
|
+
"cell_type": "markdown",
|
135
|
+
"id": "a0193055-3448-4d1c-99cc-4d953727ef4e",
|
136
|
+
"metadata": {},
|
137
|
+
"source": [
|
138
|
+
"### Create a morphology object"
|
139
|
+
]
|
140
|
+
},
|
141
|
+
{
|
142
|
+
"cell_type": "code",
|
143
|
+
"execution_count": null,
|
144
|
+
"id": "fdc328df-2cef-4e23-b240-2de061f0e640",
|
145
|
+
"metadata": {},
|
146
|
+
"outputs": [],
|
147
|
+
"source": [
|
148
|
+
"brain_location = BrainLocation(\n",
|
149
|
+
" x=4101.52490234375,\n",
|
150
|
+
" y=1173.8499755859375,\n",
|
151
|
+
" z=4744.60009765625,\n",
|
152
|
+
")\n",
|
153
|
+
"morphology = ReconstructionMorphology(\n",
|
154
|
+
" name=\"my-morph\",\n",
|
155
|
+
" description=\"A morphology\",\n",
|
156
|
+
" species=species,\n",
|
157
|
+
" strain=strain,\n",
|
158
|
+
" brain_region=brain_region,\n",
|
159
|
+
" location=brain_location,\n",
|
160
|
+
" legacy_id=None,\n",
|
161
|
+
" authorized_public=True,\n",
|
162
|
+
")"
|
163
|
+
]
|
164
|
+
},
|
165
|
+
{
|
166
|
+
"cell_type": "code",
|
167
|
+
"execution_count": null,
|
168
|
+
"id": "2568abc1-8b72-4f35-85d3-19f6935ea232",
|
169
|
+
"metadata": {},
|
170
|
+
"outputs": [],
|
171
|
+
"source": [
|
172
|
+
"rprint(morphology)"
|
173
|
+
]
|
174
|
+
},
|
175
|
+
{
|
176
|
+
"cell_type": "markdown",
|
177
|
+
"id": "83fb7e5e-73b5-4227-aa22-90bb789b0907",
|
178
|
+
"metadata": {},
|
179
|
+
"source": [
|
180
|
+
"## Register morphology"
|
181
|
+
]
|
182
|
+
},
|
183
|
+
{
|
184
|
+
"cell_type": "code",
|
185
|
+
"execution_count": null,
|
186
|
+
"id": "2e32a168",
|
187
|
+
"metadata": {},
|
188
|
+
"outputs": [],
|
189
|
+
"source": [
|
190
|
+
"registered = client.register_entity(entity=morphology)"
|
191
|
+
]
|
192
|
+
},
|
193
|
+
{
|
194
|
+
"cell_type": "markdown",
|
195
|
+
"id": "5a4482d8-d5d4-45b9-80cb-264c1a531216",
|
196
|
+
"metadata": {},
|
197
|
+
"source": [
|
198
|
+
"## Add mtype to morphology"
|
199
|
+
]
|
200
|
+
},
|
201
|
+
{
|
202
|
+
"cell_type": "code",
|
203
|
+
"execution_count": null,
|
204
|
+
"id": "540aec85-ed13-4224-99ce-a0628f3fa745",
|
205
|
+
"metadata": {},
|
206
|
+
"outputs": [],
|
207
|
+
"source": [
|
208
|
+
"mtype = client.search_entity(entity_type=MTypeClass, query={\"pref_label\": \"L5_PC\"}).one()\n",
|
209
|
+
"\n",
|
210
|
+
"mtype_classification = MTypeClassification(\n",
|
211
|
+
" mtype_class_id=mtype.id, entity_id=registered.id, authorized_public=True\n",
|
212
|
+
")\n",
|
213
|
+
"\n",
|
214
|
+
"mtype_classification = client.register_entity(mtype_classification)"
|
215
|
+
]
|
216
|
+
},
|
217
|
+
{
|
218
|
+
"cell_type": "markdown",
|
219
|
+
"id": "9cd036c4-e722-42a9-bed9-b6985a663400",
|
220
|
+
"metadata": {},
|
221
|
+
"source": [
|
222
|
+
"## Add contribution to morphology"
|
223
|
+
]
|
224
|
+
},
|
225
|
+
{
|
226
|
+
"cell_type": "code",
|
227
|
+
"execution_count": null,
|
228
|
+
"id": "c74eedae-6674-4695-b20b-177c25c8a59c",
|
229
|
+
"metadata": {},
|
230
|
+
"outputs": [],
|
231
|
+
"source": [
|
232
|
+
"agent = client.search_entity(entity_type=Organization, limit=1).one()\n",
|
233
|
+
"role = client.search_entity(entity_type=Role, limit=1).one()\n",
|
234
|
+
"contribution = Contribution(\n",
|
235
|
+
" agent=agent,\n",
|
236
|
+
" role=role,\n",
|
237
|
+
" entity=registered,\n",
|
238
|
+
")\n",
|
239
|
+
"contribution = client.register_entity(contribution)"
|
240
|
+
]
|
241
|
+
},
|
242
|
+
{
|
243
|
+
"cell_type": "code",
|
244
|
+
"execution_count": null,
|
245
|
+
"id": "5eea0777-2256-4c00-b387-3d8b9171ef63",
|
246
|
+
"metadata": {},
|
247
|
+
"outputs": [],
|
248
|
+
"source": [
|
249
|
+
"rprint(contribution)"
|
250
|
+
]
|
251
|
+
},
|
252
|
+
{
|
253
|
+
"cell_type": "markdown",
|
254
|
+
"id": "c0d500bd",
|
255
|
+
"metadata": {},
|
256
|
+
"source": [
|
257
|
+
"## Upload assets"
|
258
|
+
]
|
259
|
+
},
|
260
|
+
{
|
261
|
+
"cell_type": "code",
|
262
|
+
"execution_count": null,
|
263
|
+
"id": "51d0c5b4-6251-4ee4-99ef-b6449a4d5da8",
|
264
|
+
"metadata": {},
|
265
|
+
"outputs": [],
|
266
|
+
"source": [
|
267
|
+
"with tempfile.TemporaryDirectory() as tdir:\n",
|
268
|
+
" file1 = Path(tdir, \"morph.h5\")\n",
|
269
|
+
" file1.write_text(\"h5\")\n",
|
270
|
+
"\n",
|
271
|
+
" file2 = Path(tdir, \"morph.swc\")\n",
|
272
|
+
" file2.write_text(\"swc\")\n",
|
273
|
+
"\n",
|
274
|
+
" # use a filepath to register first asset\n",
|
275
|
+
" asset1 = client.upload_file(\n",
|
276
|
+
" entity_id=registered.id,\n",
|
277
|
+
" entity_type=ReconstructionMorphology,\n",
|
278
|
+
" file_path=file1,\n",
|
279
|
+
" file_content_type=\"application/h5\",\n",
|
280
|
+
" )\n",
|
281
|
+
" rprint(asset1)\n",
|
282
|
+
"\n",
|
283
|
+
" # use an in-memory buffer to upload second asset\n",
|
284
|
+
" buffer = io.BytesIO(b\"morph bytes buffer\")\n",
|
285
|
+
"\n",
|
286
|
+
" asset2 = client.upload_content(\n",
|
287
|
+
" entity_id=registered.id,\n",
|
288
|
+
" entity_type=ReconstructionMorphology,\n",
|
289
|
+
" file_content=buffer,\n",
|
290
|
+
" file_name=\"buffer.h5\",\n",
|
291
|
+
" file_content_type=\"application/swc\",\n",
|
292
|
+
" )\n",
|
293
|
+
" rprint(asset2)"
|
294
|
+
]
|
295
|
+
},
|
296
|
+
{
|
297
|
+
"cell_type": "markdown",
|
298
|
+
"id": "1b5e396e-bf57-436d-9b06-ce198afc15ca",
|
299
|
+
"metadata": {},
|
300
|
+
"source": [
|
301
|
+
"## Retrieve it"
|
302
|
+
]
|
303
|
+
},
|
304
|
+
{
|
305
|
+
"cell_type": "code",
|
306
|
+
"execution_count": null,
|
307
|
+
"id": "3a0f9360-a805-4ccf-ad7c-95f7237d0819",
|
308
|
+
"metadata": {},
|
309
|
+
"outputs": [],
|
310
|
+
"source": [
|
311
|
+
"# with assets and mtypes\n",
|
312
|
+
"fetched = client.get_entity(entity_id=registered.id, entity_type=ReconstructionMorphology)"
|
313
|
+
]
|
314
|
+
},
|
315
|
+
{
|
316
|
+
"cell_type": "code",
|
317
|
+
"execution_count": null,
|
318
|
+
"id": "70271bac-cc92-49a1-9bdd-aa03bac92a73",
|
319
|
+
"metadata": {},
|
320
|
+
"outputs": [],
|
321
|
+
"source": [
|
322
|
+
"rprint(fetched)"
|
323
|
+
]
|
324
|
+
},
|
325
|
+
{
|
326
|
+
"cell_type": "markdown",
|
327
|
+
"id": "b00725dc-ba90-4ddf-b3ba-dea612cd7720",
|
328
|
+
"metadata": {},
|
329
|
+
"source": [
|
330
|
+
"## Download asset"
|
331
|
+
]
|
332
|
+
},
|
333
|
+
{
|
334
|
+
"cell_type": "code",
|
335
|
+
"execution_count": null,
|
336
|
+
"id": "c89e91f7-a9bb-4d09-b921-4659e338225c",
|
337
|
+
"metadata": {},
|
338
|
+
"outputs": [],
|
339
|
+
"source": [
|
340
|
+
"downloaded = client.download_assets(\n",
|
341
|
+
" fetched,\n",
|
342
|
+
" selection={\"content_type\": \"application/swc\"},\n",
|
343
|
+
" output_path=\"./my-file.h5\",\n",
|
344
|
+
").one()\n",
|
345
|
+
"\n",
|
346
|
+
"content = client.download_content(\n",
|
347
|
+
" entity_id=fetched.id, entity_type=type(fetched), asset_id=downloaded.asset.id\n",
|
348
|
+
")\n",
|
349
|
+
"\n",
|
350
|
+
"print(content)\n",
|
351
|
+
"print(Path(\"my-file.h5\").read_text())"
|
352
|
+
]
|
353
|
+
},
|
354
|
+
{
|
355
|
+
"cell_type": "markdown",
|
356
|
+
"id": "6879c149-3f59-4ee6-b878-92bdc6038de9",
|
357
|
+
"metadata": {},
|
358
|
+
"source": [
|
359
|
+
"## Delete asset"
|
360
|
+
]
|
361
|
+
},
|
362
|
+
{
|
363
|
+
"cell_type": "code",
|
364
|
+
"execution_count": null,
|
365
|
+
"id": "9a211674-54d2-498f-983a-ab3f3675087d",
|
366
|
+
"metadata": {},
|
367
|
+
"outputs": [],
|
368
|
+
"source": [
|
369
|
+
"for asset in fetched.assets:\n",
|
370
|
+
" if asset.content_type == \"application/swc\":\n",
|
371
|
+
" print(\"Deleting asset \", asset.id)\n",
|
372
|
+
" deleted_asset = client.delete_asset(\n",
|
373
|
+
" entity_id=fetched.id,\n",
|
374
|
+
" entity_type=type(registered),\n",
|
375
|
+
" asset_id=asset.id,\n",
|
376
|
+
" )\n",
|
377
|
+
" break\n",
|
378
|
+
"\n",
|
379
|
+
"rprint(deleted_asset)\n",
|
380
|
+
"\n",
|
381
|
+
"fetched = client.get_entity(entity_id=registered.id, entity_type=ReconstructionMorphology)\n",
|
382
|
+
"rprint(fetched.assets)"
|
383
|
+
]
|
384
|
+
},
|
385
|
+
{
|
386
|
+
"cell_type": "markdown",
|
387
|
+
"id": "34b39d9d-2b08-4933-b3cb-3f9a9c08004b",
|
388
|
+
"metadata": {},
|
389
|
+
"source": [
|
390
|
+
"## Update asset"
|
391
|
+
]
|
392
|
+
},
|
393
|
+
{
|
394
|
+
"cell_type": "code",
|
395
|
+
"execution_count": null,
|
396
|
+
"id": "69d44c3c-b07c-46d2-978f-98b1b80b5212",
|
397
|
+
"metadata": {},
|
398
|
+
"outputs": [],
|
399
|
+
"source": [
|
400
|
+
"# update h5 asset with another file\n",
|
401
|
+
"with tempfile.TemporaryDirectory() as tdir:\n",
|
402
|
+
" file1 = Path(tdir, \"updated.h5\")\n",
|
403
|
+
" file1.write_text(\"updated h5\")\n",
|
404
|
+
" file1.touch()\n",
|
405
|
+
"\n",
|
406
|
+
" for asset in fetched.assets:\n",
|
407
|
+
" if asset.content_type == \"application/h5\":\n",
|
408
|
+
" updated_asset = client.update_asset_file(\n",
|
409
|
+
" entity_id=fetched.id,\n",
|
410
|
+
" entity_type=type(registered),\n",
|
411
|
+
" asset_id=asset.id,\n",
|
412
|
+
" file_name=asset1.path,\n",
|
413
|
+
" file_path=file1,\n",
|
414
|
+
" file_content_type=asset.content_type,\n",
|
415
|
+
" )\n",
|
416
|
+
" break\n",
|
417
|
+
"\n",
|
418
|
+
"\n",
|
419
|
+
"# synchronize morphology with new server data\n",
|
420
|
+
"fetched = client.get_entity(\n",
|
421
|
+
" entity_id=registered.id, entity_type=ReconstructionMorphology, token=token\n",
|
422
|
+
")\n",
|
423
|
+
"rprint(fetched.assets)\n",
|
424
|
+
"\n",
|
425
|
+
"\n",
|
426
|
+
"# download updated file and check it was successfully updated\n",
|
427
|
+
"for asset in fetched.assets:\n",
|
428
|
+
" if asset.content_type == \"application/h5\":\n",
|
429
|
+
" client.download_file(\n",
|
430
|
+
" entity_id=fetched.id,\n",
|
431
|
+
" entity_type=type(fetched),\n",
|
432
|
+
" asset_id=updated_asset.id,\n",
|
433
|
+
" output_path=\"./my-file.h5\",\n",
|
434
|
+
" )\n",
|
435
|
+
" content = client.download_content(\n",
|
436
|
+
" entity_id=fetched.id, entity_type=type(fetched), asset_id=asset.id\n",
|
437
|
+
" )\n",
|
438
|
+
" break\n",
|
439
|
+
"print(content)"
|
440
|
+
]
|
441
|
+
},
|
442
|
+
{
|
443
|
+
"cell_type": "markdown",
|
444
|
+
"id": "f15c808c-c454-4277-9ec4-587922ac74f3",
|
445
|
+
"metadata": {},
|
446
|
+
"source": [
|
447
|
+
"## Search it"
|
448
|
+
]
|
449
|
+
},
|
450
|
+
{
|
451
|
+
"cell_type": "code",
|
452
|
+
"execution_count": null,
|
453
|
+
"id": "956cc4d7-9ca8-4bb4-9911-648b4ca18a49",
|
454
|
+
"metadata": {},
|
455
|
+
"outputs": [],
|
456
|
+
"source": [
|
457
|
+
"hits = client.search_entity(\n",
|
458
|
+
" entity_type=ReconstructionMorphology,\n",
|
459
|
+
" query={\"name__ilike\": \"my-morph\", \"page\": 1, \"page_size\": 2},\n",
|
460
|
+
" limit=None,\n",
|
461
|
+
").all()\n",
|
462
|
+
"\n",
|
463
|
+
"print(\"Number of results: \", len(hits))"
|
464
|
+
]
|
465
|
+
},
|
466
|
+
{
|
467
|
+
"cell_type": "code",
|
468
|
+
"execution_count": null,
|
469
|
+
"id": "4091c7a8-75b9-49d0-8c98-378b7fb5df6d",
|
470
|
+
"metadata": {},
|
471
|
+
"outputs": [],
|
472
|
+
"source": [
|
473
|
+
"rprint(hits[0])"
|
474
|
+
]
|
475
|
+
}
|
476
|
+
],
|
477
|
+
"metadata": {
|
478
|
+
"kernelspec": {
|
479
|
+
"display_name": "Python 3 (ipykernel)",
|
480
|
+
"language": "python",
|
481
|
+
"name": "python3"
|
482
|
+
},
|
483
|
+
"language_info": {
|
484
|
+
"codemirror_mode": {
|
485
|
+
"name": "ipython",
|
486
|
+
"version": 3
|
487
|
+
},
|
488
|
+
"file_extension": ".py",
|
489
|
+
"mimetype": "text/x-python",
|
490
|
+
"name": "python",
|
491
|
+
"nbconvert_exporter": "python",
|
492
|
+
"pygments_lexer": "ipython3",
|
493
|
+
"version": "3.12.10"
|
494
|
+
}
|
495
|
+
},
|
496
|
+
"nbformat": 4,
|
497
|
+
"nbformat_minor": 5
|
498
|
+
}
|
@@ -22,27 +22,6 @@
|
|
22
22
|
"client = Client(api_url=entitycore_api_url, project_context=project_context, token_manager=token)"
|
23
23
|
]
|
24
24
|
},
|
25
|
-
{
|
26
|
-
"cell_type": "markdown",
|
27
|
-
"id": "eb0132f6-88e4-4700-a2b7-799bb0ee77e6",
|
28
|
-
"metadata": {},
|
29
|
-
"source": [
|
30
|
-
"## Register a SimulationCampaign"
|
31
|
-
]
|
32
|
-
},
|
33
|
-
{
|
34
|
-
"cell_type": "code",
|
35
|
-
"execution_count": null,
|
36
|
-
"id": "ed03bf00-51da-43eb-b887-8d0502c404c6",
|
37
|
-
"metadata": {},
|
38
|
-
"outputs": [],
|
39
|
-
"source": [
|
40
|
-
"campaign = models.SimulationCampaign(\n",
|
41
|
-
" name=\"my-campaign\", description=\"my-campaign-description\", scan_parameters={\"foo\": \"bar\"}\n",
|
42
|
-
")\n",
|
43
|
-
"campaign = client.register_entity(campaign)"
|
44
|
-
]
|
45
|
-
},
|
46
25
|
{
|
47
26
|
"cell_type": "markdown",
|
48
27
|
"id": "490dd2a8-e9a1-442e-abe2-cfda8b3c0c8f",
|
@@ -85,6 +64,30 @@
|
|
85
64
|
"circuit = client.register_entity(circuit)"
|
86
65
|
]
|
87
66
|
},
|
67
|
+
{
|
68
|
+
"cell_type": "markdown",
|
69
|
+
"id": "47679bbe-5550-4332-b5a6-0b0a916a0acc",
|
70
|
+
"metadata": {},
|
71
|
+
"source": [
|
72
|
+
"## Register a SimulationCampaign"
|
73
|
+
]
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"cell_type": "code",
|
77
|
+
"execution_count": null,
|
78
|
+
"id": "520976c2-4575-4455-9d64-ed666f661550",
|
79
|
+
"metadata": {},
|
80
|
+
"outputs": [],
|
81
|
+
"source": [
|
82
|
+
"campaign = models.SimulationCampaign(\n",
|
83
|
+
" name=\"my-campaign\",\n",
|
84
|
+
" description=\"my-campaign-description\",\n",
|
85
|
+
" scan_parameters={\"foo\": \"bar\"},\n",
|
86
|
+
" entity_id=circuit.id,\n",
|
87
|
+
")\n",
|
88
|
+
"campaign = client.register_entity(campaign)"
|
89
|
+
]
|
90
|
+
},
|
88
91
|
{
|
89
92
|
"cell_type": "markdown",
|
90
93
|
"id": "d5c5fd58-3c00-4452-90ac-54ca0269e165",
|
@@ -138,6 +141,14 @@
|
|
138
141
|
"source": [
|
139
142
|
"rprint(campaign.simulations)"
|
140
143
|
]
|
144
|
+
},
|
145
|
+
{
|
146
|
+
"cell_type": "code",
|
147
|
+
"execution_count": null,
|
148
|
+
"id": "b3260f79-5852-4e61-923f-4325e030fc71",
|
149
|
+
"metadata": {},
|
150
|
+
"outputs": [],
|
151
|
+
"source": []
|
141
152
|
}
|
142
153
|
],
|
143
154
|
"metadata": {
|
@@ -5,6 +5,7 @@ from entitysdk.models.asset import Asset
|
|
5
5
|
from entitysdk.models.brain_location import BrainLocation
|
6
6
|
from entitysdk.models.brain_region import BrainRegion
|
7
7
|
from entitysdk.models.circuit import Circuit
|
8
|
+
from entitysdk.models.classification import ETypeClassification, MTypeClassification
|
8
9
|
from entitysdk.models.contribution import Contribution, Role
|
9
10
|
from entitysdk.models.electrical_cell_recording import ElectricalCellRecording
|
10
11
|
from entitysdk.models.emodel import EModel
|
@@ -16,7 +17,10 @@ from entitysdk.models.morphology import ReconstructionMorphology
|
|
16
17
|
from entitysdk.models.mtype import MTypeClass
|
17
18
|
from entitysdk.models.simulation import Simulation
|
18
19
|
from entitysdk.models.simulation_campaign import SimulationCampaign
|
20
|
+
from entitysdk.models.single_neuron_simulation import SingleNeuronSimulation
|
21
|
+
from entitysdk.models.single_neuron_synaptome_simulation import SingleNeuronSynaptomeSimulation
|
19
22
|
from entitysdk.models.subject import Subject
|
23
|
+
from entitysdk.models.synaptome import SingleNeuronSynaptome
|
20
24
|
from entitysdk.models.taxonomy import Species, Strain, Taxonomy
|
21
25
|
from entitysdk.models.validation_result import ValidationResult
|
22
26
|
|
@@ -28,11 +32,13 @@ __all__ = [
|
|
28
32
|
"Contribution",
|
29
33
|
"ElectricalCellRecording",
|
30
34
|
"EModel",
|
35
|
+
"ETypeClassification",
|
31
36
|
"IonChannelModel",
|
32
37
|
"License",
|
33
38
|
"MEModel",
|
34
39
|
"MEModelCalibrationResult",
|
35
40
|
"MTypeClass",
|
41
|
+
"MTypeClassification",
|
36
42
|
"NeuronBlock",
|
37
43
|
"Organization",
|
38
44
|
"Person",
|
@@ -40,6 +46,9 @@ __all__ = [
|
|
40
46
|
"Role",
|
41
47
|
"Simulation",
|
42
48
|
"SimulationCampaign",
|
49
|
+
"SingleNeuronSimulation",
|
50
|
+
"SingleNeuronSynaptome",
|
51
|
+
"SingleNeuronSynaptomeSimulation",
|
43
52
|
"Species",
|
44
53
|
"Strain",
|
45
54
|
"Subject",
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"""Classification models."""
|
2
|
+
|
3
|
+
from typing import Annotated
|
4
|
+
|
5
|
+
from pydantic import Field
|
6
|
+
|
7
|
+
from entitysdk.models.core import Identifiable
|
8
|
+
from entitysdk.types import ID
|
9
|
+
|
10
|
+
|
11
|
+
class Classification(Identifiable):
|
12
|
+
"""Classification base model."""
|
13
|
+
|
14
|
+
entity_id: ID
|
15
|
+
authorized_public: Annotated[
|
16
|
+
bool,
|
17
|
+
Field(
|
18
|
+
description="Whether the resource is authorized to be public.",
|
19
|
+
),
|
20
|
+
] = False
|
21
|
+
authorized_project_id: Annotated[
|
22
|
+
ID | None,
|
23
|
+
Field(
|
24
|
+
description="The project ID the resource is authorized to be public.",
|
25
|
+
),
|
26
|
+
] = None
|
27
|
+
|
28
|
+
|
29
|
+
class MTypeClassification(Classification):
|
30
|
+
"""Mtype classification model."""
|
31
|
+
|
32
|
+
mtype_class_id: ID
|
33
|
+
|
34
|
+
|
35
|
+
class ETypeClassification(Classification):
|
36
|
+
"""Etype classification model."""
|
37
|
+
|
38
|
+
etype_class_id: ID
|