Skip to main content

Python library for interacting with the entitycore service

Project description

Build status License Code coverage CodeQL PyPI

entitysdk

entitysdk is a Python library for interacting with the entitycore service, providing a type-safe and intuitive interface for managing scientific entities, and their associated assets.

Requirements

  • Python 3.11 or higher
  • Network access to entitycore service endpoints

Installation

pip install entitysdk

Obtaining a valid access token

An access token can be retrieved easily using the obi-auth helper library.

pip install obi-auth
from obi_auth import get_token

token = get_token(environment="staging")

Quick Start

from uuid import UUID
from entitysdk import Client, ProjectContext, models

# Initialize client
client = Client(
    project_context=ProjectContext(
        project_id=UUID("your-project-id"),
        virtual_lab_id=UUID("your-lab-id")
    ),
    environment="staging",
    token_manager=token
)

# Search for morphologies
iterator = client.search_entity(
    entity_type=models.ReconstructionMorphology,
    query={"mtype__pref_label": "L5_TPC:A"},
    limit=1,
)
morphology = next(iterator)

# Upload an asset
client.upload_file(
    entity_id=morphology.id,
    entity_type=models.ReconstructionMorphology,
    file_path="path/to/file.swc",
    file_content_type="application/swc",
)

Authentication

  • Valid Keycloak access token
  • Project context with:
    • Valid project ID (UUID)
    • Valid virtual lab ID (UUID)

Example configuration:

from uuid import UUID
from entitysdk import ProjectContext

project_context = ProjectContext(
    project_id=UUID("12345678-1234-1234-1234-123456789012"),
    virtual_lab_id=UUID("87654321-4321-4321-4321-210987654321")
)

Development

Requirements

  • tox/tox-uv

Clone and run tests

# Clone the repository
git clone https://github.com/your-org/entitysdk.git

# Run linting, tests, and check-packaging
tox

Auto-generate server schemas

Server schemas at src/entitysdk/_server_schemas.py, which are currently used for importing enum types, can be updated with the following tox command:

tox -e generate-server-schemas

Please note that a manual step is required following the generation of the schemas. Importing future annotations requires to be moved at the top of the file:

from __future__ import annotations

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

Copyright (c) 2025 Open Brain Institute

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Release history Release notifications | RSS feed

This version

0.7.6

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

entitysdk-0.7.6.tar.gz (1.4 MB view details)

Uploaded Source

File details

Details for the file entitysdk-0.7.6.tar.gz.

File metadata

  • Download URL: entitysdk-0.7.6.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for entitysdk-0.7.6.tar.gz
Algorithm Hash digest
SHA256 d65a4cd290165784bc49e057785a0b4e28d21b36c407774e0c7fc65eabb0044b
MD5 8368a76d8da5948a0e04054c921e9991
BLAKE2b-256 c36fe0d54175436a0e6da56a9919a4b855629a63a95e8ffe692756ff239bd490

See more details on using hashes here.

Provenance

The following attestation bundles were made for entitysdk-0.7.6.tar.gz:

Publisher: sdist.yml on openbraininstitute/entitysdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page