Skip to main content

ApertureDB Python SDK

PyPI version Python versions License Build Status

The ApertureDB Python SDK provides a seamless interface for interacting with ApertureDB, the purpose-built database for storing, managing, and querying visual data (images, videos) alongside metadata, embeddings, and annotations.

This SDK includes comprehensive utilities to efficiently ingest and retrieve data, manage graph-based metadata, perform similarity searches on embeddings, and seamlessly integrate with the broader ML/AI ecosystem.

SDK 1.0.2 server compatibility

SDK 1.0.2 supports server 0.20.0 and 1.0.0 over TCP/TLS and HTTP. The connector selects the transport and helper commands automatically. Existing query() calls retain their buffered return shape; query_stream() provides JSON metadata followed by lazy blobs/chunks on server 1.0. Queries are never replayed automatically after uncertain transport failures.

Server 1.0 custom queries require explicit application classes and native vector indexes. AddConnection takes a string connection name and source and destination references. Connection filters and index selectors group class names under class and endpoint types under target. Use limit and offset for paging. SDK helpers and loaders handle both supported APIs; custom query generators must use the selected server's command language. See the server 1.0 migration and streaming guide.

🚀 Integrations & Capabilities

The SDK is designed for modern ML workflows and offers seamless integrations with (some require additional dependencies):

  • Deep Learning Frameworks: Seamless conversion of ApertureDB queries into PyTorch (PyTorchDataset.ApertureDBDataset) and TensorFlow (ApertureDBTensorFlowDataset) data loaders for immediate model training.
  • Vector Search & Embeddings: First-class support for storing and retrieving high-dimensional descriptors, including native embedding extraction utilizing CLIP (requires openai-clip) and Facenet.
  • Distributed Data Processing: Integration with Dask to handle parallelized data loading and large-scale query execution.
  • Cloud Storage Integrations: Easy handling of assets stored remotely using Boto3 (AWS S3) and Google Cloud Storage.
  • ML Croissant: Native parsing and handling of datasets aligned with the ML Croissant metadata format (requires mlcroissant).
  • Knowledge Graphs: Ability to execute and map SPARQL queries natively into the database (requires rdflib).

📦 Installation

To install the SDK in a standard virtual environment with all core integrations (such as PyTorch and TensorFlow support):

pip install "aperturedb[complete]"

To install just the base client without optional deep learning extras:

pip install aperturedb

Authentication and shared sessions

The SDK signs in when you first run a query and renews the session as needed. If the server rejects a session before running a query, the SDK renews it and retries that query once. When the refresh token is no longer accepted, it signs in again using the password or personal token configured on the connector. If those credentials are also rejected, the query raises an exception.

Use a separate Connector for each thread, created with db.clone(). Clones share a session, so concurrent requests reuse the same login and coordinate session renewal. Dask tasks create independent sessions using the same configured credentials, allowing each process to renew its own session.

On servers that apply security changes immediately, existing connectors observe updated permissions on subsequent queries. Removing a user's access or revoking their configured credentials can cause those queries to fail. Queries sent to replicas may briefly observe earlier permissions while replication catches up. Permission errors are returned to the caller. Explicit Authenticate and RefreshToken queries also return their errors without automatic session recovery.

📚 Documentation & Examples

🛠 Development Setup

The recommended way to contribute is to clone this repository and perform an editable installation:

git clone https://github.com/aperture-data/aperturedb-python.git
cd aperturedb-python
pip install -e '.[dev]'

🧪 Running Tests

The tests are located inside the test/ directory. They run against an ApertureDB stack (aperturedb, lenz, http-proxy and webui) started from the published Docker Compose artifact aperturedata/aperturedb-compose-single-node. ADB_COMPOSE selects the artifact; the default is the latest release.

If you'd like to bring up the environment manually, ensure your working directory is test/ and run:

./stack.sh up local

It publishes the native protocol on localhost:55555 and HTTPS on localhost:443; set ADB_TCP_PORT and HTTPS_PORT to use other ports. ./stack.sh down local stops it and deletes its files.

Development Environment Adjustments

To connect to the local test environment natively from your host, edit test/dbinfo.py to match the published ports and the stack's CA:

DB_TCP_HOST = 'localhost'
DB_REST_HOST = 'localhost'
DB_TCP_PORT  = 55555  # ADB_TCP_PORT
DB_REST_PORT = 443    # HTTPS_PORT
CA_CERT      = 'aperturedb/local/ca/ca.crt'

Executing Tests

To run the entire test suite, export the necessary credentials and execute the test runner script:

export GCP_SERVICE_ACCOUNT_KEY=<content of a GCP SERVICE ACCOUNT JSON file>
bash run_test.sh

To run a specific test file natively via pytest:

PROJECT=aperturedata KAGGLE_username=ci KAGGLE_key=dummy coverage run -m pytest test_Session.py -v -s --log-cli-level=DEBUG

(Note: The test suite assumes a Linux x86_64 environment. Adjustments may be required for macOS or Windows.)

⚙️ Runtime Configuration Variables

The following environment variables can modify the runtime behavior of the SDK, which is particularly useful for debugging:

Variable Type Description Default Value
ADB_DEBUGGABLE flag If set (to any value), allows the application to register a fault handler that dumps a trace when SIGUSR1 is sent to the process. Not set
LOG_FILE_LEVEL string The threshold for emitting log messages into the error<timestamp>.log file. WARN
LOG_CONSOLE_LEVEL string The threshold for emitting log messages to stdout. ERROR
ADB_LOG_FILE string Custom file path for the log output. Not set

🐞 Bug Reports & Contributing

  • Bugs: Please report any issues regarding functionality, documentation, or tests by creating a GitHub Issue.
  • Contributing: We welcome Pull Requests! When submitting a PR, include a brief description of the problem and the implemented fix.
  • Coding Standards: Our CI enforces coding style guidelines using autopep8 and trailing whitespace checks. If a PR encounters failures, review the CI logs for details on the offending lines.

Metadata

Release files for aperturedb 1.0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for aperturedb 1.0.2.1
File Interpreter ABI Platform Actions
aperturedb-1.0.2.1-py3-none-any.whl Python 3 none any Details for aperturedb-1.0.2.1-py3-none-any.whl

Release files / aperturedb-1.0.2.1-py3-none-any.whl

Download URL aperturedb-1.0.2.1-py3-none-any.whl
Size 632.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a387077eb3a4498078222a319369ab1d89c03d8ba019fc97e2e781d17e8b701c
BLAKE2b-256 checksum
How to use checksums
3f10961ae241c4f388eaf31303784f5c08221397acb7666a1a56a5c0400621cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for aperturedb 1.0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page