dex-connector-pinecone 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. dex_connector_pinecone-0.1.0/.gitignore +6 -0
  2. dex_connector_pinecone-0.1.0/PKG-INFO +57 -0
  3. dex_connector_pinecone-0.1.0/README.md +46 -0
  4. dex_connector_pinecone-0.1.0/examples/sample_pinecone/__init__.py +3 -0
  5. dex_connector_pinecone-0.1.0/examples/sample_pinecone/flow.py +79 -0
  6. dex_connector_pinecone-0.1.0/examples/sample_pinecone/worker.py +51 -0
  7. dex_connector_pinecone-0.1.0/pyproject.toml +37 -0
  8. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/__init__.py +51 -0
  9. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/_generated/__init__.py +2 -0
  10. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/_generated/config.py +25 -0
  11. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/_generated/connection.py +139 -0
  12. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/_generated/definitions.py +55 -0
  13. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/_generated/mock.py +107 -0
  14. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/_generated/models.py +90 -0
  15. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/_generated/steps.py +131 -0
  16. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/client.py +411 -0
  17. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/connection.py +45 -0
  18. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/dex-connector.json +77 -0
  19. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/models.py +24 -0
  20. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/pineconemock/__init__.py +53 -0
  21. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/py.typed +0 -0
  22. dex_connector_pinecone-0.1.0/src/dex_connectors/pinecone/steps.py +40 -0
  23. dex_connector_pinecone-0.1.0/tests/test_conformance.py +59 -0
  24. dex_connector_pinecone-0.1.0/tests/test_manifest_contract.py +15 -0
  25. dex_connector_pinecone-0.1.0/tests/test_operations.py +234 -0
  26. dex_connector_pinecone-0.1.0/uv.lock +932 -0
