Skip to content

Commit

Permalink
docs: fix push/pull (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
alaeddine-13 authored Apr 6, 2022
1 parent 6e4f698 commit 08e0a12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ If you want to transfer a DocumentArray from one machine to another or share it


```python
left_da.push(token='my_shared_da')
left_da.push('my_shared_da')
```

Now anyone who knows the token `my_shared_da` can pull and work on it.

```python
left_da = DocumentArray.pull(token='my_shared_da')
left_da = DocumentArray.pull('my_shared_da')
```

Intrigued? That's only scratching the surface of what DocArray is capable of. [Read our docs to learn more](https://docarray.jina.ai).
Expand Down
17 changes: 11 additions & 6 deletions docs/fundamentals/documentarray/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ from docarray import DocumentArray, Document
da = DocumentArray([Document(text='hello'), Document(text='world')])

da.save_binary('my_docarray.bin', protocol='protobuf', compress='lz4')
da_rec = DocumentArray.load_binary('my_docarray.bin', protocol='protobuf', compress='lz4')
da_rec = DocumentArray.load_binary(
'my_docarray.bin', protocol='protobuf', compress='lz4'
)
da_rec.summary()
```

Expand Down Expand Up @@ -230,9 +232,11 @@ In particular, if a serialization uses `protocol='pickle'` or `protocol='protobu
```python
from docarray import DocumentArray, Document

da_generator = DocumentArray.load_binary('xxxl.bin', protocol='pickle', compress='gzip', streaming=True)
da_generator = DocumentArray.load_binary(
'xxxl.bin', protocol='pickle', compress='gzip', streaming=True
)

for d in da_generator:
for d in da_generator:
d: Document
# go nuts with `d`
```
Expand All @@ -248,6 +252,7 @@ Serialize into base64 can be useful when binary string is not allowed, e.g. in R

```python
from docarray import DocumentArray

da = DocumentArray.empty(10)

d_str = da.to_base64(protocol='protobuf', compress='lz4')
Expand All @@ -263,7 +268,7 @@ To deserialize, remember to set the correct `protocol` and `compress`:
```python
from docarray import DocumentArray

da = DocumentArray.from_base64(d_str, protocol='protobuf', compress='lz4')
da = DocumentArray.from_base64(d_str, protocol='protobuf', compress='lz4')
da.summary()
```

Expand Down Expand Up @@ -368,7 +373,7 @@ Considering you are working on a GPU machine via Google Colab/Jupyter. After pre
from docarray import DocumentArray

da = DocumentArray(...) # heavylifting, processing, GPU task, ...
da.push(token='myda123', show_progress=True)
da.push('myda123', show_progress=True)
```

```{figure} images/da-push.png
Expand All @@ -379,7 +384,7 @@ Then on your local laptop, simply pull it:
```python
from docarray import DocumentArray

da = DocumentArray.pull(token='myda123', show_progress=True)
da = DocumentArray.pull('myda123', show_progress=True)
```

Now you can continue the work at local, analyzing `da` or visualizing it. Your friends & colleagues who know the token `myda123` can also pull that DocumentArray. It's useful when you want to quickly share the results with your colleagues & friends.
Expand Down

0 comments on commit 08e0a12

Please sign in to comment.