Repository navigation
Description
Feature Request
Problem
Many existing DataJoint pipelines rely on the blob attribute type to store arbitrary serialized Python objects (e.g., NumPy arrays, dictionaries, custom class instances). While DataJoint 2.0 is moving towards a more structured approach with object types and specialized adaptors, there is a critical need for a backward-compatible solution. Without a standardized <dj_blob> adaptor, migrating legacy pipelines becomes a significant challenge, requiring users to manually update their code to handle serialization, which defeats the purpose of a seamless upgrade path.
Requirements
A successful implementation of this improvement should provide a built-in Custom Type Adaptor that replicates the functionality of the legacy blob type for storing general Python objects. This implementation must adhere to the DataJoint 2.0 Specification.
The core requirements are:
- Create a
dj.CustomTypeAdaptor for classic datajoint blobs.�
- A new class must be implemented that inherits from
dj.CustomType.
- Implement the Standard Interface:
- The
input_typeproperty must return the type name to be used in the definition:dj_blob. - The
stored_typeproperty must return the type name to convert into for storage (can be anotherCustomType. - The
putmethod must accept an arbitrary Python object and serialize it into a binary format suitable for storage in ablobdatabase field. - The get method must accept the binary data from the blob field and deserialize it back into the original Python object.
- The
<dj_blob>adaptor should be registered by default with the DataJoint client, making it available out-of-the-box without requiring user intervention.
Justification
The primary justification for this feature is backward compatibility. It provides a direct and simple migration path for countless existing pipelines that depend on the ability to store serialized Python objects in blob fields. Furthermore, it offers a standardized, safe, and officially supported method for handling generic Python objects, ensuring consistency and preventing the proliferation of ad-hoc serialization solutions in new pipelines.
Activity
github-actions commentedon Oct 11, 2025
This issue is stale because it has been open for 45 days with no activity.
dimitri-yatsenko commentedon Jan 8, 2026
DataJoint 2.0 Implementation
This feature is implemented in DataJoint 2.0 via the
<blob>codec (using<blob>syntax rather than<dj_blob>).Implementation Details
The
BlobCodecclass insrc/datajoint/builtin_codecs.pyprovides the requested functionality:Requirements Checklist
BlobCodecclassinput_typepropertyname = "blob"(used as<blob>)stored_typepropertyget_dtype()returnsbytesor<hash>putmethod (serialize)encode()usingblob.pack()getmethod (deserialize)decode()usingblob.unpack()Usage
Naming Convention
The implementation uses
<blob>rather than<dj_blob>for cleaner syntax. The three-layer type system in 2.0 distinguishes:blob: Raw bytes (no serialization)<blob>: DataJoint's serialization format (NumPy, dicts, etc.)This approach is cleaner and consistent with other codecs (
<hash>,<object>,<attach>, etc.).Backward Compatibility
The
<blob>codec uses the sameblob.pack()/blob.unpack()functions as legacy DataJoint, ensuring full backward compatibility with existing serialized data.dimitri-yatsenko commentedon Jan 9, 2026
Implemented in DataJoint 2.0
The
<blob>codec is built-in and provides backward-compatible blob functionality:Implementation:
src/datajoint/builtin_codecs.pyUsage:
The
<blob>codec is the default for DataJoint's native object serialization, providing seamless migration from legacy blob fields.