Skip to content

Commit

Permalink
docs: add doc for deplyment on JCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiniuYu committed May 31, 2022
1 parent 5b8e914 commit 441f40d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
69 changes: 69 additions & 0 deletions docs/how-to/clip_torch_encoder_jcloud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Deploy CLIP Torch Encoder on JCloud

This tutorial shows how to deploy CLIP Torch Encoder on JCloud. Click [here](https://github.com/jina-ai/jcloud) for more information on JCloud usage.

## Deploy on JCloud

A sample minimum YAML file of a [Jina Flow](https://docs.jina.ai/fundamentals/flow/) to run CLIP Torch Encoder is given as

```yaml
# flow.yml
jtype: Flow
executors:
- name: CLIPTorchEncoder
uses: jinahub+docker://CLIPTorchEncoder
```
> All Executors' `uses` must follow the format `jinahub+docker://MyExecutor` (from [Jina Hub](https://hub.jina.ai)) to avoid any local file dependencies.

To deploy,

```bash
$ jc deploy flow.yml
```

you should get:

```bash
╭───────────────Flow is available!──────────────╮
│ │
│ ID <your_flow_id> │
│ URL grpcs://<your_flow_id>.wolf.jina.ai │
│ │
╰───────────────────────────────────────────────╯
```

## Connect from Client

Run the following Python script:

```python
from clip_client import Client
c = Client('grpcs://<your_flow_id>.wolf.jina.ai')
r = c.encode(
[
'First do it',
'then do it right',
'then do it better',
'https://picsum.photos/200',
]
)
print(r)
```

will give you:

```bash
[[ 0.03480401 -0.23519686 0.01041038 ... -0.5229086 -0.10081214
-0.08695138]
[-0.0683605 -0.00324154 0.01490371 ... -0.50309485 -0.06193433
-0.08574048]
[ 0.15041807 -0.07933374 -0.06650036 ... -0.46410388 -0.08535041
0.04270519]
[-0.16183889 0.10636599 -0.2062868 ... -0.41244072 0.19485454
0.05658712]]
```


It means the client and the JCloud server are now connected. Well done!
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ playground/embedding
```


```{toctree}
:caption: How-To
:hidden:
how-to/clip_torch_encoder_jcloud
```


```{toctree}
:caption: Developer References
:hidden:
Expand Down

0 comments on commit 441f40d

Please sign in to comment.