From 7c2faae270e276bfc36f4c51e4abe101194f1799 Mon Sep 17 00:00:00 2001 From: Ziniu Yu Date: Fri, 17 Jun 2022 16:25:17 +0800 Subject: [PATCH] docs: update jcloud docs (#754) * docs: update jcloud docs * docs: rename executors * docs: add onnx * docs: minor revision * docs: modify narrative * docs: change link to jcloud * docs: improve narratives * docs: add no gpu tip * docs: add no gpu tip * docs: modify sample jcloud yml --- docs/user-guides/server.md | 173 +++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 94 deletions(-) diff --git a/docs/user-guides/server.md b/docs/user-guides/server.md index 2fb3eb6f3..14329f331 100644 --- a/docs/user-guides/server.md +++ b/docs/user-guides/server.md @@ -487,117 +487,102 @@ r = c.encode( ) ``` -[//]: # (## Deploy on JCloud) +## Deploy on JCloud -[//]: # () -[//]: # (You can deploy `CLIPTorchEncoder` on JCloud. ) +The `clip_server` can be smoothly deployed and hosted as a [Flow](https://docs.jina.ai/fundamentals/flow/) on [JCloud](https://docs.jina.ai/fundamentals/jcloud/) to utilize the free computational and storage resources provided by Jina. -[//]: # (A minimum YAML file `flow.yml` is as follows:) +You need a YAML file to config the `clip_server` executor in the Flow in order to deploy. +The executors are hosted on [Jina Hub](https://hub.jina.ai) and are automatically sync with `clip_server` Python module. +We currently support [PyTorch-backed CLIP](https://hub.jina.ai/executor/gzpbl8jh) and [ONNX-backed CLIP](https://hub.jina.ai/executor/2a7auwg2). -[//]: # () -[//]: # (```yaml) +A minimum YAML file is as follows. You can also config the same parameters in executors via `with` [described here](#clip-model-config). -[//]: # (jtype: Flow) +````{tab} pytorch-flow.yml -[//]: # (executors:) - -[//]: # ( - name: CLIPTorchEncoder # The name of the encoder) - -[//]: # ( uses: jinahub+docker://CLIPTorchEncoder) - -[//]: # (```) - -[//]: # () -[//]: # (```{warning}) - -[//]: # (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) - -[//]: # (```) - -[//]: # () -[//]: # (Here `jc deploy` is the command to deploy a Jina project to JCloud.) - -[//]: # (Learn more about [JCloud usage](https://docs.jina.ai/fundamentals/jcloud/).) - -[//]: # () -[//]: # () -[//]: # (The Flow is successfully deployed when you see:) - -[//]: # () -[//]: # (```{figure} images/jc-deploy.png) - -[//]: # (:width: 60%) - -[//]: # () -[//]: # (```) - -[//]: # () -[//]: # (After deploying on jcloud, you can connect to it via client by setting `grpcs://` as follows:) - -[//]: # () -[//]: # () -[//]: # (```python) - -[//]: # (from clip_client import Client) - -[//]: # () -[//]: # (c = Client('grpcs://174eb69ba3.wolf.jina.ai') # This is the URL you get from previous step) - -[//]: # () -[//]: # (r = c.encode() - -[//]: # ( [) - -[//]: # ( 'First do it',) - -[//]: # ( 'then do it right',) - -[//]: # ( 'then do it better',) - -[//]: # ( 'https://picsum.photos/200',) - -[//]: # ( ]) +```yaml +--- +emphasize-lines: 5 +--- -[//]: # ()) +jtype: Flow +executors: + - name: CLIPTorchEncoder + uses: jinahub+docker://CLIPTorchEncoder + with: +``` +```` +````{tab} onnx-flow.yml +--- +emphasize-lines: 5 +--- -[//]: # (print(r)) +```yaml +jtype: Flow +executors: + - name: CLIPOnnxEncoder + uses: jinahub+docker://CLIPOnnxEncoder + with: +``` +```` -[//]: # (```) -[//]: # () -[//]: # (will give you:) +```{warning} +All Executors' `uses` must follow the format `jinahub+docker://MyExecutor` (from [Jina Hub](https://hub.jina.ai)) to avoid any local file dependencies. +``` -[//]: # () -[//]: # (```text) +To deploy, -[//]: # ([[ 0.03480401 -0.23519686 0.01041038 ... -0.5229086 -0.10081214) +````{tab} PyTorch-backed +```bash +$ jc deploy pytorch-flow.yml +``` +```` +````{tab} ONNX-backed +```bash +$ jc deploy onnx-flow.yml +``` +```` -[//]: # ( -0.08695138]) +Here `jc deploy` is the command to deploy a Jina project to JCloud. +Learn more about [JCloud usage](https://docs.jina.ai/fundamentals/jcloud/). -[//]: # ( [-0.0683605 -0.00324154 0.01490371 ... -0.50309485 -0.06193433) +The Flow is successfully deployed when you see: -[//]: # ( -0.08574048]) +```{figure} images/jc-deploy.png +:width: 60% +``` -[//]: # ( [ 0.15041807 -0.07933374 -0.06650036 ... -0.46410388 -0.08535041) +After deploying on jcloud, you can connect to it via client by setting `grpcs://` generated from previous step as follows: -[//]: # ( 0.04270519]) +```python +from clip_client import Client -[//]: # ( [-0.16183889 0.10636599 -0.2062868 ... -0.41244072 0.19485454) +c = Client( + 'grpcs://174eb69ba3.wolf.jina.ai' +) # This is the URL you get from previous step -[//]: # ( 0.05658712]]) +r = c.encode( + [ + 'First do it', + 'then do it right', + 'then do it better', + 'https://picsum.photos/200', + ] +) +print(r) +``` -[//]: # (```) +will give you: + +```text +[[ 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!) +It means the client and the JCloud server are now connected. Well done! \ No newline at end of file