diff --git a/pyproject.toml b/pyproject.toml index 7b6efdc..551972f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "turbopuffer" -version = "0.1.23" +version = "0.1.24" description = "Python Client for accessing the turbopuffer API" authors = ["turbopuffer Inc. "] homepage = "https://turbopuffer.com" diff --git a/tests/test_backend.py b/tests/test_backend.py index 3576659..64814aa 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -27,7 +27,7 @@ def test_500_retried(): with mock.patch.object(time, 'sleep', return_value=None) as sleep: with pytest.raises(tpuf.error.APIError): - backend.make_api_request('vectors', payload={}) + backend.make_api_request('namespaces', payload={}) assert sleep.call_count == tpuf.max_retries - 1 @@ -38,5 +38,5 @@ def test_429_retried(): with mock.patch.object(time, 'sleep', return_value=None) as sleep: with pytest.raises(tpuf.error.APIError): - backend.make_api_request('vectors', payload={}) + backend.make_api_request('namespaces', payload={}) assert sleep.call_count == tpuf.max_retries - 1 diff --git a/turbopuffer/namespace.py b/turbopuffer/namespace.py index c72480b..7305ecc 100644 --- a/turbopuffer/namespace.py +++ b/turbopuffer/namespace.py @@ -112,7 +112,7 @@ def __eq__(self, other): return False def refresh_metadata(self): - response = self.backend.make_api_request('vectors', self.name, method='HEAD') + response = self.backend.make_api_request('namespaces', self.name, method='HEAD') status_code = response.get('status_code') if status_code == 200: headers = response.get('headers', dict()) @@ -170,7 +170,7 @@ def schema(self) -> NamespaceSchema: """ Returns the current schema for the namespace. """ - response = self.backend.make_api_request('vectors', self.name, 'schema', method='GET') + response = self.backend.make_api_request('namespaces', self.name, 'schema', method='GET') return parse_namespace_schema(response["content"]) def update_schema(self, schema_updates: NamespaceSchema): @@ -181,7 +181,7 @@ def update_schema(self, schema_updates: NamespaceSchema): See https://turbopuffer.com/docs/schema for specifics on allowed updates. """ request_payload = json.dumps({key: value.as_dict() for key, value in schema_updates.items()}).encode() - response = self.backend.make_api_request('vectors', self.name, 'schema', method='POST', payload=request_payload) + response = self.backend.make_api_request('namespaces', self.name, 'schema', method='POST', payload=request_payload) return parse_namespace_schema(response["content"]) @overload @@ -255,7 +255,7 @@ def upsert(self, data=None, ids=None, vectors=None, attributes=None, schema=None if schema is not None: payload["schema"] = schema - response = self.backend.make_api_request('vectors', self.name, payload=payload) + response = self.backend.make_api_request('namespaces', self.name, payload=payload) assert response.get('content', dict()).get('status', '') == 'OK', f'Invalid upsert() response: {response}' self.metadata = None # Invalidate cached metadata @@ -325,12 +325,12 @@ def delete(self, ids: Union[int, str, List[int], List[str]]) -> None: """ if isinstance(ids, int) or isinstance(ids, str): - response = self.backend.make_api_request('vectors', self.name, payload={ + response = self.backend.make_api_request('namespaces', self.name, payload={ 'ids': [ids], 'vectors': [None], }) elif isinstance(ids, list): - response = self.backend.make_api_request('vectors', self.name, payload={ + response = self.backend.make_api_request('namespaces', self.name, payload={ 'ids': ids, 'vectors': [None] * len(ids), }) @@ -391,7 +391,7 @@ def query(self, else: raise ValueError(f'query() input type must be compatible with turbopuffer.VectorQuery: {type(query_data)}') - response = self.backend.make_api_request('vectors', self.name, 'query', payload=query_data.__dict__) + response = self.backend.make_api_request('namespaces', self.name, 'query', payload=query_data.__dict__) result = VectorResult(response.get('content', dict()), namespace=self) result.performance = response.get('performance') return result @@ -404,7 +404,7 @@ def vectors(self, cursor: Optional[Cursor] = None) -> VectorResult: If you want to look up vectors by ID, use the query function with an id filter. """ - response = self.backend.make_api_request('vectors', self.name, query={'cursor': cursor}) + response = self.backend.make_api_request('namespaces', self.name, query={'cursor': cursor}) content = response.get('content', dict()) next_cursor = content.pop('next_cursor', None) result = VectorResult(content, namespace=self, next_cursor=next_cursor) @@ -416,7 +416,7 @@ def delete_all_indexes(self) -> None: Deletes all indexes in a namespace. """ - response = self.backend.make_api_request('vectors', self.name, 'index', method='DELETE') + response = self.backend.make_api_request('namespaces', self.name, 'index', method='DELETE') assert response.get('content', dict()).get('status', '') == 'ok', f'Invalid delete_all_indexes() response: {response}' def delete_all(self) -> None: @@ -424,7 +424,7 @@ def delete_all(self) -> None: Deletes all data as well as all indexes. """ - response = self.backend.make_api_request('vectors', self.name, method='DELETE') + response = self.backend.make_api_request('namespaces', self.name, method='DELETE') assert response.get('content', dict()).get('status', '') == 'ok', f'Invalid delete_all() response: {response}' self.metadata = None # Invalidate cached metadata @@ -438,7 +438,7 @@ def recall(self, num=20, top_k=10) -> float: Recall is calculated as the ratio of matching vectors between the two search results. """ - response = self.backend.make_api_request('vectors', self.name, '_debug', 'recall', query={'num': num, 'top_k': top_k}) + response = self.backend.make_api_request('namespaces', self.name, '_debug', 'recall', query={'num': num, 'top_k': top_k}) content = response.get('content', dict()) assert 'avg_recall' in content, f'Invalid recall() response: {response}' return float(content.get('avg_recall')) @@ -525,7 +525,7 @@ def __next__(self): raise StopIteration else: response = self.backend.make_api_request( - 'vectors', + 'namespaces', query={'cursor': self.next_cursor} ) content = response.get('content', dict()) @@ -542,7 +542,7 @@ def namespaces(api_key: Optional[str] = None) -> Iterable[Namespace]: If no api_key is provided, the globally configured API key will be used. """ backend = Backend(api_key) - response = backend.make_api_request('vectors') + response = backend.make_api_request('namespaces') content = response.get('content', dict()) next_cursor = content.pop('next_cursor', None) return NamespaceIterator(backend, content.pop('namespaces', list()), next_cursor) diff --git a/turbopuffer/version.py b/turbopuffer/version.py index 6f1ee1b..df95409 100644 --- a/turbopuffer/version.py +++ b/turbopuffer/version.py @@ -1 +1 @@ -VERSION = '0.1.23' +VERSION = '0.1.24'