Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Commit d231f38

Browse files
authored
refactor: rename Document to Doc (#1293)
* refactor: rename document to doc Signed-off-by: samsja <sami.jaghouar@hotmail.fr> * refactor: rename document to doc in da Signed-off-by: samsja <sami.jaghouar@hotmail.fr> * refactor: rename base doc in md files Signed-off-by: samsja <sami.jaghouar@hotmail.fr> * refactor: rename base base document ot base doc Signed-off-by: samsja <sami.jaghouar@hotmail.fr> * fix(docs): fix docs building Signed-off-by: samsja <sami.jaghouar@hotmail.fr> * fix: ingore hubble test Signed-off-by: samsja <sami.jaghouar@hotmail.fr> * fix: ingore hubble test Signed-off-by: samsja <sami.jaghouar@hotmail.fr> --------- Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
1 parent 6cd05f8 commit d231f38

158 files changed

Lines changed: 1596 additions & 1649 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
poetry install --without dev
6262
poetry run pip install tensorflow==2.11.0
6363
- name: Test basic import
64-
run: poetry run python -c 'from docarray import DocumentArray, BaseDocument'
64+
run: poetry run python -c 'from docarray import DocArray, BaseDoc'
6565

6666

6767
check-mypy:

‎README.md‎

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ This means that DocArray lets you do the following things:
1515
## Represent
1616

1717
```python
18-
from docarray import BaseDocument
18+
from docarray import BaseDoc
1919
from docarray.typing import TorchTensor, ImageUrl
2020
from typing import Optional
2121

2222

23-
class MyDocument(BaseDocument):
23+
class MyDocument(BaseDoc):
2424
description: str
2525
image_url: ImageUrl
2626
image_tensor: Optional[TorchTensor[1704, 2272, 3]]
@@ -62,12 +62,12 @@ doc.embedding = clip_image_encoder(
6262
### Compose nested Documents:
6363

6464
```python
65-
from docarray import BaseDocument
65+
from docarray import BaseDoc
6666
from docarray.documents import ImageDoc, TextDoc
6767
import numpy as np
6868

6969

70-
class MultiModalDocument(BaseDocument):
70+
class MultiModalDocument(BaseDoc):
7171
image_doc: ImageDoc
7272
text_doc: TextDoc
7373

@@ -77,22 +77,22 @@ doc = MultiModalDocument(
7777
)
7878
```
7979

80-
### Collect multiple `Documents` into a `DocumentArray`:
80+
### Collect multiple `Documents` into a `DocArray`:
8181
```python
82-
from docarray import DocumentArray, BaseDocument
82+
from docarray import DocArray, BaseDoc
8383
from docarray.typing import AnyTensor, ImageUrl
8484
import numpy as np
8585

8686

87-
class Image(BaseDocument):
87+
class Image(BaseDoc):
8888
url: ImageUrl
8989
tensor: AnyTensor
9090
```
9191

9292
```python
93-
from docarray import DocumentArray
93+
from docarray import DocArray
9494

95-
da = DocumentArray[Image](
95+
da = DocArray[Image](
9696
[
9797
Image(
9898
url="https://upload.wikimedia.org/wikipedia/commons/2/2f/Alpamayo.jpg",
@@ -103,7 +103,7 @@ da = DocumentArray[Image](
103103
)
104104
```
105105

106-
Access fields at the DocumentArray level:
106+
Access fields at the DocArray level:
107107

108108
```python
109109
print(len(da.tensor))
@@ -122,7 +122,7 @@ print(da.tensor.shape)
122122
```
123123

124124
## Send
125-
- **Serialize** any `Document` or `DocumentArray` into _protobuf_, _json_, _jsonschema_, _bytes_ or _base64_
125+
- **Serialize** any `Document` or `DocArray` into _protobuf_, _json_, _jsonschema_, _bytes_ or _base64_
126126
- Use in **microservice** architecture: Send over **HTTP** or **gRPC**
127127
- Integrate seamlessly with **[FastAPI](https://github.com/tiangolo/fastapi/)** and **[Jina](https://github.com/jina-ai/jina/)**
128128

@@ -144,22 +144,22 @@ Image.from_protobuf(doc.to_protobuf())
144144
```
145145

146146
## Store
147-
- Persist a `DocumentArray` using a **`DocumentStore`**
147+
- Persist a `DocArray` using a **`DocumentStore`**
148148
- Store your Documents in any supported (vector) database: **Elasticsearch**, **Qdrant**, **Weaviate**, **Redis**, **Milvus**, **ANNLite** or **SQLite**
149149
- Leverage DocumentStores to **perform vector search on your multi-modal data**
150150

151151
```python
152152
# NOTE: DocumentStores are not yet implemented in version 2
153-
from docarray import DocumentArray
153+
from docarray import DocArray
154154
from docarray.documents import ImageDoc
155155
from docarray.stores import DocumentStore
156156
import numpy as np
157157

158-
da = DocumentArray([ImageDoc(embedding=np.zeros((128,))) for _ in range(1000)])
158+
da = DocArray([ImageDoc(embedding=np.zeros((128,))) for _ in range(1000)])
159159
store = DocumentStore[ImageDoc](
160160
storage='qdrant'
161161
) # create a DocumentStore with Qdrant as backend
162-
store.insert(da) # insert the DocumentArray into the DocumentStore
162+
store.insert(da) # insert the DocArray into the DocumentStore
163163
# find the 10 most similar images based on the 'embedding' field
164164
match = store.find(ImageDoc(embedding=np.zeros((128,))), field='embedding', top_k=10)
165165
```
@@ -186,7 +186,7 @@ If you come from Pydantic, you can see Documents as juiced up models, and DocArr
186186
- **ML focused types**: Tensor, TorchTensor, TFTensor, Embedding, ...
187187
- **Types that are alive**: ImageUrl can `.load()` a URL to image tensor, TextUrl can load and tokenize text documents, etc.
188188
- **Pre-built Documents** for different data modalities: Image, Text, 3DMesh, Video, Audio and more. Note that all of these will be valid Pydantic models!
189-
- The concepts of **DocumentArray and DocumentStore**
189+
- The concepts of **DocArray and DocumentStore**
190190
- Cloud-ready: Serialization to **Protobuf** for use with microservices and **gRPC**
191191
- Support for **vector search functionalities**, such as `find()` and `embed()`
192192

@@ -233,20 +233,20 @@ Not very easy on the eyes if you ask us. And even worse, if you need to add one
233233
So, now let's see what the same code looks like with DocArray:
234234

235235
```python
236-
from docarray import DocumentArray, BaseDocument
236+
from docarray import DocArray, BaseDoc
237237
from docarray.documents import ImageDoc, TextDoc, AudioDoc
238238
from docarray.typing import TorchTensor
239239

240240
import torch
241241

242242

243-
class Podcast(BaseDocument):
243+
class Podcast(BaseDoc):
244244
text: TextDoc
245245
image: ImageDoc
246246
audio: AudioDoc
247247

248248

249-
class PairPodcast(BaseDocument):
249+
class PairPodcast(BaseDoc):
250250
left: Podcast
251251
right: Podcast
252252

@@ -258,14 +258,14 @@ class MyPodcastModel(nn.Module):
258258
self.image_encoder = ImageEncoder()
259259
self.text_encoder = TextEncoder()
260260

261-
def forward_podcast(self, da: DocumentArray[Podcast]) -> DocumentArray[Podcast]:
261+
def forward_podcast(self, da: DocArray[Podcast]) -> DocArray[Podcast]:
262262
da.audio.embedding = self.audio_encoder(da.audio.tensor)
263263
da.text.embedding = self.text_encoder(da.text.tensor)
264264
da.image.embedding = self.image_encoder(da.image.tensor)
265265

266266
return da
267267

268-
def forward(self, da: DocumentArray[PairPodcast]) -> DocumentArray[PairPodcast]:
268+
def forward(self, da: DocArray[PairPodcast]) -> DocArray[PairPodcast]:
269269
da.left = self.forward_podcast(da.left)
270270
da.right = self.forward_podcast(da.right)
271271

@@ -297,12 +297,12 @@ This would look like the following:
297297
```python
298298
from typing import Optional
299299

300-
from docarray import DocumentArray, BaseDocument
300+
from docarray import DocArray, BaseDoc
301301

302302
import tensorflow as tf
303303

304304

305-
class Podcast(BaseDocument):
305+
class Podcast(BaseDoc):
306306
audio_tensor: Optional[AudioTensorFlowTensor]
307307
embedding: Optional[AudioTensorFlowTensor]
308308

@@ -312,7 +312,7 @@ class MyPodcastModel(tf.keras.Model):
312312
super().__init__()
313313
self.audio_encoder = AudioEncoder()
314314

315-
def call(self, inputs: DocumentArray[Podcast]) -> DocumentArray[Podcast]:
315+
def call(self, inputs: DocArray[Podcast]) -> DocArray[Podcast]:
316316
inputs.audio_tensor.embedding = self.audio_encoder(
317317
inputs.audio_tensor.tensor
318318
) # access audio_tensor's .tensor attribute
@@ -328,17 +328,17 @@ import numpy as np
328328
from fastapi import FastAPI
329329
from httpx import AsyncClient
330330

331-
from docarray import BaseDocument
331+
from docarray import BaseDoc
332332
from docarray.documents import ImageDoc
333333
from docarray.typing import NdArray
334-
from docarray.base_document import DocumentResponse
334+
from docarray.base_doc import DocumentResponse
335335

336336

337-
class InputDoc(BaseDocument):
337+
class InputDoc(BaseDoc):
338338
img: ImageDoc
339339

340340

341-
class OutputDoc(BaseDocument):
341+
class OutputDoc(BaseDoc):
342342
embedding_clip: NdArray
343343
embedding_bert: NdArray
344344

@@ -368,12 +368,12 @@ The big advantage here is **first-class support for ML centric data**, such as {
368368
This includes handy features such as validating the shape of a tensor:
369369

370370
```python
371-
from docarray import BaseDocument
371+
from docarray import BaseDoc
372372
from docarray.typing import TorchTensor
373373
import torch
374374

375375

376-
class MyDoc(BaseDocument):
376+
class MyDoc(BaseDoc):
377377
tensor: TorchTensor[3, 224, 224]
378378

379379

@@ -382,7 +382,7 @@ doc = MyDoc(tensor=torch.zeros(224, 224, 3)) # works by reshaping
382382
doc = MyDoc(tensor=torch.zeros(224)) # fails validation
383383

384384

385-
class Image(BaseDocument):
385+
class Image(BaseDoc):
386386
tensor: TorchTensor[3, 'x', 'x']
387387

388388

@@ -407,13 +407,13 @@ store it there, and thus make it searchable:
407407

408408
```python
409409
# NOTE: DocumentStores are not yet implemented in version 2
410-
from docarray import DocumentArray, BaseDocument
410+
from docarray import DocArray, BaseDoc
411411
from docarray.stores import DocumentStore
412412
from docarray.documents import ImageDoc, TextDoc
413413
import numpy as np
414414

415415

416-
class MyDoc(BaseDocument):
416+
class MyDoc(BaseDoc):
417417
image: ImageDoc
418418
text: TextDoc
419419
description: str
@@ -427,11 +427,11 @@ def _random_my_doc():
427427
)
428428

429429

430-
da = DocumentArray([_random_my_doc() for _ in range(1000)]) # create some data
430+
da = DocArray([_random_my_doc() for _ in range(1000)]) # create some data
431431
store = DocumentStore[MyDoc](
432432
storage='qdrant'
433433
) # create a DocumentStore with Qdrant as backend
434-
store.insert(da) # insert the DocumentArray into the DocumentStore
434+
store.insert(da) # insert the DocArray into the DocumentStore
435435

436436
# find the 10 most similar images based on the image embedding field
437437
match = store.find(
@@ -449,16 +449,17 @@ You can see more logs by setting the log level to `DEBUG` or `INFO`:
449449

450450
```python
451451
from pydantic import Field
452-
from docarray import BaseDocument
452+
from docarray import BaseDoc
453453
from docarray.index import HnswDocumentIndex
454454
from docarray.typing import NdArray
455455
import logging
456+
456457
# get the logger and set the log level to DEBUG
457458
logging.getLogger('docarray').setLevel(logging.DEBUG)
458459

459460

460461
# define a simple document and create a document index
461-
class SimpleDoc(BaseDocument):
462+
class SimpleDoc(BaseDoc):
462463
vector: NdArray = Field(dim=10)
463464

464465

‎docarray/__init__.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
__version__ = '0.30.0a3'
22

3-
from docarray.array import DocumentArray, DocumentArrayStacked
4-
from docarray.base_document.document import BaseDocument
53
import logging
64

7-
__all__ = ['BaseDocument', 'DocumentArray', 'DocumentArrayStacked']
5+
from docarray.array import DocArray, DocArrayStacked
6+
from docarray.base_doc.doc import BaseDoc
7+
8+
__all__ = ['BaseDoc', 'DocArray', 'DocArrayStacked']
89

910
logger = logging.getLogger('docarray')
1011

‎docarray/array/__init__.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from docarray.array.array.array import DocumentArray
2-
from docarray.array.stacked.array_stacked import DocumentArrayStacked
1+
from docarray.array.array.array import DocArray
2+
from docarray.array.stacked.array_stacked import DocArrayStacked
33

4-
__all__ = ['DocumentArray', 'DocumentArrayStacked']
4+
__all__ = ['DocArray', 'DocArrayStacked']

0 commit comments

Comments
 (0)