This is a maintainer how-to for extending ArrayBridge's closed framework
taxonomy. Applications should consume MemoryType; they should not add their
own framework registry.
Add an ArrayOperations bundle in
src/arraybridge/array_operations.py. It must provide four ordinary callables:
- project an array to NumPy;
- create an array from NumPy on the requested framework-local device;
- stack prepared 2D arrays into one 3D array;
- apply the framework's dtype-scaling semantics.
Define device, stream, DLPack, cleanup, and OOM leaves in
src/arraybridge/types.py. Use the no-op defaults in FrameworkRuntime only
when the framework genuinely lacks that capability. Do not encode behavior as
strings or add a parallel MemoryType-keyed table.
Add one MemoryType member carrying:
- its stable value and import name;
- its display name and module aliases;
- whether it is GPU-backed;
- any environment defaults that must be set before first import;
- its
FrameworkRuntimeleaves; - its
ArrayOperationsbundle.
The converter classes, target conversion methods, compatibility operation view, dtype-scaling view, cleanup adapters, and framework decorator are generated from the enum. Do not wire them manually.
Add focused tests for:
- module-name detection and optional-dependency failure;
- NumPy round trips and every supported DLPack pair;
- CPU-only installations of a nominally GPU framework;
- invalid, negative, and multiple framework-local device IDs;
- same-framework moves between two devices;
- one-, two-, and multi-slice stack/unstack behavior;
- immutable array types;
- cleanup and OOM behavior without importing an absent framework;
- generated registry and export completeness.
Run:
ruff check src tests
black --check src tests
mypy src --ignore-missing-imports
pytest
python -m sphinx -E -W --keep-going -b html docs/source /tmp/arraybridge-docsWhen GPU hardware is available, also exercise every installed framework pair in one process. This catches import-order, allocator-coexistence, DLPack, and real API-shape defects that isolated mocks cannot prove.