From 2c546c5b1e604eca1d0adc2f9289b03336670219 Mon Sep 17 00:00:00 2001 From: Girish Chandrashekar Date: Mon, 28 Nov 2022 13:20:18 +0100 Subject: [PATCH] fix: provide default value for tracing_context --- server/clip_server/executors/clip_onnx.py | 14 +++++++++----- server/clip_server/executors/clip_tensorrt.py | 16 ++++++++++------ server/clip_server/executors/clip_torch.py | 16 ++++++++++------ 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/server/clip_server/executors/clip_onnx.py b/server/clip_server/executors/clip_onnx.py index f6bdf2e39..1b52ec3a7 100644 --- a/server/clip_server/executors/clip_onnx.py +++ b/server/clip_server/executors/clip_onnx.py @@ -1,20 +1,20 @@ import os import warnings -from multiprocessing.pool import ThreadPool -from typing import Optional, Dict from functools import partial +from multiprocessing.pool import ThreadPool +from typing import Dict, Optional import onnxruntime as ort from clip_server.executors.helper import ( - split_img_txt_da, preproc_image, preproc_text, set_rank, + split_img_txt_da, ) from clip_server.model import clip from clip_server.model.clip_onnx import CLIPOnnxModel from clip_server.model.tokenization import Tokenizer -from jina import Executor, requests, DocumentArray +from jina import DocumentArray, Executor, requests from opentelemetry.trace import NoOpTracer, Span @@ -135,7 +135,11 @@ async def rank(self, docs: 'DocumentArray', parameters: Dict, **kwargs): @requests async def encode( - self, docs: 'DocumentArray', tracing_context, parameters: Dict = {}, **kwargs + self, + docs: 'DocumentArray', + tracing_context=None, + parameters: Dict = {}, + **kwargs, ): with self.tracer.start_as_current_span( 'encode', context=tracing_context diff --git a/server/clip_server/executors/clip_tensorrt.py b/server/clip_server/executors/clip_tensorrt.py index 253aac36d..580095e30 100644 --- a/server/clip_server/executors/clip_tensorrt.py +++ b/server/clip_server/executors/clip_tensorrt.py @@ -1,19 +1,19 @@ import warnings -from multiprocessing.pool import ThreadPool -from typing import Optional, Dict from functools import partial +from multiprocessing.pool import ThreadPool +from typing import Dict, Optional import numpy as np from clip_server.executors.helper import ( - split_img_txt_da, preproc_image, preproc_text, set_rank, + split_img_txt_da, ) from clip_server.model import clip -from clip_server.model.tokenization import Tokenizer from clip_server.model.clip_trt import CLIPTensorRTModel -from jina import Executor, requests, DocumentArray +from clip_server.model.tokenization import Tokenizer +from jina import DocumentArray, Executor, requests from opentelemetry.trace import NoOpTracer, Span @@ -109,7 +109,11 @@ async def rank(self, docs: 'DocumentArray', parameters: Dict, **kwargs): @requests async def encode( - self, docs: 'DocumentArray', tracing_context, parameters: Dict = {}, **kwargs + self, + docs: 'DocumentArray', + tracing_context=None, + parameters: Dict = {}, + **kwargs, ): with self.tracer.start_as_current_span( 'encode', context=tracing_context diff --git a/server/clip_server/executors/clip_torch.py b/server/clip_server/executors/clip_torch.py index b529d0785..8b740d526 100644 --- a/server/clip_server/executors/clip_torch.py +++ b/server/clip_server/executors/clip_torch.py @@ -1,22 +1,22 @@ import os import warnings -from multiprocessing.pool import ThreadPool -from typing import Optional, Dict from functools import partial -from opentelemetry.trace import NoOpTracer, Span +from multiprocessing.pool import ThreadPool +from typing import Dict, Optional import numpy as np import torch from clip_server.executors.helper import ( - split_img_txt_da, preproc_image, preproc_text, set_rank, + split_img_txt_da, ) from clip_server.model import clip from clip_server.model.clip_model import CLIPModel from clip_server.model.tokenization import Tokenizer -from jina import Executor, requests, DocumentArray +from jina import DocumentArray, Executor, requests +from opentelemetry.trace import NoOpTracer, Span class CLIPEncoder(Executor): @@ -120,7 +120,11 @@ async def rank(self, docs: 'DocumentArray', parameters: Dict, **kwargs): @requests async def encode( - self, docs: 'DocumentArray', tracing_context, parameters: Dict = {}, **kwargs + self, + docs: 'DocumentArray', + tracing_context=None, + parameters: Dict = {}, + **kwargs, ): with self.tracer.start_as_current_span( 'encode', context=tracing_context