bkp-registry-client 0.11.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.
- bkp_registry_client-0.11.0/LICENSE +33 -0
- bkp_registry_client-0.11.0/PKG-INFO +313 -0
- bkp_registry_client-0.11.0/README.md +277 -0
- bkp_registry_client-0.11.0/pyproject.toml +491 -0
- bkp_registry_client-0.11.0/setup.cfg +4 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/__init__.py +68 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/__init__.py +8 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/abstract.py +30 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/constants/__init__.py +11 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/constants/excluded_fields.py +10 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/constants/external_sources.py +12 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/constants/operations.py +212 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/constants/sort_keys.py +449 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/constants/vocabularies.py +18 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/__init__.py +8 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/client/__init__.py +1 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/client/authentication.py +565 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/client/base_client.py +174 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/client/configuration.py +969 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/client/exception_helpers.py +130 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/client/exceptions.py +38 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/client/http.py +205 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/model/__init__.py +4 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/model/base_model.py +741 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/model/graphql_helpers.py +853 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/core/model/pydantic_helpers.py +186 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/crud.py +335 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/directory_manifest.py +132 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/display/__init__.py +310 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/display/config.py +174 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/display/projection.py +922 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/display/registry.py +309 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/display/render.py +1144 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/execution.py +842 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filter_values.py +604 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/__init__.py +4 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/asset_accounts.py +216 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/asset_collections.py +201 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/asset_types.py +345 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/assets.py +205 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/biological_collections.py +103 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/cells.py +204 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/instruments.py +233 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/namespace.py +118 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/operations.py +433 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/process_artifacts.py +119 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/process_states.py +79 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/process_templates.py +141 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/process_types.py +207 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/processes.py +214 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/species.py +100 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/specimens.py +370 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/storage.py +431 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/filters/subjects.py +252 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resolvers.py +798 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/__init__.py +9 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/asset_accounts.py +1061 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/asset_collections.py +1368 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/asset_helpers.py +580 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/asset_types.py +1970 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/assets.py +1444 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/biological_collections.py +722 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/cells.py +1373 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/instruments.py +1549 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/process_artifacts.py +3195 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/process_states.py +405 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/process_templates.py +1041 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/process_types.py +1869 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/processes.py +2938 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/species.py +498 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/specimens.py +2713 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/storage.py +2824 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/resources/subjects.py +1696 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/schemas/__init__.py +6 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/schemas/base.py +355 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/schemas/digest.py +111 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/type_helpers/__init__.py +221 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/type_helpers/_bio.py +1069 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/type_helpers/common.py +4242 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/type_helpers/instruments.py +117 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_internal/unset.py +44 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/_version.py +1 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/client.py +131 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/config.py +40 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/exceptions.py +285 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/filters.py +193 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/models.py +7457 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/py.typed +0 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/schemas.py +57 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client/types.py +251 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client.egg-info/PKG-INFO +313 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client.egg-info/SOURCES.txt +140 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client.egg-info/dependency_links.txt +1 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client.egg-info/requires.txt +11 -0
- bkp_registry_client-0.11.0/src/bkp_registry_client.egg-info/top_level.txt +3 -0
- bkp_registry_client-0.11.0/src/bkprs_client/__init__.py +59 -0
- bkp_registry_client-0.11.0/src/bkprs_client/_version.py +1 -0
- bkp_registry_client-0.11.0/src/bkprs_client/core/__init__.py +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client/core/client/__init__.py +7 -0
- bkp_registry_client-0.11.0/src/bkprs_client/core/client/authentication.py +11 -0
- bkp_registry_client-0.11.0/src/bkprs_client/core/client/base_client.py +13 -0
- bkp_registry_client-0.11.0/src/bkprs_client/core/client/configuration.py +15 -0
- bkp_registry_client-0.11.0/src/bkprs_client/core/client/exception_helpers.py +1 -0
- bkp_registry_client-0.11.0/src/bkprs_client/core/client/exceptions.py +11 -0
- bkp_registry_client-0.11.0/src/bkprs_client/core/client/http.py +5 -0
- bkp_registry_client-0.11.0/src/bkprs_client/py.typed +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/__init__.py +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/bers/__init__.py +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/bers/client.py +4060 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/bers/constants.py +59 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/bers/exceptions.py +11 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/bers/type_helpers.py +892 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/bkpr/__init__.py +15 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/bkpr/client.py +4 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/bkpr/exceptions.py +46 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/dats/__init__.py +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/dats/client.py +6656 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/dats/constants.py +81 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/dats/directory_manifest.py +127 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/dats/exceptions.py +47 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/dats/type_helpers.py +1862 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/pts/__init__.py +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/pts/client.py +4830 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/pts/constants.py +45 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/pts/exceptions.py +44 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/pts/type_helpers.py +925 -0
- bkp_registry_client-0.11.0/src/bkprs_client/service/service_type.py +9 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/__init__.py +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/core/__init__.py +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/core/base_model.py +1 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/core/graphql_helpers.py +1 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/core/pydantic_helpers.py +1 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/py.typed +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/__init__.py +0 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/bers/__init__.py +9 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/bers/models.py +4074 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/bkpr/__init__.py +16 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/bkpr/models.py +10 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/dats/__init__.py +9 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/dats/models.py +3347 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/pts/__init__.py +9 -0
- bkp_registry_client-0.11.0/src/bkprs_client_models/service/pts/models.py +1731 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Allen Institute Software License – This software license is the 2-clause BSD
|
|
2
|
+
license plus a third clause that prohibits redistribution and use for
|
|
3
|
+
commercial purposes without further permission.
|
|
4
|
+
|
|
5
|
+
Copyright © 2026. Allen Institute. All rights reserved.
|
|
6
|
+
|
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
|
8
|
+
modification, are permitted provided that the following conditions are met:
|
|
9
|
+
|
|
10
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
11
|
+
list of conditions and the following disclaimer.
|
|
12
|
+
|
|
13
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
and/or other materials provided with the distribution.
|
|
16
|
+
|
|
17
|
+
3. Redistributions and use for commercial purposes are not permitted without
|
|
18
|
+
the Allen Institute’s written permission. For purposes of this license,
|
|
19
|
+
commercial purposes are the incorporation of the Allen Institute's software
|
|
20
|
+
into anything for which you will charge fees or other compensation or use of
|
|
21
|
+
the software to perform a commercial service for a third party. Contact
|
|
22
|
+
terms@alleninstitute.org for commercial licensing opportunities.
|
|
23
|
+
|
|
24
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
25
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
26
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
27
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
28
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
29
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
30
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
31
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
32
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
33
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bkp-registry-client
|
|
3
|
+
Version: 0.11.0
|
|
4
|
+
Summary: Typed Python client for the Brain Knowledge Platform (BKP) Registry GraphQL service.
|
|
5
|
+
Author: AIBS Informatics Group
|
|
6
|
+
License-Expression: LicenseRef-Allen-Institute-Software-License
|
|
7
|
+
Project-URL: Homepage, https://github.com/AllenInstitute/bkp-registry-client-python
|
|
8
|
+
Project-URL: Documentation, https://bkp-registry-client.docs.brain.allentech.org/latest/
|
|
9
|
+
Project-URL: Repository, https://github.com/AllenInstitute/bkp-registry-client-python
|
|
10
|
+
Project-URL: Issues, https://github.com/AllenInstitute/bkp-registry-client-python/issues
|
|
11
|
+
Keywords: allen-institute,bkp,bkp-registry,brain-knowledge-platform,graphql,client
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: aibs-informatics-core<2.0.0,>=1.0.3
|
|
27
|
+
Requires-Dist: cloudpathlib>=0.23.0
|
|
28
|
+
Requires-Dist: gql[httpx]
|
|
29
|
+
Requires-Dist: graphql-query
|
|
30
|
+
Requires-Dist: msal~=1.32
|
|
31
|
+
Requires-Dist: msal_extensions~=1.3
|
|
32
|
+
Requires-Dist: pydantic<3,>=2.0.3
|
|
33
|
+
Requires-Dist: rich<15,>=14
|
|
34
|
+
Requires-Dist: typing_extensions<5.0.0,>=4.0.0; python_version < "3.13"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<picture>
|
|
39
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo/lockup-dark.png">
|
|
40
|
+
<img src="docs/assets/logo/lockup-light.png" width="420" alt="bkp/registry/client">
|
|
41
|
+
</picture>
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
<h1 align="center">BKP Registry Client</h1>
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<a href="https://bkp-registry-client.docs.brain.allentech.org/"><img src="https://img.shields.io/badge/docs-online-6464FF.svg" alt="Docs"></a>
|
|
48
|
+
<a href="https://pypi.org/project/bkp-registry-client/"><img src="https://img.shields.io/pypi/v/bkp-registry-client.svg" alt="PyPI"></a>
|
|
49
|
+
<a href="https://codecov.io/gh/AllenInstitute/bkp-registry-client-python"><img src="https://codecov.io/gh/AllenInstitute/bkp-registry-client-python/graph/badge.svg?token=tFdk2saBeU" alt="codecov"></a>
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
> [!WARNING]
|
|
53
|
+
> BKP Registry Client is in active development. Interfaces may change; please open issues or discussions for feedback.
|
|
54
|
+
|
|
55
|
+
A typed Python client for the Brain Knowledge Platform Registry (BKP Registry) GraphQL service. `BkpRegistryClient` wraps every registry interaction behind typed `list_*` / `get_*` / `create_*` / `update_*` / `delete_*` methods, with Pydantic-backed models generated from the BKP Registry schema, Azure AD and AWS Cognito authentication helpers, and expressive filter construction. Install it from [PyPI](https://pypi.org/project/bkp-registry-client/) with `pip install bkp-registry-client`, and read the full documentation at [bkp-registry-client.docs.brain.allentech.org](https://bkp-registry-client.docs.brain.allentech.org/).
|
|
56
|
+
|
|
57
|
+
> **New here?** Start with the **[Quick Start guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/quickstart/)** — install, connect, and run your first typed query. The [Configuration guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/configuration/) covers authentication flows and the staging/production endpoints in full.
|
|
58
|
+
|
|
59
|
+
> **Upgrading?** From 0.10, the distribution is now named `bkp-registry-client` and installs from PyPI: run `pip uninstall bkprs-client` before `pip install bkp-registry-client`, since both ship the same packages. The repository moved too, to `AllenInstitute/bkp-registry-client-python`. The [0.11 migration guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/migration-0.11-bkp-registry-client/) covers the reinstall, the import changes and the breaking changes — notably, the built-in defaults now target production, and a record's schema type comes back as a `*Ref` model. From a pre-release build (`BkprClient`, `bkprs_client.service.bkpr`), the client lives in the `bkp_registry_client` package (`from bkp_registry_client import BkpRegistryClient`, `bkp_registry_client.models`, `bkp_registry_client.config`, `bkp_registry_client.exceptions`); the old public paths keep working until 1.0 with a deprecation warning, and the [0.10 migration guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/migration-0.10-bkp-registry-client/) lists every rename and breaking change.
|
|
60
|
+
|
|
61
|
+
## Highlights
|
|
62
|
+
|
|
63
|
+
- One client, every resource: assets, storage, processes, instruments, specimens, subjects, cells, and more — a uniform CRUD surface on a single `BkpRegistryClient` instance.
|
|
64
|
+
- Strongly typed request/response models generated from a committed snapshot of the BKP Registry GraphQL schema (`bkp_registry_client.models`).
|
|
65
|
+
- Intuitive filtering: pass a raw value, a sequence of values, or a full GraphQL operation filter to any filter kwarg, and build filters on related records with `client.filters` (`bkp_registry_client.filters`).
|
|
66
|
+
- Built-in pagination with optional generator streaming on every `list_*` method.
|
|
67
|
+
- Typed sort keys, conflict handling on create (`on_conflict`), and disambiguation on get (`on_multiple`).
|
|
68
|
+
- `display()` and `to_records()` for reading result sets as tables, records, JSON or TSV — in a terminal or a notebook.
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
`bkp-registry-client` is published to [PyPI](https://pypi.org/project/bkp-registry-client/) from 0.11.0. It needs Python 3.11 or newer:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install bkp-registry-client
|
|
76
|
+
|
|
77
|
+
# or add it to a uv project
|
|
78
|
+
uv add bkp-registry-client
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Before 0.11.0 the distribution was named `bkprs-client` and installed from GitHub. Both names install the same `bkprs_client` and `bkp_registry_client` packages, so uninstall the old one first (`pip uninstall bkprs-client`).
|
|
82
|
+
|
|
83
|
+
To depend on it from another project, pin the minor version in `pyproject.toml`. Until 1.0, a minor release can carry breaking changes:
|
|
84
|
+
|
|
85
|
+
```toml
|
|
86
|
+
[project]
|
|
87
|
+
dependencies = [
|
|
88
|
+
"bkp-registry-client~=0.11.0",
|
|
89
|
+
]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### From GitHub
|
|
93
|
+
|
|
94
|
+
Install from the repository, [`AllenInstitute/bkp-registry-client-python`](https://github.com/AllenInstitute/bkp-registry-client-python), to pick up unreleased work on `develop` or a specific commit. This needs access to the repository: an SSH key on your GitHub account, or a personal access token.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# unreleased work
|
|
98
|
+
pip install "bkp-registry-client @ git+ssh://git@github.com/AllenInstitute/bkp-registry-client-python@develop"
|
|
99
|
+
|
|
100
|
+
# a release tag (the same specifier works in pyproject.toml and with uv add)
|
|
101
|
+
pip install "bkp-registry-client @ git+ssh://git@github.com/AllenInstitute/bkp-registry-client-python@v0.11.0"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Released versions are tagged `vX.Y.Z`, and each [GitHub release](https://github.com/AllenInstitute/bkp-registry-client-python/releases) has the wheel and sdist attached. The `latest` tag follows the newest release; like a branch, it moves.
|
|
105
|
+
|
|
106
|
+
Where SSH keys are unavailable — most CI runners — authenticate with a personal access token that has `repo` scope:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pip install "bkp-registry-client @ git+https://${GITHUB_TOKEN}@github.com/AllenInstitute/bkp-registry-client-python@develop"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Keep the token in an environment variable or secret store rather than committing it into `pyproject.toml`, where it would be readable by anyone with the repository.
|
|
113
|
+
|
|
114
|
+
### Working inside this repository
|
|
115
|
+
|
|
116
|
+
Contributors clone the repo and use the [`uv`](https://docs.astral.sh/uv/latest/) workflow used throughout Allen Institute projects, which installs the client, its dependencies, and the docs tooling:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
git clone git@github.com:AllenInstitute/bkp-registry-client-python.git
|
|
120
|
+
cd bkp-registry-client-python
|
|
121
|
+
uv sync --frozen --group dev
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Quickstart
|
|
125
|
+
|
|
126
|
+
The fastest way to a working client — the production endpoint and the Cognito sign-in are built in, so no configuration file is needed. Pass `environment="staging"` (or set `BKP_REGISTRY_ENV=staging`) to use staging instead:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from bkp_registry_client import BkpRegistryClient
|
|
130
|
+
|
|
131
|
+
client = BkpRegistryClient(use_default_settings=True) # production; environment="staging" for staging
|
|
132
|
+
|
|
133
|
+
for species in client.list_species(limit=5):
|
|
134
|
+
print(species.id, species.name, species.common_name)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The first call opens your browser for sign-in; the token is cached at `~/.bkprs_cognito_user_token_cache.json` so later runs are non-interactive.
|
|
138
|
+
|
|
139
|
+
Every method returns typed models from `bkp_registry_client.models`, making downstream validation easy:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# Fetch a single record by name
|
|
143
|
+
species = client.get_species(name="Mus musculus")
|
|
144
|
+
|
|
145
|
+
# List with typed filters and sorting
|
|
146
|
+
recent = client.list_species(
|
|
147
|
+
created_at="2026-07-01T00:00:00Z",
|
|
148
|
+
sort_by=["created_at"],
|
|
149
|
+
sort_order="DESC",
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Stream large result sets without holding them in memory
|
|
153
|
+
for specimen in client.list_specimens(as_generator=True):
|
|
154
|
+
print(specimen.name)
|
|
155
|
+
|
|
156
|
+
# Create with conflict handling
|
|
157
|
+
mouse = client.create_species(
|
|
158
|
+
name="Mus musculus",
|
|
159
|
+
common_name="house mouse",
|
|
160
|
+
on_conflict="update", # update the existing record instead of raising
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Filter kwargs are flexible — a raw value, a sequence of values, or a preconstructed GraphQL operation filter all work:
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
from bkp_registry_client.models import StringOperationFilterInput
|
|
168
|
+
|
|
169
|
+
client.list_species(name=["Mus musculus", "Homo sapiens"])
|
|
170
|
+
client.list_species(common_name=StringOperationFilterInput(contains="mouse"))
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
To filter on a related record, build its filter from the same kwargs as that record's `list_*` method with `client.filters` (also importable as `bkp_registry_client.filters`):
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
client.list_specimens(subjects=client.filters.subject(species="Macaca mulatta"))
|
|
177
|
+
client.list_species(common_name=client.filters.string(contains="mouse"))
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The [Quick Start guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/quickstart/) walks through the same ground in more depth — the five CRUD verbs, `on_conflict` / `on_multiple`, streaming with `as_generator`, and error handling.
|
|
181
|
+
|
|
182
|
+
## Displaying Results
|
|
183
|
+
|
|
184
|
+
Reading a result set does not need an f-string loop. `display()` prints any model, or any list of
|
|
185
|
+
models, as a table, a record, JSON or TSV — and renders correctly in both a terminal and a
|
|
186
|
+
notebook:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from bkp_registry_client import BkpRegistryClient, display, to_records
|
|
190
|
+
|
|
191
|
+
client = BkpRegistryClient(use_default_settings=True)
|
|
192
|
+
assets = client.list_assets(sort_by=["created_at"], sort_order="DESC", limit=125)
|
|
193
|
+
|
|
194
|
+
display(assets) # 50-row table, then a footer for the rest
|
|
195
|
+
display(assets[0]) # a single model prints as a record, all fields
|
|
196
|
+
display(assets, detail="full") # every column, not just the standard set
|
|
197
|
+
display(assets, view="json") # snake_case JSON, for pasting elsewhere
|
|
198
|
+
display(assets, fields=["name", "status", "instances"]) # explicit columns
|
|
199
|
+
display(assets, exclude=["created_by", "updated_by"]) # drop columns you never want
|
|
200
|
+
display(assets, summarize=["instances"]) # collapse one noisy cell to a count
|
|
201
|
+
|
|
202
|
+
records = to_records(assets) # real datetime/enum/model values, not display strings
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Nothing is shortened unless you ask. A `data` blob prints its contents rather than `{2 keys}`,
|
|
206
|
+
and a to-many list prints its members' labels; `truncate=` bounds a wide cell and `summarize=`
|
|
207
|
+
collapses one to a count.
|
|
208
|
+
|
|
209
|
+
In a notebook, set these two once — Rich cannot see how wide the browser is, and instance UUIDs
|
|
210
|
+
make a poor label:
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
from bkp_registry_client import display_defaults
|
|
214
|
+
|
|
215
|
+
display_defaults.width = 200
|
|
216
|
+
display_defaults.summarize = ["instances"]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
`to_records()` is the same projection `display()` renders, so it is the way into pandas without
|
|
220
|
+
this package depending on it. Values come back as real objects rather than display strings --
|
|
221
|
+
`datetime`, enum members, nested models. An `id` is the exception: the generated `UUID` scalar
|
|
222
|
+
is a `str` alias, so it stays a string.
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
import pandas as pd
|
|
226
|
+
|
|
227
|
+
df = pd.json_normalize(to_records(assets))
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
In a notebook, import the same function as `show` instead: Jupyter injects its own
|
|
231
|
+
`display` into every namespace, and `from bkp_registry_client import show` avoids shadowing it.
|
|
232
|
+
|
|
233
|
+
A cell marked `?` means the field was **not requested by your query** — not that it is empty.
|
|
234
|
+
`—` means fetched and null, and `·` means the field does not exist on that row's type. See the
|
|
235
|
+
[Displaying Results](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/display/) guide
|
|
236
|
+
for the views, detail tiers, dotted field paths, the absence markers and `display_defaults`.
|
|
237
|
+
|
|
238
|
+
## Configuration
|
|
239
|
+
|
|
240
|
+
For anything beyond the built-in defaults — service accounts, CI, or a custom endpoint — clients read an INI file pointed to by the `BKP_REGISTRY_API_CONFIG` environment variable. Values support `${ENV_VAR}` interpolation so credentials stay out of the file.
|
|
241
|
+
|
|
242
|
+
Create `~/bkp_registry_config.ini`:
|
|
243
|
+
|
|
244
|
+
```ini
|
|
245
|
+
[general]
|
|
246
|
+
cache_token = true
|
|
247
|
+
|
|
248
|
+
[account]
|
|
249
|
+
type = cognito_user
|
|
250
|
+
cognito_base_url = ${COGNITO_BASE_URL}
|
|
251
|
+
client_id = ${COGNITO_USER_CLIENT_ID}
|
|
252
|
+
redirect_uri = http://localhost:8765/callback
|
|
253
|
+
scopes = email
|
|
254
|
+
identity_provider = AzureAD
|
|
255
|
+
|
|
256
|
+
[bkp_registry]
|
|
257
|
+
url = https://prod-bkpr.brain.allentech.org/graphql
|
|
258
|
+
scope =
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Export the config path before instantiating a client:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
export BKP_REGISTRY_API_CONFIG=~/bkp_registry_config.ini
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
A single `[account]` section carries a `type =` discriminator selecting the authentication flow: `cognito_user` (interactive browser sign-in), `cognito_service` (machine-to-machine), `azure_service`, or `azure_user`. The older `ALLEN_SERVICE_API_CONFIG` variable and the per-flow section names (`[service_account]`, `[cognito_account]`, `[cognito_user_account]`, `[user_account]`) are still accepted, with a deprecation warning on the former.
|
|
268
|
+
|
|
269
|
+
If you need to override settings programmatically, you can pass a preloaded `BkpRegistryConfig`, a `ConfigParser`, or a custom `GqlEndpoint` into any client:
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
from pathlib import Path
|
|
273
|
+
|
|
274
|
+
from bkp_registry_client import BkpRegistryClient
|
|
275
|
+
from bkp_registry_client.config import BkpRegistryConfig
|
|
276
|
+
|
|
277
|
+
config = BkpRegistryConfig.from_config(Path("~/stage-config.ini").expanduser())
|
|
278
|
+
|
|
279
|
+
client = BkpRegistryClient(configuration=config)
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Environments
|
|
283
|
+
|
|
284
|
+
| Service | Staging | Production |
|
|
285
|
+
| --- | --- | --- |
|
|
286
|
+
| `bkpr` | `https://stage-bkpr.brain.devlims.org/graphql` | `https://prod-bkpr.brain.allentech.org/graphql` |
|
|
287
|
+
| `pts` | `https://stage-pts.brain.devlims.org/graphql` | `https://prod-process-tracking.brain.allentech.org/graphql` |
|
|
288
|
+
| `dats` | `https://stage-dats.brain.devlims.org/graphql` | `https://prod-dats.brain.allentech.org/graphql` |
|
|
289
|
+
| `bers` | `https://stage-bers.brain.devlims.org/graphql` | `https://prod-bers.brain.allentech.org/graphql` |
|
|
290
|
+
|
|
291
|
+
Staging and production are separate registries: records in one do not exist in the other, and access is authorized separately in each. Production signs in through the production Cognito user pool; for now staging still signs in through its own pool. `BkpRegistryClient`'s built-in defaults target **production**. Select staging with `BkpRegistryClient(environment="staging")`, `BkpRegistryConfig.build(environment="staging")`, or `BKP_REGISTRY_ENV=staging`; an explicit argument beats the environment variable. The variable only affects the built-in defaults: a client built with neither `environment=` nor `use_default_settings=True` uses your config file (or `configuration=`) and ignores it, while `use_default_settings=True` never reads the config file. The full details are in the [Configuration guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/configuration/).
|
|
292
|
+
|
|
293
|
+
## Resources
|
|
294
|
+
|
|
295
|
+
`BkpRegistryClient` covers the full registry:
|
|
296
|
+
|
|
297
|
+
- **Digital assets** — assets, asset types, asset accounts, asset collections, and storage (file and object storages, storage providers, storage uses).
|
|
298
|
+
- **Processes** — processes, process types, process templates, process states, process artifacts, and instruments.
|
|
299
|
+
- **Biological entities** — biological collections, specimens, species, subjects, and cells.
|
|
300
|
+
|
|
301
|
+
Each resource exposes the same CRUD pattern, plus relationship helpers (`update_<resource>_<relation>(..., mode=...)` with `append` / `replace` / `remove` modes) for projects, external identifiers, and the other to-many relations — assets, specimens, instruments, methods, metadata and hashes. A data asset's quality control is a single value instead: set it with `update_asset_quality_control(asset, schema_type_id=..., data=...)` and clear it with `remove_asset_quality_control(asset)`. See the [API Reference](https://bkp-registry-client.docs.brain.allentech.org/latest/api/clients/bkpr/) for the per-resource method documentation, or the [Quick Start guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/quickstart/) for a worked introduction.
|
|
302
|
+
|
|
303
|
+
## Legacy service clients
|
|
304
|
+
|
|
305
|
+
The per-service clients that predate `BkpRegistryClient` — `PtsClient` (Process Tracking Service), `DatsClient` (Digital Asset Tracking Service), and `BersClient` (BERS, biological entities) — remain available under `bkprs_client.service.{pts,dats,bers}`. They are **legacy**: maintained for bug fixes, and removed in 1.0. They share the same configuration pipeline (add `[pts]` / `[dats]` / `[bers]` sections with `url` and `scope` to the INI file). New integrations should prefer `BkpRegistryClient`.
|
|
306
|
+
|
|
307
|
+
## Development
|
|
308
|
+
|
|
309
|
+
For development setup instructions, testing guidelines, and documentation build steps, see the [DEVELOPMENT.md](DEVELOPMENT.md) file.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
<p align="center"><sub>An <a href="https://alleninstitute.org/">Allen Institute</a> project.</sub></p>
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo/lockup-dark.png">
|
|
4
|
+
<img src="docs/assets/logo/lockup-light.png" width="420" alt="bkp/registry/client">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<h1 align="center">BKP Registry Client</h1>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://bkp-registry-client.docs.brain.allentech.org/"><img src="https://img.shields.io/badge/docs-online-6464FF.svg" alt="Docs"></a>
|
|
12
|
+
<a href="https://pypi.org/project/bkp-registry-client/"><img src="https://img.shields.io/pypi/v/bkp-registry-client.svg" alt="PyPI"></a>
|
|
13
|
+
<a href="https://codecov.io/gh/AllenInstitute/bkp-registry-client-python"><img src="https://codecov.io/gh/AllenInstitute/bkp-registry-client-python/graph/badge.svg?token=tFdk2saBeU" alt="codecov"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
> [!WARNING]
|
|
17
|
+
> BKP Registry Client is in active development. Interfaces may change; please open issues or discussions for feedback.
|
|
18
|
+
|
|
19
|
+
A typed Python client for the Brain Knowledge Platform Registry (BKP Registry) GraphQL service. `BkpRegistryClient` wraps every registry interaction behind typed `list_*` / `get_*` / `create_*` / `update_*` / `delete_*` methods, with Pydantic-backed models generated from the BKP Registry schema, Azure AD and AWS Cognito authentication helpers, and expressive filter construction. Install it from [PyPI](https://pypi.org/project/bkp-registry-client/) with `pip install bkp-registry-client`, and read the full documentation at [bkp-registry-client.docs.brain.allentech.org](https://bkp-registry-client.docs.brain.allentech.org/).
|
|
20
|
+
|
|
21
|
+
> **New here?** Start with the **[Quick Start guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/quickstart/)** — install, connect, and run your first typed query. The [Configuration guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/configuration/) covers authentication flows and the staging/production endpoints in full.
|
|
22
|
+
|
|
23
|
+
> **Upgrading?** From 0.10, the distribution is now named `bkp-registry-client` and installs from PyPI: run `pip uninstall bkprs-client` before `pip install bkp-registry-client`, since both ship the same packages. The repository moved too, to `AllenInstitute/bkp-registry-client-python`. The [0.11 migration guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/migration-0.11-bkp-registry-client/) covers the reinstall, the import changes and the breaking changes — notably, the built-in defaults now target production, and a record's schema type comes back as a `*Ref` model. From a pre-release build (`BkprClient`, `bkprs_client.service.bkpr`), the client lives in the `bkp_registry_client` package (`from bkp_registry_client import BkpRegistryClient`, `bkp_registry_client.models`, `bkp_registry_client.config`, `bkp_registry_client.exceptions`); the old public paths keep working until 1.0 with a deprecation warning, and the [0.10 migration guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/migration-0.10-bkp-registry-client/) lists every rename and breaking change.
|
|
24
|
+
|
|
25
|
+
## Highlights
|
|
26
|
+
|
|
27
|
+
- One client, every resource: assets, storage, processes, instruments, specimens, subjects, cells, and more — a uniform CRUD surface on a single `BkpRegistryClient` instance.
|
|
28
|
+
- Strongly typed request/response models generated from a committed snapshot of the BKP Registry GraphQL schema (`bkp_registry_client.models`).
|
|
29
|
+
- Intuitive filtering: pass a raw value, a sequence of values, or a full GraphQL operation filter to any filter kwarg, and build filters on related records with `client.filters` (`bkp_registry_client.filters`).
|
|
30
|
+
- Built-in pagination with optional generator streaming on every `list_*` method.
|
|
31
|
+
- Typed sort keys, conflict handling on create (`on_conflict`), and disambiguation on get (`on_multiple`).
|
|
32
|
+
- `display()` and `to_records()` for reading result sets as tables, records, JSON or TSV — in a terminal or a notebook.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
`bkp-registry-client` is published to [PyPI](https://pypi.org/project/bkp-registry-client/) from 0.11.0. It needs Python 3.11 or newer:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install bkp-registry-client
|
|
40
|
+
|
|
41
|
+
# or add it to a uv project
|
|
42
|
+
uv add bkp-registry-client
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Before 0.11.0 the distribution was named `bkprs-client` and installed from GitHub. Both names install the same `bkprs_client` and `bkp_registry_client` packages, so uninstall the old one first (`pip uninstall bkprs-client`).
|
|
46
|
+
|
|
47
|
+
To depend on it from another project, pin the minor version in `pyproject.toml`. Until 1.0, a minor release can carry breaking changes:
|
|
48
|
+
|
|
49
|
+
```toml
|
|
50
|
+
[project]
|
|
51
|
+
dependencies = [
|
|
52
|
+
"bkp-registry-client~=0.11.0",
|
|
53
|
+
]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### From GitHub
|
|
57
|
+
|
|
58
|
+
Install from the repository, [`AllenInstitute/bkp-registry-client-python`](https://github.com/AllenInstitute/bkp-registry-client-python), to pick up unreleased work on `develop` or a specific commit. This needs access to the repository: an SSH key on your GitHub account, or a personal access token.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# unreleased work
|
|
62
|
+
pip install "bkp-registry-client @ git+ssh://git@github.com/AllenInstitute/bkp-registry-client-python@develop"
|
|
63
|
+
|
|
64
|
+
# a release tag (the same specifier works in pyproject.toml and with uv add)
|
|
65
|
+
pip install "bkp-registry-client @ git+ssh://git@github.com/AllenInstitute/bkp-registry-client-python@v0.11.0"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Released versions are tagged `vX.Y.Z`, and each [GitHub release](https://github.com/AllenInstitute/bkp-registry-client-python/releases) has the wheel and sdist attached. The `latest` tag follows the newest release; like a branch, it moves.
|
|
69
|
+
|
|
70
|
+
Where SSH keys are unavailable — most CI runners — authenticate with a personal access token that has `repo` scope:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install "bkp-registry-client @ git+https://${GITHUB_TOKEN}@github.com/AllenInstitute/bkp-registry-client-python@develop"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Keep the token in an environment variable or secret store rather than committing it into `pyproject.toml`, where it would be readable by anyone with the repository.
|
|
77
|
+
|
|
78
|
+
### Working inside this repository
|
|
79
|
+
|
|
80
|
+
Contributors clone the repo and use the [`uv`](https://docs.astral.sh/uv/latest/) workflow used throughout Allen Institute projects, which installs the client, its dependencies, and the docs tooling:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone git@github.com:AllenInstitute/bkp-registry-client-python.git
|
|
84
|
+
cd bkp-registry-client-python
|
|
85
|
+
uv sync --frozen --group dev
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Quickstart
|
|
89
|
+
|
|
90
|
+
The fastest way to a working client — the production endpoint and the Cognito sign-in are built in, so no configuration file is needed. Pass `environment="staging"` (or set `BKP_REGISTRY_ENV=staging`) to use staging instead:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from bkp_registry_client import BkpRegistryClient
|
|
94
|
+
|
|
95
|
+
client = BkpRegistryClient(use_default_settings=True) # production; environment="staging" for staging
|
|
96
|
+
|
|
97
|
+
for species in client.list_species(limit=5):
|
|
98
|
+
print(species.id, species.name, species.common_name)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The first call opens your browser for sign-in; the token is cached at `~/.bkprs_cognito_user_token_cache.json` so later runs are non-interactive.
|
|
102
|
+
|
|
103
|
+
Every method returns typed models from `bkp_registry_client.models`, making downstream validation easy:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
# Fetch a single record by name
|
|
107
|
+
species = client.get_species(name="Mus musculus")
|
|
108
|
+
|
|
109
|
+
# List with typed filters and sorting
|
|
110
|
+
recent = client.list_species(
|
|
111
|
+
created_at="2026-07-01T00:00:00Z",
|
|
112
|
+
sort_by=["created_at"],
|
|
113
|
+
sort_order="DESC",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# Stream large result sets without holding them in memory
|
|
117
|
+
for specimen in client.list_specimens(as_generator=True):
|
|
118
|
+
print(specimen.name)
|
|
119
|
+
|
|
120
|
+
# Create with conflict handling
|
|
121
|
+
mouse = client.create_species(
|
|
122
|
+
name="Mus musculus",
|
|
123
|
+
common_name="house mouse",
|
|
124
|
+
on_conflict="update", # update the existing record instead of raising
|
|
125
|
+
)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Filter kwargs are flexible — a raw value, a sequence of values, or a preconstructed GraphQL operation filter all work:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from bkp_registry_client.models import StringOperationFilterInput
|
|
132
|
+
|
|
133
|
+
client.list_species(name=["Mus musculus", "Homo sapiens"])
|
|
134
|
+
client.list_species(common_name=StringOperationFilterInput(contains="mouse"))
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
To filter on a related record, build its filter from the same kwargs as that record's `list_*` method with `client.filters` (also importable as `bkp_registry_client.filters`):
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
client.list_specimens(subjects=client.filters.subject(species="Macaca mulatta"))
|
|
141
|
+
client.list_species(common_name=client.filters.string(contains="mouse"))
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The [Quick Start guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/quickstart/) walks through the same ground in more depth — the five CRUD verbs, `on_conflict` / `on_multiple`, streaming with `as_generator`, and error handling.
|
|
145
|
+
|
|
146
|
+
## Displaying Results
|
|
147
|
+
|
|
148
|
+
Reading a result set does not need an f-string loop. `display()` prints any model, or any list of
|
|
149
|
+
models, as a table, a record, JSON or TSV — and renders correctly in both a terminal and a
|
|
150
|
+
notebook:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from bkp_registry_client import BkpRegistryClient, display, to_records
|
|
154
|
+
|
|
155
|
+
client = BkpRegistryClient(use_default_settings=True)
|
|
156
|
+
assets = client.list_assets(sort_by=["created_at"], sort_order="DESC", limit=125)
|
|
157
|
+
|
|
158
|
+
display(assets) # 50-row table, then a footer for the rest
|
|
159
|
+
display(assets[0]) # a single model prints as a record, all fields
|
|
160
|
+
display(assets, detail="full") # every column, not just the standard set
|
|
161
|
+
display(assets, view="json") # snake_case JSON, for pasting elsewhere
|
|
162
|
+
display(assets, fields=["name", "status", "instances"]) # explicit columns
|
|
163
|
+
display(assets, exclude=["created_by", "updated_by"]) # drop columns you never want
|
|
164
|
+
display(assets, summarize=["instances"]) # collapse one noisy cell to a count
|
|
165
|
+
|
|
166
|
+
records = to_records(assets) # real datetime/enum/model values, not display strings
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Nothing is shortened unless you ask. A `data` blob prints its contents rather than `{2 keys}`,
|
|
170
|
+
and a to-many list prints its members' labels; `truncate=` bounds a wide cell and `summarize=`
|
|
171
|
+
collapses one to a count.
|
|
172
|
+
|
|
173
|
+
In a notebook, set these two once — Rich cannot see how wide the browser is, and instance UUIDs
|
|
174
|
+
make a poor label:
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
from bkp_registry_client import display_defaults
|
|
178
|
+
|
|
179
|
+
display_defaults.width = 200
|
|
180
|
+
display_defaults.summarize = ["instances"]
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`to_records()` is the same projection `display()` renders, so it is the way into pandas without
|
|
184
|
+
this package depending on it. Values come back as real objects rather than display strings --
|
|
185
|
+
`datetime`, enum members, nested models. An `id` is the exception: the generated `UUID` scalar
|
|
186
|
+
is a `str` alias, so it stays a string.
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
import pandas as pd
|
|
190
|
+
|
|
191
|
+
df = pd.json_normalize(to_records(assets))
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
In a notebook, import the same function as `show` instead: Jupyter injects its own
|
|
195
|
+
`display` into every namespace, and `from bkp_registry_client import show` avoids shadowing it.
|
|
196
|
+
|
|
197
|
+
A cell marked `?` means the field was **not requested by your query** — not that it is empty.
|
|
198
|
+
`—` means fetched and null, and `·` means the field does not exist on that row's type. See the
|
|
199
|
+
[Displaying Results](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/display/) guide
|
|
200
|
+
for the views, detail tiers, dotted field paths, the absence markers and `display_defaults`.
|
|
201
|
+
|
|
202
|
+
## Configuration
|
|
203
|
+
|
|
204
|
+
For anything beyond the built-in defaults — service accounts, CI, or a custom endpoint — clients read an INI file pointed to by the `BKP_REGISTRY_API_CONFIG` environment variable. Values support `${ENV_VAR}` interpolation so credentials stay out of the file.
|
|
205
|
+
|
|
206
|
+
Create `~/bkp_registry_config.ini`:
|
|
207
|
+
|
|
208
|
+
```ini
|
|
209
|
+
[general]
|
|
210
|
+
cache_token = true
|
|
211
|
+
|
|
212
|
+
[account]
|
|
213
|
+
type = cognito_user
|
|
214
|
+
cognito_base_url = ${COGNITO_BASE_URL}
|
|
215
|
+
client_id = ${COGNITO_USER_CLIENT_ID}
|
|
216
|
+
redirect_uri = http://localhost:8765/callback
|
|
217
|
+
scopes = email
|
|
218
|
+
identity_provider = AzureAD
|
|
219
|
+
|
|
220
|
+
[bkp_registry]
|
|
221
|
+
url = https://prod-bkpr.brain.allentech.org/graphql
|
|
222
|
+
scope =
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Export the config path before instantiating a client:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
export BKP_REGISTRY_API_CONFIG=~/bkp_registry_config.ini
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
A single `[account]` section carries a `type =` discriminator selecting the authentication flow: `cognito_user` (interactive browser sign-in), `cognito_service` (machine-to-machine), `azure_service`, or `azure_user`. The older `ALLEN_SERVICE_API_CONFIG` variable and the per-flow section names (`[service_account]`, `[cognito_account]`, `[cognito_user_account]`, `[user_account]`) are still accepted, with a deprecation warning on the former.
|
|
232
|
+
|
|
233
|
+
If you need to override settings programmatically, you can pass a preloaded `BkpRegistryConfig`, a `ConfigParser`, or a custom `GqlEndpoint` into any client:
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
from pathlib import Path
|
|
237
|
+
|
|
238
|
+
from bkp_registry_client import BkpRegistryClient
|
|
239
|
+
from bkp_registry_client.config import BkpRegistryConfig
|
|
240
|
+
|
|
241
|
+
config = BkpRegistryConfig.from_config(Path("~/stage-config.ini").expanduser())
|
|
242
|
+
|
|
243
|
+
client = BkpRegistryClient(configuration=config)
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Environments
|
|
247
|
+
|
|
248
|
+
| Service | Staging | Production |
|
|
249
|
+
| --- | --- | --- |
|
|
250
|
+
| `bkpr` | `https://stage-bkpr.brain.devlims.org/graphql` | `https://prod-bkpr.brain.allentech.org/graphql` |
|
|
251
|
+
| `pts` | `https://stage-pts.brain.devlims.org/graphql` | `https://prod-process-tracking.brain.allentech.org/graphql` |
|
|
252
|
+
| `dats` | `https://stage-dats.brain.devlims.org/graphql` | `https://prod-dats.brain.allentech.org/graphql` |
|
|
253
|
+
| `bers` | `https://stage-bers.brain.devlims.org/graphql` | `https://prod-bers.brain.allentech.org/graphql` |
|
|
254
|
+
|
|
255
|
+
Staging and production are separate registries: records in one do not exist in the other, and access is authorized separately in each. Production signs in through the production Cognito user pool; for now staging still signs in through its own pool. `BkpRegistryClient`'s built-in defaults target **production**. Select staging with `BkpRegistryClient(environment="staging")`, `BkpRegistryConfig.build(environment="staging")`, or `BKP_REGISTRY_ENV=staging`; an explicit argument beats the environment variable. The variable only affects the built-in defaults: a client built with neither `environment=` nor `use_default_settings=True` uses your config file (or `configuration=`) and ignores it, while `use_default_settings=True` never reads the config file. The full details are in the [Configuration guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/configuration/).
|
|
256
|
+
|
|
257
|
+
## Resources
|
|
258
|
+
|
|
259
|
+
`BkpRegistryClient` covers the full registry:
|
|
260
|
+
|
|
261
|
+
- **Digital assets** — assets, asset types, asset accounts, asset collections, and storage (file and object storages, storage providers, storage uses).
|
|
262
|
+
- **Processes** — processes, process types, process templates, process states, process artifacts, and instruments.
|
|
263
|
+
- **Biological entities** — biological collections, specimens, species, subjects, and cells.
|
|
264
|
+
|
|
265
|
+
Each resource exposes the same CRUD pattern, plus relationship helpers (`update_<resource>_<relation>(..., mode=...)` with `append` / `replace` / `remove` modes) for projects, external identifiers, and the other to-many relations — assets, specimens, instruments, methods, metadata and hashes. A data asset's quality control is a single value instead: set it with `update_asset_quality_control(asset, schema_type_id=..., data=...)` and clear it with `remove_asset_quality_control(asset)`. See the [API Reference](https://bkp-registry-client.docs.brain.allentech.org/latest/api/clients/bkpr/) for the per-resource method documentation, or the [Quick Start guide](https://bkp-registry-client.docs.brain.allentech.org/latest/user-guide/quickstart/) for a worked introduction.
|
|
266
|
+
|
|
267
|
+
## Legacy service clients
|
|
268
|
+
|
|
269
|
+
The per-service clients that predate `BkpRegistryClient` — `PtsClient` (Process Tracking Service), `DatsClient` (Digital Asset Tracking Service), and `BersClient` (BERS, biological entities) — remain available under `bkprs_client.service.{pts,dats,bers}`. They are **legacy**: maintained for bug fixes, and removed in 1.0. They share the same configuration pipeline (add `[pts]` / `[dats]` / `[bers]` sections with `url` and `scope` to the INI file). New integrations should prefer `BkpRegistryClient`.
|
|
270
|
+
|
|
271
|
+
## Development
|
|
272
|
+
|
|
273
|
+
For development setup instructions, testing guidelines, and documentation build steps, see the [DEVELOPMENT.md](DEVELOPMENT.md) file.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
<p align="center"><sub>An <a href="https://alleninstitute.org/">Allen Institute</a> project.</sub></p>
|