entitysdk 0.0.1__tar.gz → 0.1.0__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.
Files changed (72) hide show
  1. {entitysdk-0.0.1 → entitysdk-0.1.0}/.gitignore +4 -1
  2. entitysdk-0.1.0/CHANGELOG.rst +5 -0
  3. entitysdk-0.1.0/CONTRIBUTING.md +105 -0
  4. entitysdk-0.1.0/PKG-INFO +143 -0
  5. entitysdk-0.1.0/README.md +122 -0
  6. entitysdk-0.1.0/examples/contribution.ipynb +201 -0
  7. entitysdk-0.1.0/examples/morphology.ipynb +436 -0
  8. entitysdk-0.1.0/examples/searching.ipynb +289 -0
  9. {entitysdk-0.0.1 → entitysdk-0.1.0}/pyproject.toml +5 -7
  10. entitysdk-0.1.0/src/entitysdk/client.py +419 -0
  11. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/config.py +4 -4
  12. entitysdk-0.1.0/src/entitysdk/core.py +273 -0
  13. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/exception.py +4 -0
  14. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/models/asset.py +7 -1
  15. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/models/base.py +1 -1
  16. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/models/contribution.py +7 -2
  17. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/models/core.py +2 -22
  18. entitysdk-0.1.0/src/entitysdk/models/entity.py +38 -0
  19. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/models/morphology.py +22 -16
  20. entitysdk-0.1.0/src/entitysdk/models/mtype.py +28 -0
  21. entitysdk-0.1.0/src/entitysdk/models/response.py +20 -0
  22. entitysdk-0.1.0/src/entitysdk/result.py +47 -0
  23. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/route.py +7 -3
  24. entitysdk-0.1.0/src/entitysdk/token_manager.py +30 -0
  25. entitysdk-0.1.0/src/entitysdk/typedef.py +5 -0
  26. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/util.py +46 -29
  27. entitysdk-0.1.0/src/entitysdk.egg-info/PKG-INFO +143 -0
  28. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk.egg-info/SOURCES.txt +17 -0
  29. entitysdk-0.1.0/tests/integration/conftest.py +33 -0
  30. entitysdk-0.1.0/tests/integration/test_searching.py +29 -0
  31. entitysdk-0.1.0/tests/unit/conftest.py +50 -0
  32. entitysdk-0.1.0/tests/unit/models/__init__.py +0 -0
  33. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/models/test_asset.py +7 -4
  34. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/models/test_morphology.py +31 -32
  35. entitysdk-0.1.0/tests/unit/test_client.py +375 -0
  36. entitysdk-0.1.0/tests/unit/test_config.py +13 -0
  37. entitysdk-0.1.0/tests/unit/test_result.py +40 -0
  38. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/test_route.py +1 -1
  39. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/test_serdes.py +6 -4
  40. entitysdk-0.1.0/tests/unit/test_token_manager.py +20 -0
  41. entitysdk-0.1.0/tests/unit/test_util.py +432 -0
  42. entitysdk-0.1.0/tests/unit/util.py +3 -0
  43. {entitysdk-0.0.1 → entitysdk-0.1.0}/tox.ini +25 -1
  44. entitysdk-0.0.1/CHANGELOG.rst +0 -21
  45. entitysdk-0.0.1/PKG-INFO +0 -22
  46. entitysdk-0.0.1/README.md +0 -2
  47. entitysdk-0.0.1/examples/morphology.ipynb +0 -241
  48. entitysdk-0.0.1/src/entitysdk/client.py +0 -535
  49. entitysdk-0.0.1/src/entitysdk.egg-info/PKG-INFO +0 -22
  50. entitysdk-0.0.1/tests/unit/conftest.py +0 -24
  51. entitysdk-0.0.1/tests/unit/test_client.py +0 -184
  52. entitysdk-0.0.1/tests/unit/test_util.py +0 -172
  53. {entitysdk-0.0.1 → entitysdk-0.1.0}/.github/workflows/sdist.yml +0 -0
  54. {entitysdk-0.0.1 → entitysdk-0.1.0}/.github/workflows/tox.yml +0 -0
  55. {entitysdk-0.0.1 → entitysdk-0.1.0}/LICENSE.txt +0 -0
  56. {entitysdk-0.0.1 → entitysdk-0.1.0}/setup.cfg +0 -0
  57. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/__init__.py +0 -0
  58. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/common.py +0 -0
  59. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/mixin.py +0 -0
  60. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/models/__init__.py +0 -0
  61. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/models/agent.py +0 -0
  62. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk/serdes.py +0 -0
  63. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk.egg-info/dependency_links.txt +0 -0
  64. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk.egg-info/requires.txt +0 -0
  65. {entitysdk-0.0.1 → entitysdk-0.1.0}/src/entitysdk.egg-info/top_level.txt +0 -0
  66. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/__init__.py +0 -0
  67. {entitysdk-0.0.1/tests/unit/models → entitysdk-0.1.0/tests/integration}/__init__.py +0 -0
  68. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/__init__.py +0 -0
  69. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/data/.gitignore +0 -0
  70. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/models/test_agent.py +0 -0
  71. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/models/test_contribution.py +0 -0
  72. {entitysdk-0.0.1 → entitysdk-0.1.0}/tests/unit/test_base.py +0 -0
