Skip to content

Commit e86138c

Browse files
committed
refactor(targets): rename storages to targets for remaining code
1 parent d0c893b commit e86138c

File tree

24 files changed

+37
-34
lines changed

24 files changed

+37
-34
lines changed

docs/docs/getting_started/quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ from pgvector.psycopg import register_vector
214214
215215
def search(pool: ConnectionPool, query: str, top_k: int = 5):
216216
# Get the table name, for the export target in the text_embedding_flow above.
217-
table_name = cocoindex.utils.get_target_storage_default_name(text_embedding_flow, "doc_embeddings")
217+
table_name = cocoindex.utils.get_target_default_name(text_embedding_flow, "doc_embeddings")
218218
# Evaluate the transform flow defined above with the input query, to get the embedding.
219219
query_vector = text_to_embedding.eval(query)
220220
# Run the query and get the results.
@@ -237,7 +237,7 @@ There're two CocoIndex-specific logic:
237237
1. Get the table name from the export target in the `text_embedding_flow` above.
238238
Since the table name for the `Postgres` target is not explicitly specified in the `export()` call,
239239
CocoIndex uses a default name.
240-
`cocoindex.utils.get_target_storage_default_name()` is a utility function to get the default table name for this case.
240+
`cocoindex.utils.get_target_default_name()` is a utility function to get the default table name for this case.
241241
242242
2. Evaluate the transform flow defined above with the input query, to get the embedding.
243243
It's done by the `eval()` method of the transform flow `text_to_embedding`.

docs/docs/query.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ print(await text_to_embedding.eval_async("Hello, world!"))
8080

8181
In your indexing flow, when you export data to a target, you can specify the target name (e.g. a database table name, a collection name, the node label in property graph databases, etc.) explicitly,
8282
or for some backends you can also omit it and let CocoIndex generate a default name for you.
83-
For the latter case, CocoIndex provides a utility function `cocoindex.utils.get_target_storage_default_name()` to get the default name.
83+
For the latter case, CocoIndex provides a utility function `cocoindex.utils.get_target_default_name()` to get the default name.
8484
It takes the following arguments:
8585

8686
* `flow` (type: `cocoindex.Flow`): The flow to get the default name for.
@@ -92,7 +92,7 @@ For example:
9292
<TabItem value="python" label="Python">
9393

9494
```python
95-
table_name = cocoindex.utils.get_target_storage_default_name(text_embedding_flow, "doc_embeddings")
95+
table_name = cocoindex.utils.get_target_default_name(text_embedding_flow, "doc_embeddings")
9696
query = f"SELECT filename, text FROM {table_name} ORDER BY embedding <=> %s DESC LIMIT 5"
9797
...
9898
```

examples/amazon_s3_embedding/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def amazon_s3_text_embedding_flow(
7474

7575
def search(pool: ConnectionPool, query: str, top_k: int = 5):
7676
# Get the table name, for the export target in the amazon_s3_text_embedding_flow above.
77-
table_name = cocoindex.utils.get_target_storage_default_name(
77+
table_name = cocoindex.utils.get_target_default_name(
7878
amazon_s3_text_embedding_flow, "doc_embeddings"
7979
)
8080
# Evaluate the transform flow defined above with the input query, to get the embedding.

examples/code_embedding/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def code_embedding_flow(
7373

7474
def search(pool: ConnectionPool, query: str, top_k: int = 5):
7575
# Get the table name, for the export target in the code_embedding_flow above.
76-
table_name = cocoindex.utils.get_target_storage_default_name(
76+
table_name = cocoindex.utils.get_target_default_name(
7777
code_embedding_flow, "code_embeddings"
7878
)
7979
# Evaluate the transform flow defined above with the input query, to get the embedding.

examples/fastapi_server_docker/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def markdown_embedding_flow(
6767

6868
def search(pool: ConnectionPool, query: str, top_k: int = 5):
6969
# Get the table name, for the export target in the text_embedding_flow above.
70-
table_name = cocoindex.utils.get_target_storage_default_name(
70+
table_name = cocoindex.utils.get_target_default_name(
7171
markdown_embedding_flow, "doc_embeddings"
7272
)
7373
# Evaluate the transform flow defined above with the input query, to get the embedding.

examples/gdrive_text_embedding/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def gdrive_text_embedding_flow(
7373

7474
def search(pool: ConnectionPool, query: str, top_k: int = 5):
7575
# Get the table name, for the export target in the gdrive_text_embedding_flow above.
76-
table_name = cocoindex.utils.get_target_storage_default_name(
76+
table_name = cocoindex.utils.get_target_default_name(
7777
gdrive_text_embedding_flow, "doc_embeddings"
7878
)
7979
# Evaluate the transform flow defined above with the input query, to get the embedding.

examples/pdf_embedding/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def pdf_embedding_flow(
9999

100100
def search(pool: ConnectionPool, query: str, top_k: int = 5):
101101
# Get the table name, for the export target in the pdf_embedding_flow above.
102-
table_name = cocoindex.utils.get_target_storage_default_name(
102+
table_name = cocoindex.utils.get_target_default_name(
103103
pdf_embedding_flow, "pdf_embeddings"
104104
)
105105
# Evaluate the transform flow defined above with the input query, to get the embedding.

examples/text_embedding/Text_Embedding.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
"\n",
273273
"def search(pool: ConnectionPool, query: str, top_k: int = 5):\n",
274274
" # Get the table name, for the export target in the text_embedding_flow above.\n",
275-
" table_name = cocoindex.utils.get_target_storage_default_name(text_embedding_flow, \"doc_embeddings\")\n",
275+
" table_name = cocoindex.utils.get_target_default_name(text_embedding_flow, \"doc_embeddings\")\n",
276276
" # Evaluate the transform flow defined above with the input query, to get the embedding.\n",
277277
" query_vector = text_to_embedding.eval(query)\n",
278278
" # Run the query and get the results.\n",

examples/text_embedding/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def text_embedding_flow(
6767

6868
def search(pool: ConnectionPool, query: str, top_k: int = 5):
6969
# Get the table name, for the export target in the text_embedding_flow above.
70-
table_name = cocoindex.utils.get_target_storage_default_name(
70+
table_name = cocoindex.utils.get_target_default_name(
7171
text_embedding_flow, "doc_embeddings"
7272
)
7373
# Evaluate the transform flow defined above with the input query, to get the embedding.

python/cocoindex/flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def collect(self, **kwargs: Any) -> None:
327327
def export(
328328
self,
329329
name: str,
330-
target_spec: op.StorageSpec,
330+
target_spec: op.TargetSpec,
331331
/,
332332
*,
333333
primary_key_fields: Sequence[str],
@@ -340,7 +340,7 @@ def export(
340340
341341
`vector_index` is for backward compatibility only. Please use `vector_indexes` instead.
342342
"""
343-
if not isinstance(target_spec, op.StorageSpec):
343+
if not isinstance(target_spec, op.TargetSpec):
344344
raise ValueError(
345345
"export() can only be called on a CocoIndex target storage"
346346
)

0 commit comments

Comments
 (0)