@@ -0,0 +1,6 @@
1
+ /.dex-local/dexcli
2
+ /.dex-local/dex-server-zd
3
+ /.dex-local/data/
4
+ /.dex-local/cli.log
5
+ /.dex-local/visualize.json
6
+ /.dex-local/visualize.err
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.5
2
+ Name: dex-connector-pinecone
3
+ Version: 0.1.0
4
+ Summary: Pinecone connector for Dex Flows
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: dex-connectors-sdk==0.1.0
8
+ Requires-Dist: dex-python-sdk>=1.28.0
9
+ Requires-Dist: httpx>=0.27
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Pinecone connector for Python
13
+
14
+ Install with `pip install dex-connector-pinecone==0.1.0`. The package requires
15
+ `dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, and implements the
16
+ manifest operations `upsertVectors` (Mutation) and `queryVectors` (Query) with
17
+ the same branches, defaults, and failure classification as the Go module.
18
+
19
+ ## Operations
20
+
21
+ | Operation | Factory | Happy branch | Optional branches |
22
+ | --- | --- | --- | --- |
23
+ | `upsertVectors` | `new_upsert_vectors_step` | `upserted` | `providerRejected`, `invalidResponse`, `defect` |
24
+ | `queryVectors` | `new_query_vectors_step` | `queried` | `providerRejected`, `invalidResponse`, `defect` |
25
+
26
+ `upsertVectors` posts 1 through 1000 vectors with unique stable IDs to
27
+ `/vectors/upsert`; replacing by ID makes a retry safe. Coordinates are rounded
28
+ to 32-bit floats and written exactly as the Go module writes them. Only an
29
+ `upsertedCount` from zero through the batch size selects `upserted`.
30
+ `queryVectors` posts one dense vector and a `topK` from 1 through 10000 to
31
+ `/query` and returns Pinecone's JSON, which must contain a `matches` list,
32
+ untouched in `data`.
33
+
34
+ Both operations retry on 408, 409, 429, 5xx, and transport failures; other
35
+ non-200 statuses select `providerRejected` with authentication (401),
36
+ authorization (403), or validation (400, 422) kinds. Every request sends
37
+ `X-Pinecone-Api-Version: 2025-04`.
38
+
39
+ ## Authorization
40
+
41
+ Create a Dex Web connection named `pinecone` as described in the
42
+ [connector README](../README.md#authorization-and-configuration), with the
43
+ index host as `baseUrl`. The API key travels only in the `Api-Key` header and
44
+ is resolved for every attempt.
45
+
46
+ ## Example
47
+
48
+ [`examples/sample_pinecone`](examples/sample_pinecone/flow.py) upserts the start
49
+ input's vectors. Run the Worker with
50
+ `uv run python -m examples.sample_pinecone.worker` after `dexcli dev` has
51
+ loaded a project containing the `pinecone` connection.
52
+
53
+ ## Tests
54
+
55
+ `pineconemock.Mock` scripts both operations and defaults to the manifest
56
+ answers. Run `uv run pytest tests` for provider parity and manifest contract
57
+ checks.
@@ -0,0 +1,46 @@
1
+ # Pinecone connector for Python
2
+
3
+ Install with `pip install dex-connector-pinecone==0.1.0`. The package requires
4
+ `dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, and implements the
5
+ manifest operations `upsertVectors` (Mutation) and `queryVectors` (Query) with
6
+ the same branches, defaults, and failure classification as the Go module.
7
+
8
+ ## Operations
9
+
10
+ | Operation | Factory | Happy branch | Optional branches |
11
+ | --- | --- | --- | --- |
12
+ | `upsertVectors` | `new_upsert_vectors_step` | `upserted` | `providerRejected`, `invalidResponse`, `defect` |
13
+ | `queryVectors` | `new_query_vectors_step` | `queried` | `providerRejected`, `invalidResponse`, `defect` |
14
+
15
+ `upsertVectors` posts 1 through 1000 vectors with unique stable IDs to
16
+ `/vectors/upsert`; replacing by ID makes a retry safe. Coordinates are rounded
17
+ to 32-bit floats and written exactly as the Go module writes them. Only an
18
+ `upsertedCount` from zero through the batch size selects `upserted`.
19
+ `queryVectors` posts one dense vector and a `topK` from 1 through 10000 to
20
+ `/query` and returns Pinecone's JSON, which must contain a `matches` list,
21
+ untouched in `data`.
22
+
23
+ Both operations retry on 408, 409, 429, 5xx, and transport failures; other
24
+ non-200 statuses select `providerRejected` with authentication (401),
25
+ authorization (403), or validation (400, 422) kinds. Every request sends
26
+ `X-Pinecone-Api-Version: 2025-04`.
27
+
28
+ ## Authorization
29
+
30
+ Create a Dex Web connection named `pinecone` as described in the
31
+ [connector README](../README.md#authorization-and-configuration), with the
32
+ index host as `baseUrl`. The API key travels only in the `Api-Key` header and
33
+ is resolved for every attempt.
34
+
35
+ ## Example
36
+
37
+ [`examples/sample_pinecone`](examples/sample_pinecone/flow.py) upserts the start
38
+ input's vectors. Run the Worker with
39
+ `uv run python -m examples.sample_pinecone.worker` after `dexcli dev` has
40
+ loaded a project containing the `pinecone` connection.
41
+
42
+ ## Tests
43
+
44
+ `pineconemock.Mock` scripts both operations and defaults to the manifest
45
+ answers. Run `uv run pytest tests` for provider parity and manifest contract
46
+ checks.
@@ -0,0 +1,3 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Pinecone sample example Flow."""
@@ -0,0 +1,79 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Runnable Pinecone sample Flow using the upsertVectors Mutation."""
4
+
5
+ import dex
6
+ from dex_connectors.sdk import MutationResult
7
+
8
+ from dex_connectors.pinecone import (
9
+ Connection,
10
+ UpsertVectorsInput,
11
+ UpsertVectorsOutput,
12
+ new_upsert_vectors_step,
13
+ )
14
+
15
+ FLOW_TYPE = "PineconeSample"
16
+ CONNECTION_NAME = "pinecone"
17
+ _CALL_STEP_TYPE = "CallPinecone"
18
+ _RESULT = dex.Attribute("pinecone-sample-result", UpsertVectorsOutput)
19
+
20
+
21
+ def map_to_operation_input(request: UpsertVectorsInput) -> UpsertVectorsInput:
22
+ """Pass the validated Flow request to the connector."""
23
+ return request
24
+
25
+
26
+ # dex:group group-id:pinecone-start group-label:"Pinecone sample"
27
+ # dex:explanation text:"Pass the start input to the connector operation."
28
+ class _StartRequest(dex.Step[UpsertVectorsInput]):
29
+ def get_step_type(self) -> str:
30
+ return "StartPineconeRequest"
31
+
32
+ def execute(self, context: dex.Context, input: UpsertVectorsInput) -> dex.StepDecision:
33
+ return dex.go_to(dex.StepRef(_CALL_STEP_TYPE), input)
34
+
35
+
36
+ # dex:group group-id:pinecone-complete group-label:"Pinecone sample"
37
+ # dex:explanation text:"Complete the Flow with the provider response."
38
+ class _CompleteRequest(dex.Step[MutationResult[UpsertVectorsOutput]]):
39
+ def get_step_type(self) -> str:
40
+ return "CompletePineconeRequest"
41
+
42
+ def execute(self, context: dex.Context, input: MutationResult[UpsertVectorsOutput]) -> dex.StepDecision:
43
+ _RESULT.set(context, input.value)
44
+ return dex.graceful_complete(input.value)
45
+
46
+
47
+ class SampleFlow(dex.Flow[UpsertVectorsInput]):
48
+ """Run one upsertVectors write through the static pinecone connection."""
49
+
50
+ def __init__(self, connection: Connection) -> None:
51
+ if connection.reference.name != CONNECTION_NAME:
52
+ raise ValueError("the sample requires the static pinecone connection")
53
+ self._start = _StartRequest()
54
+ self._complete = _CompleteRequest()
55
+ self._call = new_upsert_vectors_step(
56
+ step_type=_CALL_STEP_TYPE,
57
+ step_input_type=UpsertVectorsInput,
58
+ annotations={
59
+ "groupId": "pinecone",
60
+ "groupLabel": "Pinecone",
61
+ "explanation": "Upsert vector IDs by absolute replacement in one namespace.",
62
+ },
63
+ connection=connection,
64
+ connection_name=CONNECTION_NAME,
65
+ map_to_operation_input=map_to_operation_input,
66
+ upserted=self._complete,
67
+ )
68
+
69
+ def get_flow_type(self) -> str:
70
+ """Return the stable Flow identity used in Dex Web."""
71
+ return FLOW_TYPE
72
+
73
+ def get_steps(self) -> dex.StepList[UpsertVectorsInput]:
74
+ """Register the start, provider write, and completion Steps."""
75
+ return dex.StepList.start_step(self._start).other_steps(self._call, self._complete)
76
+
77
+ def get_persistence_schema(self) -> dex.PersistenceSchema:
78
+ """Persist the provider result."""
79
+ return dex.PersistenceSchema.of(_RESULT)
@@ -0,0 +1,51 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Worker entrypoint for the Pinecone sample Flow."""
4
+
5
+ import asyncio
6
+ import os
7
+ import tempfile
8
+ from pathlib import Path
9
+
10
+ import dex
11
+ from dex_connectors.sdk.projectconfig import load_from_environment
12
+
13
+ from dex_connectors.pinecone import new_project_connection
14
+
15
+ from .flow import CONNECTION_NAME, SampleFlow
16
+
17
+
18
+ async def run_worker() -> None:
19
+ """Load the named Dex Web connection and upsert vectors."""
20
+ project = await load_from_environment()
21
+ connection = None
22
+ cache = None
23
+ try:
24
+ connection = new_project_connection(project, CONNECTION_NAME)
25
+ registry = dex.Registry([SampleFlow(connection)], allow_async_handlers=True)
26
+ cache_directory = os.environ.get(
27
+ "DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-pinecone-sample-blobs")
28
+ )
29
+ cache = dex.open_blob_cache(dex.BlobCacheConfig(cache_directory, 1 << 30))
30
+ worker = dex.AsyncWorker(
31
+ registry,
32
+ cache,
33
+ dex.WorkerOptions(server_address=os.environ.get("DEX_FLOW_SERVICE_ADDRESS", "localhost:8801")),
34
+ )
35
+ async with worker:
36
+ await worker.start()
37
+ finally:
38
+ if connection is not None:
39
+ await connection.aclose()
40
+ if cache is not None:
41
+ cache.close()
42
+ await project.close()
43
+
44
+
45
+ def main() -> None:
46
+ """Run until the Worker stops or the process receives an interrupt."""
47
+ asyncio.run(run_worker())
48
+
49
+
50
+ if __name__ == "__main__":
51
+ main()
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dex-connector-pinecone"
7
+ version = "0.1.0"
8
+ description = "Pinecone connector for Dex Flows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ dependencies = ["dex-connectors-sdk==0.1.0", "dex-python-sdk>=1.28.0", "httpx>=0.27"]
13
+
14
+ [dependency-groups]
15
+ dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7", "pyyaml>=6", "types-PyYAML>=6"]
16
+
17
+ [tool.hatch.build.targets.wheel]
18
+ packages = ["src/dex_connectors"]
19
+
20
+ [tool.pytest.ini_options]
21
+ testpaths = ["tests"]
22
+ pythonpath = [".", "src"]
23
+ asyncio_mode = "auto"
24
+ asyncio_default_fixture_loop_scope = "function"
25
+
26
+ [tool.mypy]
27
+ python_version = "3.11"
28
+ strict = true
29
+ mypy_path = "src"
30
+ explicit_package_bases = true
31
+
32
+ [tool.ruff]
33
+ target-version = "py311"
34
+ line-length = 110
35
+
36
+ [tool.ruff.lint]
37
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,51 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Pinecone vector upsert and query operations for Dex connector Steps."""
4
+
5
+ from .client import (
6
+ API_VERSION,
7
+ CONNECTOR_ID,
8
+ DEFECT,
9
+ INVALID_RESPONSE,
10
+ PROVIDER_REJECTED,
11
+ QUERIED,
12
+ QUERY_VECTORS_DEFINITION,
13
+ UPSERT_VECTORS_DEFINITION,
14
+ UPSERTED,
15
+ Client,
16
+ Config,
17
+ Credentials,
18
+ QueryVectorsOperation,
19
+ UpsertVectorsOperation,
20
+ )
21
+ from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
22
+ from .models import QueryVectorsInput, QueryVectorsOutput, UpsertVectorsInput, UpsertVectorsOutput, Vector
23
+ from .steps import new_query_vectors_step, new_upsert_vectors_step
24
+
25
+ __all__ = [
26
+ "Client",
27
+ "Config",
28
+ "Connection",
29
+ "Credentials",
30
+ "QueryVectorsInput",
31
+ "QueryVectorsOperation",
32
+ "QueryVectorsOutput",
33
+ "UpsertVectorsInput",
34
+ "UpsertVectorsOperation",
35
+ "UpsertVectorsOutput",
36
+ "Vector",
37
+ "new_connection",
38
+ "new_connection_with_operations",
39
+ "new_project_connection",
40
+ "new_query_vectors_step",
41
+ "new_upsert_vectors_step",
42
+ "API_VERSION",
43
+ "CONNECTOR_ID",
44
+ "DEFECT",
45
+ "INVALID_RESPONSE",
46
+ "PROVIDER_REJECTED",
47
+ "QUERIED",
48
+ "QUERY_VECTORS_DEFINITION",
49
+ "UPSERT_VECTORS_DEFINITION",
50
+ "UPSERTED",
51
+ ]
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from dataclasses import dataclass
6
+
7
+ from dex_connectors.sdk import SecretString
8
+
9
+
10
+ @dataclass(frozen=True, slots=True)
11
+ class Config:
12
+
13
+ base_url: str
14
+ timeout_seconds: float = 15
15
+ max_response_bytes: int = 2097152
16
+
17
+ setattr(Config, '__module__', 'dex_connectors.pinecone.client')
18
+
19
+
20
+ @dataclass(frozen=True, slots=True)
21
+ class Credentials:
22
+
23
+ api_key: SecretString
24
+
25
+ setattr(Credentials, '__module__', 'dex_connectors.pinecone.client')
@@ -0,0 +1,139 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+ from dex_connectors.sdk import ConnectionRef, Mutation, Query, Call, SecretString
9
+ from dex_connectors.sdk.projectconfig import ConnectionKey, LoadedProject
10
+
11
+ from ..client import Client, Config, Credentials
12
+ from .definitions import CONNECTOR_ID, QUERY_VECTORS_DEFINITION, UPSERT_VECTORS_DEFINITION
13
+ from ..models import QueryVectorsInput, QueryVectorsOutput, UpsertVectorsInput, UpsertVectorsOutput
14
+
15
+ class Connection:
16
+
17
+ __slots__ = ('_upsert_vectors', '_query_vectors', '_client', 'reference')
18
+
19
+ def __init__(self,
20
+ reference: ConnectionRef,
21
+ upsert_vectors: Mutation[UpsertVectorsInput, UpsertVectorsOutput],
22
+ query_vectors: Query[QueryVectorsInput, QueryVectorsOutput],
23
+ client: Client | None = None,
24
+ ) -> None:
25
+ reference.validate()
26
+ if reference.provider != CONNECTOR_ID or upsert_vectors is None or query_vectors is None:
27
+ raise ValueError("Pinecone connection provider and operations are required")
28
+ if upsert_vectors.definition().operation != UPSERT_VECTORS_DEFINITION.operation:
29
+ raise ValueError("Pinecone connection operation identity differs")
30
+ if query_vectors.definition().operation != QUERY_VECTORS_DEFINITION.operation:
31
+ raise ValueError("Pinecone connection operation identity differs")
32
+ self.reference = reference
33
+ self._upsert_vectors = upsert_vectors
34
+ self._query_vectors = query_vectors
35
+ self._client = client
36
+
37
+ def upsert_vectors(self) -> Mutation[UpsertVectorsInput, UpsertVectorsOutput]:
38
+ return self._upsert_vectors
39
+
40
+ def query_vectors(self) -> Query[QueryVectorsInput, QueryVectorsOutput]:
41
+ return self._query_vectors
42
+
43
+ async def aclose(self) -> None:
44
+ if self._client is not None:
45
+ await self._client.aclose()
46
+
47
+ def __repr__(self) -> str:
48
+ return "pinecone.Connection([REDACTED])"
49
+
50
+ def __reduce__(self) -> tuple[object, ...]:
51
+ raise TypeError("Pinecone connections cannot be serialized")
52
+
53
+ setattr(Connection, '__module__', 'dex_connectors.pinecone.connection')
54
+
55
+
56
+ def new_connection(client: Client, reference: ConnectionRef) -> Connection:
57
+ if client is None:
58
+ raise ValueError("Pinecone client is required")
59
+ return Connection(reference, client.upsert_vectors(), client.query_vectors(), client)
60
+
61
+ setattr(new_connection, '__module__', 'dex_connectors.pinecone.connection')
62
+
63
+
64
+ def new_connection_with_operations(
65
+ upsert_vectors: Mutation[UpsertVectorsInput, UpsertVectorsOutput],
66
+ query_vectors: Query[QueryVectorsInput, QueryVectorsOutput],
67
+ reference: ConnectionRef,
68
+ ) -> Connection:
69
+ return Connection(reference, upsert_vectors, query_vectors)
70
+
71
+ setattr(new_connection_with_operations, '__module__', 'dex_connectors.pinecone.connection')
72
+
73
+
74
+ class _ProjectCredentialSource:
75
+
76
+ def __init__(self, project: LoadedProject, key: ConnectionKey) -> None:
77
+ self.project = project
78
+ self.key = key
79
+
80
+ async def resolve(self, call: Call) -> Credentials:
81
+ material = await self.project.resolve_credential(self.key, str(call.id))
82
+ if not isinstance(material, dict):
83
+ raise ValueError("Pinecone stored credential does not match the connector credential fields")
84
+ if set(material) - set(('api_key',)):
85
+ raise ValueError("Pinecone stored credential does not match the connector credential fields")
86
+ api_key = material.get("api_key")
87
+ if api_key is not None and not (isinstance(api_key, str)):
88
+ raise ValueError("Pinecone credential api_key has an invalid type")
89
+ if not api_key:
90
+ raise ValueError("Pinecone credential api_key is required")
91
+ return Credentials(SecretString(api_key))
92
+
93
+
94
+ def new_project_connection(
95
+ project: LoadedProject, connection_name: str, http_client: httpx.AsyncClient | None = None
96
+ ) -> Connection:
97
+ if project is None:
98
+ raise ValueError("Pinecone connection requires loaded project configuration")
99
+ reference = ConnectionRef(CONNECTOR_ID, connection_name)
100
+ reference.validate()
101
+ key = ConnectionKey(CONNECTOR_ID, connection_name)
102
+ matching = [
103
+ entry
104
+ for entry in project.configuration.connections
105
+ if entry.connector_id == CONNECTOR_ID and entry.connection_name == connection_name
106
+ ]
107
+ if len(matching) != 1:
108
+ raise ValueError("Pinecone project connection is missing or duplicated")
109
+ if matching[0].provider != CONNECTOR_ID:
110
+ raise ValueError("Pinecone project connection provider differs")
111
+ config = _decode_config(matching[0].configuration)
112
+ client = Client(config, _ProjectCredentialSource(project, key), http_client)
113
+ return new_connection(client, reference)
114
+
115
+ setattr(new_project_connection, '__module__', 'dex_connectors.pinecone.connection')
116
+
117
+
118
+ def _decode_config(value: dict[str, Any]) -> Config:
119
+ if set(value) - {"baseUrl", "timeout", "maxResponseBytes"}:
120
+ raise ValueError("Pinecone configuration has unknown fields")
121
+ config_arguments: dict[str, Any] = {}
122
+ if "baseUrl" in value:
123
+ base_url = value["baseUrl"]
124
+ if not (isinstance(base_url, str)):
125
+ raise ValueError("Pinecone configuration baseUrl has an invalid type")
126
+ config_arguments['base_url'] = base_url
127
+ else:
128
+ raise ValueError("Pinecone configuration baseUrl is required")
129
+ if "timeout" in value:
130
+ timeout = value["timeout"]
131
+ if not (type(timeout) is int):
132
+ raise ValueError("Pinecone configuration timeout has an invalid type")
133
+ config_arguments['timeout_seconds'] = timeout / 1_000_000_000
134
+ if "maxResponseBytes" in value:
135
+ max_response_bytes = value["maxResponseBytes"]
136
+ if not (type(max_response_bytes) is int):
137
+ raise ValueError("Pinecone configuration maxResponseBytes has an invalid type")
138
+ config_arguments['max_response_bytes'] = max_response_bytes
139
+ return Config(**config_arguments)
@@ -0,0 +1,55 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from datetime import timedelta
6
+
7
+ from dex_connectors.sdk import (
8
+ BranchDefinition,
9
+ MutationDefinition,
10
+ OperationRef,
11
+ QueryDefinition,
12
+ RetryPolicy,
13
+ StepDefaults,
14
+ default_connector_step_execute_retry_policy,
15
+ )
16
+
17
+ CONNECTOR_ID = "pinecone"
18
+ PROVIDER = "pinecone"
19
+ UPSERT_VECTORS_OPERATION_ID = "upsertVectors"
20
+ QUERY_VECTORS_OPERATION_ID = "queryVectors"
21
+ DEFECT = "defect"
22
+ INVALID_RESPONSE = "invalidResponse"
23
+ PROVIDER_REJECTED = "providerRejected"
24
+ QUERIED = "queried"
25
+ UPSERTED = "upserted"
26
+
27
+ UPSERT_VECTORS_DEFINITION = MutationDefinition(
28
+ OperationRef(CONNECTOR_ID, UPSERT_VECTORS_OPERATION_ID),
29
+ (
30
+ BranchDefinition(UPSERTED, "Upsert vector IDs by absolute replacement in one namespace.", False),
31
+ BranchDefinition(PROVIDER_REJECTED, "The provider conclusively rejected the request or credentials.", True),
32
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
33
+ BranchDefinition(DEFECT, "Local input, configuration, or credentials are invalid.", True),
34
+ ),
35
+ StepDefaults(
36
+ timedelta(seconds=30),
37
+ 2,
38
+ execute_retry=default_connector_step_execute_retry_policy(),
39
+ ),
40
+ )
41
+
42
+ QUERY_VECTORS_DEFINITION = QueryDefinition(
43
+ OperationRef(CONNECTOR_ID, QUERY_VECTORS_OPERATION_ID),
44
+ (
45
+ BranchDefinition(QUERIED, "Find nearest vectors in one namespace.", False),
46
+ BranchDefinition(PROVIDER_REJECTED, "The provider conclusively rejected the request or credentials.", True),
47
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
48
+ BranchDefinition(DEFECT, "Local input, configuration, or credentials are invalid.", True),
49
+ ),
50
+ StepDefaults(
51
+ timedelta(seconds=30),
52
+ 2,
53
+ execute_retry=default_connector_step_execute_retry_policy(),
54
+ ),
55
+ )
@@ -0,0 +1,107 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from datetime import datetime
6
+
7
+ from dex_connectors.sdk import ConnectionRef, Failure, FailureKind
8
+ from dex_connectors.sdk.connectormock import Case, Mutation, Query
9
+
10
+ from ..connection import Connection, new_connection_with_operations
11
+ from ..models import QueryVectorsInput, QueryVectorsOutput, UpsertVectorsInput, UpsertVectorsOutput, Vector
12
+ from .definitions import CONNECTOR_ID, DEFECT, INVALID_RESPONSE, PROVIDER_REJECTED, QUERIED, QUERY_VECTORS_DEFINITION, UPSERTED, UPSERT_VECTORS_DEFINITION
13
+
14
+ def upsert_vectors_upserted(value: UpsertVectorsOutput, failure: Failure | None = None) -> Case[UpsertVectorsOutput]:
15
+ return Case.branch_result(UPSERTED, value, failure)
16
+
17
+ setattr(upsert_vectors_upserted, '__module__', "dex_connectors.pinecone.pineconemock")
18
+
19
+ def upsert_vectors_provider_rejected(value: UpsertVectorsOutput, failure: Failure | None = None) -> Case[UpsertVectorsOutput]:
20
+ return Case.branch_result(PROVIDER_REJECTED, value, failure)
21
+
22
+ setattr(upsert_vectors_provider_rejected, '__module__', "dex_connectors.pinecone.pineconemock")
23
+
24
+ def upsert_vectors_invalid_response(value: UpsertVectorsOutput, failure: Failure | None = None) -> Case[UpsertVectorsOutput]:
25
+ return Case.branch_result(INVALID_RESPONSE, value, failure)
26
+
27
+ setattr(upsert_vectors_invalid_response, '__module__', "dex_connectors.pinecone.pineconemock")
28
+
29
+ def upsert_vectors_defect(value: UpsertVectorsOutput, failure: Failure | None = None) -> Case[UpsertVectorsOutput]:
30
+ return Case.branch_result(DEFECT, value, failure)
31
+
32
+ setattr(upsert_vectors_defect, '__module__', "dex_connectors.pinecone.pineconemock")
33
+
34
+ def upsert_vectors_retry(failure: Failure, after_seconds: float = 0) -> Case[UpsertVectorsOutput]:
35
+ return Case.retry(failure, after_seconds)
36
+
37
+ setattr(upsert_vectors_retry, '__module__', "dex_connectors.pinecone.pineconemock")
38
+
39
+ def upsert_vectors_default_upsert_vectors() -> Case[UpsertVectorsOutput]:
40
+ return Case.branch_result(UPSERTED, UpsertVectorsOutput(upserted_count=1))
41
+
42
+ setattr(upsert_vectors_default_upsert_vectors, '__module__', "dex_connectors.pinecone.pineconemock")
43
+
44
+ def query_vectors_queried(value: QueryVectorsOutput, failure: Failure | None = None) -> Case[QueryVectorsOutput]:
45
+ return Case.branch_result(QUERIED, value, failure)
46
+
47
+ setattr(query_vectors_queried, '__module__', "dex_connectors.pinecone.pineconemock")
48
+
49
+ def query_vectors_provider_rejected(value: QueryVectorsOutput, failure: Failure | None = None) -> Case[QueryVectorsOutput]:
50
+ return Case.branch_result(PROVIDER_REJECTED, value, failure)
51
+
52
+ setattr(query_vectors_provider_rejected, '__module__', "dex_connectors.pinecone.pineconemock")
53
+
54
+ def query_vectors_invalid_response(value: QueryVectorsOutput, failure: Failure | None = None) -> Case[QueryVectorsOutput]:
55
+ return Case.branch_result(INVALID_RESPONSE, value, failure)
56
+
57
+ setattr(query_vectors_invalid_response, '__module__', "dex_connectors.pinecone.pineconemock")
58
+
59
+ def query_vectors_defect(value: QueryVectorsOutput, failure: Failure | None = None) -> Case[QueryVectorsOutput]:
60
+ return Case.branch_result(DEFECT, value, failure)
61
+
62
+ setattr(query_vectors_defect, '__module__', "dex_connectors.pinecone.pineconemock")
63
+
64
+ def query_vectors_retry(failure: Failure, after_seconds: float = 0) -> Case[QueryVectorsOutput]:
65
+ return Case.retry(failure, after_seconds)
66
+
67
+ setattr(query_vectors_retry, '__module__', "dex_connectors.pinecone.pineconemock")
68
+
69
+ def query_vectors_default_query_vectors() -> Case[QueryVectorsOutput]:
70
+ return Case.branch_result(QUERIED, QueryVectorsOutput(data={'matches': [{'id': 'vec-meridian', 'score': 0.98}], 'namespace': 'example'}))
71
+
72
+ setattr(query_vectors_default_query_vectors, '__module__', "dex_connectors.pinecone.pineconemock")
73
+
74
+
75
+ class Mock:
76
+
77
+ def __init__(self, connection_name: str = "pinecone") -> None:
78
+ self.upsert_vectors_script: Mutation[UpsertVectorsInput, UpsertVectorsOutput] = Mutation(UPSERT_VECTORS_DEFINITION)
79
+ self.upsert_vectors_script.default(upsert_vectors_default_upsert_vectors())
80
+ self.query_vectors_script: Query[QueryVectorsInput, QueryVectorsOutput] = Query(QUERY_VECTORS_DEFINITION)
81
+ self.query_vectors_script.default(query_vectors_default_query_vectors())
82
+ self._connection = new_connection_with_operations(
83
+ upsert_vectors=self.upsert_vectors_script,
84
+ query_vectors=self.query_vectors_script,
85
+ reference=ConnectionRef(CONNECTOR_ID, connection_name),
86
+ )
87
+
88
+ def connection(self) -> Connection:
89
+ return self._connection
90
+
91
+ setattr(Mock, '__module__', "dex_connectors.pinecone.pineconemock")
92
+
93
+ __all__ = [
94
+ "Mock",
95
+ "upsert_vectors_upserted",
96
+ "upsert_vectors_provider_rejected",
97
+ "upsert_vectors_invalid_response",
98
+ "upsert_vectors_defect",
99
+ "upsert_vectors_retry",
100
+ "upsert_vectors_default_upsert_vectors",
101
+ "query_vectors_queried",
102
+ "query_vectors_provider_rejected",
103
+ "query_vectors_invalid_response",
104
+ "query_vectors_defect",
105
+ "query_vectors_retry",
106
+ "query_vectors_default_query_vectors",
107
+ ]