@@ -165,7 +165,10 @@ cython_debug/
165
165
  # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
166
  # and can be added to the global gitignore or merged into this file. For a more nuclear
167
167
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
- #.idea/
168
+ .idea/
169
169
 
170
170
  # PyPI configuration file
171
171
  .pypirc
172
+
173
+ examples/*.md
174
+ examples/*.h5
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## Version 0.0.1
4
+
5
+ - Initial preliminary version.
@@ -0,0 +1,105 @@
1
+ # Contribution Guide
2
+
3
+ We would love for you to contribute to the project and help make it better than it is today.
4
+ As a contributor, here are the guidelines we would like you to follow:
5
+
6
+ - [Question or Problem?](#got-a-question)
7
+ - [Issues and Bugs](#found-a-bug)
8
+ - [Feature Requests](#missing-a-feature)
9
+ - [Submissions](#submission-guidelines)
10
+
11
+ # Got a Question?
12
+
13
+ Please do not hesitate to raise an issue on [github project page][github].
14
+
15
+ # Found a Bug?
16
+
17
+ If you find a bug in the source code, you can help us by [submitting an issue](#issues)
18
+ to our [GitHub Repository][github]. Even better, you can [submit a Pull Request](#pull-requests) with a fix.
19
+
20
+ # Missing a Feature?
21
+
22
+ You can *request* a new feature by [submitting an issue](#issues) to our GitHub Repository.
23
+ If you would like to *implement* a new feature, please submit an issue with a proposal for your
24
+ work first, to be sure that we can use it.
25
+
26
+ Please consider what kind of change it is:
27
+
28
+ * For a **Major Feature**, first open an issue and outline your proposal so that it can be
29
+ discussed. This will also allow us to better coordinate our efforts, prevent duplication of work,
30
+ and help you to craft the change so that it is successfully accepted into the project.
31
+ * **Small Features** can be crafted and directly [submitted as a Pull Request](#pull-requests).
32
+
33
+ # Submission Guidelines
34
+
35
+ ## Issues
36
+
37
+ Before you submit an issue, please search the issue tracker, maybe an issue for your problem
38
+ already exists and the discussion might inform you of workarounds readily available.
39
+
40
+ We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce
41
+ and confirm it. In order to reproduce bugs we will need as much information as possible, and
42
+ preferably with an example.
43
+
44
+ ## Pull Requests
45
+
46
+ When you wish to contribute to the code base, please consider the following guidelines:
47
+
48
+ * Make a [fork](https://guides.github.com/activities/forking/) of this repository.
49
+ * Make your changes in your fork, in a new git branch:
50
+
51
+ ```shell
52
+ git checkout -b my-fix-branch main
53
+ ```
54
+ * Create your patch, **including appropriate Python test cases**.
55
+ * Run the full test suite, and ensure that all tests pass.
56
+ * Commit your changes using a descriptive commit message.
57
+
58
+ ```shell
59
+ git commit -a
60
+ ```
61
+ * Push your branch to GitHub:
62
+
63
+ ```shell
64
+ git push origin my-fix-branch
65
+ ```
66
+ * In GitHub, send a Pull Request to the `main` branch of the upstream repository of the relevant component.
67
+ * If we suggest changes then:
68
+ * Make the required updates.
69
+ * Re-run the test suites to ensure tests are still passing.
70
+ * Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
71
+
72
+ ```shell
73
+ git rebase main -i
74
+ git push -f
75
+ ```
76
+
77
+ That’s it! Thank you for your contribution!
78
+
79
+ ### After your pull request is merged
80
+
81
+ After your pull request is merged, you can safely delete your branch and pull the changes from
82
+ the main (upstream) repository:
83
+
84
+ * Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
85
+
86
+ ```shell
87
+ git push origin --delete my-fix-branch
88
+ ```
89
+ * Check out the main branch:
90
+
91
+ ```shell
92
+ git checkout main -f
93
+ ```
94
+ * Delete the local branch:
95
+
96
+ ```shell
97
+ git branch -D my-fix-branch
98
+ ```
99
+ * Update your main with the latest upstream version:
100
+
101
+ ```shell
102
+ git pull --ff upstream main
103
+ ```
104
+
105
+ [github]: https://github.com/openbraininstitute/entitysdk
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: entitysdk
3
+ Version: 0.1.0
4
+ Summary: Python library for interacting with the entitycore service
5
+ Author-email: Open Brain Institute <info@openbraininstitute.org>
6
+ Maintainer-email: Open Brain Institute <info@openbraininstitute.org>
7
+ License: Apache-2.0
8
+ Project-URL: documentation, https://entitysdk.readthedocs.io/en/stable
9
+ Project-URL: repository, https://github.com/openbraininstitute/entitysdk
10
+ Project-URL: changelog, https://github.com/openbraininstitute/entitysdk/CHANGELOG.md
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE.txt
17
+ Requires-Dist: httpx
18
+ Requires-Dist: pydantic
19
+ Requires-Dist: pydantic-settings
20
+ Dynamic: license-file
21
+
22
+ [![Build status][build_status_badge]][build_status_target]
23
+ [![License][license_badge]][license_target]
24
+ [![Code coverage][coverage_badge]][coverage_target]
25
+ [![CodeQL][codeql_badge]][codeql_target]
26
+ [![PyPI][pypi_badge]][pypi_target]
27
+
28
+ # entitysdk
29
+
30
+ entitysdk is a Python library for interacting with the [entitycore service][entitycore], providing a type-safe and intuitive interface for managing scientific entities, and their associated assets.
31
+
32
+ ## Requirements
33
+
34
+ - Python 3.11 or higher
35
+ - Network access to entitycore service endpoints
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install entitysdk
41
+ ```
42
+ ## Quick Start
43
+
44
+ ```python
45
+ from uuid import UUID
46
+ from entitysdk.client import Client
47
+ from entitysdk.common import ProjectContext
48
+ from entitysdk.models.morphology import ReconstructionMorphology
49
+
50
+ # Initialize client
51
+ client = Client(
52
+ api_url="http://api.example.com",
53
+ project_context=ProjectContext(
54
+ project_id=UUID("your-project-id"),
55
+ virtual_lab_id=UUID("your-lab-id")
56
+ )
57
+ )
58
+
59
+ # Search for morphologies
60
+ iterator = client.search(
61
+ entity_type=ReconstructionMorphology,
62
+ query={"mtype__pref_label": "L5_TPC:A"},
63
+ token=token,
64
+ limit=1,
65
+ )
66
+ morphology = next(iterator)
67
+
68
+ # Upload an asset
69
+ client.upload_file(
70
+ entity_id=morphology.id,
71
+ entity_type=ReconstructionMorphology,
72
+ file_path="path/to/file.swc",
73
+ file_content_type="application/swc",
74
+ token="your-token"
75
+ )
76
+ ```
77
+
78
+ ### Authentication
79
+ - Valid Keycloak access token
80
+ - Project context with:
81
+ - Valid project ID (UUID)
82
+ - Valid virtual lab ID (UUID)
83
+
84
+ Example configuration:
85
+ ```python
86
+ from uuid import UUID
87
+ from entitysdk.common import ProjectContext
88
+
89
+ project_context = ProjectContext(
90
+ project_id=UUID("12345678-1234-1234-1234-123456789012"),
91
+ virtual_lab_id=UUID("87654321-4321-4321-4321-210987654321")
92
+ )
93
+ ```
94
+
95
+ ## Development
96
+
97
+ ### Requirements
98
+ - tox/tox-uv
99
+
100
+ ### Clone and run tests
101
+
102
+ ```bash
103
+ # Clone the repository
104
+ git clone https://github.com/your-org/entitysdk.git
105
+
106
+ # Run linting, tests, and check-packaging
107
+ tox
108
+ ```
109
+
110
+ ## Contributing
111
+
112
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
113
+
114
+ ## License
115
+
116
+ Copyright (c) 2025 Open Brain Institute
117
+
118
+ Licensed under the Apache License, Version 2.0 (the "License");
119
+ you may not use this file except in compliance with the License.
120
+ You may obtain a copy of the License at
121
+
122
+ http://www.apache.org/licenses/LICENSE-2.0
123
+
124
+ Unless required by applicable law or agreed to in writing, software
125
+ distributed under the License is distributed on an "AS IS" BASIS,
126
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127
+ See the License for the specific language governing permissions and
128
+ limitations under the License.
129
+
130
+
131
+ [entitycore]: https://github.com/openbraininstitute/entitycore
132
+
133
+ [build_status_badge]: https://github.com/openbraininstitute/entitysdk/actions/workflows/tox.yml/badge.svg
134
+ [build_status_target]: https://github.com/openbraininstitute/entitysdk/actions
135
+ [license_badge]: https://img.shields.io/pypi/l/entitysdk
136
+ [license_target]: https://github.com/openbraininstitute/entitysdk/blob/main/LICENSE.txt
137
+ [coverage_badge]: https://codecov.io/github/openbraininstitute/entitysdk/coverage.svg?branch=main
138
+ [coverage_target]: https://codecov.io/github/openbraininstitute/entitysdk?branch=main
139
+ [codeql_badge]: https://github.com/openbraininstitute/entitysdk/actions/workflows/github-code-scanning/codeql/badge.svg
140
+ [codeql_target]: https://github.com/openbraininstitute/entitysdk/actions/workflows/github-code-scanning/codeql
141
+ [pypi_badge]: https://github.com/openbraininstitute/entitysdk/actions/workflows/sdist.yml/badge.svg
142
+ [pypi_target]: https://pypi.org/project/entitysdk/
143
+
@@ -0,0 +1,122 @@
1
+ [![Build status][build_status_badge]][build_status_target]
2
+ [![License][license_badge]][license_target]
3
+ [![Code coverage][coverage_badge]][coverage_target]
4
+ [![CodeQL][codeql_badge]][codeql_target]
5
+ [![PyPI][pypi_badge]][pypi_target]
6
+
7
+ # entitysdk
8
+
9
+ entitysdk is a Python library for interacting with the [entitycore service][entitycore], providing a type-safe and intuitive interface for managing scientific entities, and their associated assets.
10
+
11
+ ## Requirements
12
+
13
+ - Python 3.11 or higher
14
+ - Network access to entitycore service endpoints
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install entitysdk
20
+ ```
21
+ ## Quick Start
22
+
23
+ ```python
24
+ from uuid import UUID
25
+ from entitysdk.client import Client
26
+ from entitysdk.common import ProjectContext
27
+ from entitysdk.models.morphology import ReconstructionMorphology
28
+
29
+ # Initialize client
30
+ client = Client(
31
+ api_url="http://api.example.com",
32
+ project_context=ProjectContext(
33
+ project_id=UUID("your-project-id"),
34
+ virtual_lab_id=UUID("your-lab-id")
35
+ )
36
+ )
37
+
38
+ # Search for morphologies
39
+ iterator = client.search(
40
+ entity_type=ReconstructionMorphology,
41
+ query={"mtype__pref_label": "L5_TPC:A"},
42
+ token=token,
43
+ limit=1,
44
+ )
45
+ morphology = next(iterator)
46
+
47
+ # Upload an asset
48
+ client.upload_file(
49
+ entity_id=morphology.id,
50
+ entity_type=ReconstructionMorphology,
51
+ file_path="path/to/file.swc",
52
+ file_content_type="application/swc",
53
+ token="your-token"
54
+ )
55
+ ```
56
+
57
+ ### Authentication
58
+ - Valid Keycloak access token
59
+ - Project context with:
60
+ - Valid project ID (UUID)
61
+ - Valid virtual lab ID (UUID)
62
+
63
+ Example configuration:
64
+ ```python
65
+ from uuid import UUID
66
+ from entitysdk.common import ProjectContext
67
+
68
+ project_context = ProjectContext(
69
+ project_id=UUID("12345678-1234-1234-1234-123456789012"),
70
+ virtual_lab_id=UUID("87654321-4321-4321-4321-210987654321")
71
+ )
72
+ ```
73
+
74
+ ## Development
75
+
76
+ ### Requirements
77
+ - tox/tox-uv
78
+
79
+ ### Clone and run tests
80
+
81
+ ```bash
82
+ # Clone the repository
83
+ git clone https://github.com/your-org/entitysdk.git
84
+
85
+ # Run linting, tests, and check-packaging
86
+ tox
87
+ ```
88
+
89
+ ## Contributing
90
+
91
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
92
+
93
+ ## License
94
+
95
+ Copyright (c) 2025 Open Brain Institute
96
+
97
+ Licensed under the Apache License, Version 2.0 (the "License");
98
+ you may not use this file except in compliance with the License.
99
+ You may obtain a copy of the License at
100
+
101
+ http://www.apache.org/licenses/LICENSE-2.0
102
+
103
+ Unless required by applicable law or agreed to in writing, software
104
+ distributed under the License is distributed on an "AS IS" BASIS,
105
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
106
+ See the License for the specific language governing permissions and
107
+ limitations under the License.
108
+
109
+
110
+ [entitycore]: https://github.com/openbraininstitute/entitycore
111
+
112
+ [build_status_badge]: https://github.com/openbraininstitute/entitysdk/actions/workflows/tox.yml/badge.svg
113
+ [build_status_target]: https://github.com/openbraininstitute/entitysdk/actions
114
+ [license_badge]: https://img.shields.io/pypi/l/entitysdk
115
+ [license_target]: https://github.com/openbraininstitute/entitysdk/blob/main/LICENSE.txt
116
+ [coverage_badge]: https://codecov.io/github/openbraininstitute/entitysdk/coverage.svg?branch=main
117
+ [coverage_target]: https://codecov.io/github/openbraininstitute/entitysdk?branch=main
118
+ [codeql_badge]: https://github.com/openbraininstitute/entitysdk/actions/workflows/github-code-scanning/codeql/badge.svg
119
+ [codeql_target]: https://github.com/openbraininstitute/entitysdk/actions/workflows/github-code-scanning/codeql
120
+ [pypi_badge]: https://github.com/openbraininstitute/entitysdk/actions/workflows/sdist.yml/badge.svg
121
+ [pypi_target]: https://pypi.org/project/entitysdk/
122
+
@@ -0,0 +1,201 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "143211ec-83e7-46c2-84bd-ce61f77ba1d0",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import os\n",
11
+ "\n",
12
+ "from rich import print as rprint\n",
13
+ "\n",
14
+ "from entitysdk.client import Client\n",
15
+ "from entitysdk.common import ProjectContext\n",
16
+ "from entitysdk.models.agent import Organization\n",
17
+ "from entitysdk.models.contribution import Contribution, Role\n",
18
+ "from entitysdk.models.morphology import ReconstructionMorphology\n",
19
+ "\n",
20
+ "entitycore_api_url = \"http://127.0.0.1:8000\"\n",
21
+ "project_context = ProjectContext(\n",
22
+ " virtual_lab_id=\"a98b7abc-fc46-4700-9e3d-37137812c730\",\n",
23
+ " project_id=\"0dbced5f-cc3d-488a-8c7f-cfb8ea039dc6\",\n",
24
+ ")\n",
25
+ "client = Client(api_url=entitycore_api_url, project_context=project_context)\n",
26
+ "token = os.getenv(\"ACCESS_TOKEN\", \"XXX\")"
27
+ ]
28
+ },
29
+ {
30
+ "cell_type": "markdown",
31
+ "id": "bebd0bea-8d87-4fe5-adcb-b897198aaba6",
32
+ "metadata": {},
33
+ "source": [
34
+ "## Create a Contribution object"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": null,
40
+ "id": "fd9e9356-0570-41f0-adc3-7ca859d1437b",
41
+ "metadata": {},
42
+ "outputs": [],
43
+ "source": [
44
+ "agent = client.search_entity(entity_type=Organization, token=token, limit=1).one()"
45
+ ]
46
+ },
47
+ {
48
+ "cell_type": "code",
49
+ "execution_count": null,
50
+ "id": "2ef91588-bc83-493e-b90c-2298f814f15e",
51
+ "metadata": {},
52
+ "outputs": [],
53
+ "source": [
54
+ "rprint(agent)"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": null,
60
+ "id": "0458e9bc-481b-4129-a206-60c546307411",
61
+ "metadata": {},
62
+ "outputs": [],
63
+ "source": [
64
+ "role = client.search_entity(entity_type=Role, token=token, limit=1).one()"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": null,
70
+ "id": "0d493ec1-044f-46a0-8310-5e6f00347836",
71
+ "metadata": {},
72
+ "outputs": [],
73
+ "source": [
74
+ "rprint(role)"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": null,
80
+ "id": "fa2c555c-22d5-41aa-8bf3-86fd87921dc1",
81
+ "metadata": {},
82
+ "outputs": [],
83
+ "source": [
84
+ "morphology = client.search_entity(\n",
85
+ " entity_type=ReconstructionMorphology, token=token, limit=1\n",
86
+ ").first()"
87
+ ]
88
+ },
89
+ {
90
+ "cell_type": "code",
91
+ "execution_count": null,
92
+ "id": "efcfdee2-7679-4ae9-90d6-7e70637459ea",
93
+ "metadata": {},
94
+ "outputs": [],
95
+ "source": [
96
+ "rprint(morphology)"
97
+ ]
98
+ },
99
+ {
100
+ "cell_type": "code",
101
+ "execution_count": null,
102
+ "id": "d3daa96f-4acc-46ef-83b4-375d42ab611c",
103
+ "metadata": {},
104
+ "outputs": [],
105
+ "source": [
106
+ "contribution = Contribution(\n",
107
+ " agent=agent,\n",
108
+ " role=role,\n",
109
+ " entity=morphology,\n",
110
+ ")"
111
+ ]
112
+ },
113
+ {
114
+ "cell_type": "code",
115
+ "execution_count": null,
116
+ "id": "653628d2-5ad9-44fb-be9c-8c7488d664ba",
117
+ "metadata": {},
118
+ "outputs": [],
119
+ "source": [
120
+ "rprint(contribution)"
121
+ ]
122
+ },
123
+ {
124
+ "cell_type": "markdown",
125
+ "id": "7ba44524-7710-4643-8a13-ca9575c179e7",
126
+ "metadata": {},
127
+ "source": [
128
+ "## Register it"
129
+ ]
130
+ },
131
+ {
132
+ "cell_type": "code",
133
+ "execution_count": null,
134
+ "id": "24076fd8-879b-49a7-af65-f0836b6703c2",
135
+ "metadata": {},
136
+ "outputs": [],
137
+ "source": [
138
+ "registered = client.register_entity(entity=contribution, token=token)"
139
+ ]
140
+ },
141
+ {
142
+ "cell_type": "code",
143
+ "execution_count": null,
144
+ "id": "20859296-1d8c-43a1-ab31-8ad9284ec8eb",
145
+ "metadata": {},
146
+ "outputs": [],
147
+ "source": [
148
+ "rprint(registered)"
149
+ ]
150
+ },
151
+ {
152
+ "cell_type": "markdown",
153
+ "id": "3c7ad61f-c2cf-467a-9624-211b0f06efbc",
154
+ "metadata": {},
155
+ "source": [
156
+ "## Retrieve it"
157
+ ]
158
+ },
159
+ {
160
+ "cell_type": "code",
161
+ "execution_count": null,
162
+ "id": "5d904513-4534-450e-8b97-3a0f185f7f6c",
163
+ "metadata": {},
164
+ "outputs": [],
165
+ "source": [
166
+ "retrieved = client.get_entity(entity_type=Contribution, entity_id=registered.id, token=token)"
167
+ ]
168
+ },
169
+ {
170
+ "cell_type": "code",
171
+ "execution_count": null,
172
+ "id": "891df12c-a76a-42f4-b0e4-bbfae0ab6d72",
173
+ "metadata": {},
174
+ "outputs": [],
175
+ "source": [
176
+ "rprint(retrieved)"
177
+ ]
178
+ }
179
+ ],
180
+ "metadata": {
181
+ "kernelspec": {
182
+ "display_name": "Python 3 (ipykernel)",
183
+ "language": "python",
184
+ "name": "python3"
185
+ },
186
+ "language_info": {
187
+ "codemirror_mode": {
188
+ "name": "ipython",
189
+ "version": 3
190
+ },
191
+ "file_extension": ".py",
192
+ "mimetype": "text/x-python",
193
+ "name": "python",
194
+ "nbconvert_exporter": "python",
195
+ "pygments_lexer": "ipython3",
196
+ "version": "3.12.9"
197
+ }
198
+ },
199
+ "nbformat": 4,
200
+ "nbformat_minor": 5
201
+ }