Skip to content

feat(targets): add Turbopuffer target connector#1647

Open
costajohnt wants to merge 3 commits intococoindex-io:mainfrom
costajohnt:add-turbopuffer-target
Open

feat(targets): add Turbopuffer target connector#1647
costajohnt wants to merge 3 commits intococoindex-io:mainfrom
costajohnt:add-turbopuffer-target

Conversation

@costajohnt
Copy link

Summary

  • Adds a new target connector for Turbopuffer vector database, following the same pattern as the existing ChromaDB connector
  • Supports cosine distance, euclidean squared, and dot product similarity metrics
  • Includes 30 unit tests covering all connector logic and helper functions (no turbopuffer account required)

Changes

  • python/cocoindex/targets/turbopuffer.py — Connector implementation with Turbopuffer spec class and _Connector with all 7 required static methods
  • python/cocoindex/tests/targets/test_turbopuffer_unit.py — Unit tests for persistent key, setup state validation, state compatibility, describe, and all helper functions
  • pyproject.toml — Added turbopuffer optional dependency, added to all group, added to mypy ignore list

Test plan

  • ruff check passes with no issues
  • mypy passes with no issues
  • pytest python/cocoindex/tests/targets/test_turbopuffer_unit.py -v — 30/30 tests pass
  • python -c "import cocoindex.targets.turbopuffer" succeeds

Closes #1562

Add a new target connector for Turbopuffer vector database. The
implementation follows the same pattern as the ChromaDB connector
with turbopuffer-specific adaptations:

- Namespaces are created implicitly on first write (no explicit setup)
- distance_metric is passed on every upsert call
- Row-oriented write format via ns.write(upsert_rows=[...])
- Supports cosine, euclidean, and dot product distance metrics

Includes 30 unit tests covering all connector logic and helper
functions, with no turbopuffer account required.

Closes cocoindex-io#1562
@costajohnt costajohnt force-pushed the add-turbopuffer-target branch from 58d9ee3 to f4d2cb3 Compare February 8, 2026 18:34
@badmonster0
Copy link
Member

thanks a lot @costajohnt john! we'll get to this shortly!

@badmonster0 badmonster0 requested a review from georgeh0 February 9, 2026 02:41
@costajohnt
Copy link
Author

thanks a lot @costajohnt john! we'll get to this shortly!

sounds good, thanks @badmonster0

Move the top-level `import turbopuffer` behind a TYPE_CHECKING guard
and add a _get_turbopuffer() helper for runtime imports. This matches
the existing pattern in the doris connector and fixes CI failures
where turbopuffer is not installed in the CI dependency group.

Also run `uv lock` to include turbopuffer and sniffio in the lock file.
Copy link
Member

@georgeh0 georgeh0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most parts look good! Left one minor comment. Thanks!

Comment on lines +260 to +271
# Execute upserts
if rows_to_upsert:
context.namespace.write(
upsert_rows=rows_to_upsert,
distance_metric=context.distance_metric,
)

# Execute deletes
if ids_to_delete:
context.namespace.write(
deletes=ids_to_delete,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they support upserts and deletes happening in the same call, we can merge them, to make these mutations happen atomically.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @georgeh0 sorry for the late reply. i missed this comment. pushed a refactor

Combine the separate upsert and delete write() calls into a single
atomic call, since turbopuffer supports both upsert_rows and deletes
in the same write request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] support turbopuffer as target connector

3 participants