Skip to content

Commit

Permalink
feat: add monitoring of internal part
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Jaghouar committed May 2, 2022
1 parent 0f94166 commit a6576e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/clip_server/executors/clip_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import torch
from clip_server.model import clip
from jina import Executor, requests, DocumentArray
from jina import Executor, requests, DocumentArray, monitor


class CLIPEncoder(Executor):
Expand Down Expand Up @@ -52,6 +52,7 @@ def __init__(

self._pool = ThreadPool(processes=num_worker_preprocess)

@monitor('preproc_images_seconds','Time preprocessing images')
def _preproc_image(self, da: 'DocumentArray') -> 'DocumentArray':
for d in da:
if d.tensor is not None:
Expand All @@ -64,6 +65,7 @@ def _preproc_image(self, da: 'DocumentArray') -> 'DocumentArray':
da.tensors = da.tensors.to(self._device)
return da

@monitor('preproc_texts_seconds','Time preprocessing texts')
def _preproc_text(self, da: 'DocumentArray') -> Tuple['DocumentArray', List[str]]:
texts = da.texts
da.tensors = clip.tokenize(texts).to(self._device)
Expand Down
4 changes: 4 additions & 0 deletions server/clip_server/torch-flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ jtype: Flow
version: '1'
with:
port: 51000
monitoring: True
executors:
- name: clip_t
uses:
jtype: CLIPEncoder
metas:
py_modules:
- executors/clip_torch.py
monitoring: true
port_monitoring: 9091

0 comments on commit a6576e1

Please sign in to comment.