diff --git a/jina/__init__.py b/jina/__init__.py
index 732690f2c42f6..0a0de91f0be76 100644
--- a/jina/__init__.py
+++ b/jina/__init__.py
@@ -7,7 +7,7 @@
# do not change this line manually
# this is managed by proto/build-proto.sh and updated on every execution
-__proto_version__ = '0.0.29'
+__proto_version__ = '0.0.30'
import platform
import sys
diff --git a/jina/clients/python/request.py b/jina/clients/python/request.py
index 8a2c2c41b64cf..75c54bd13cdd2 100644
--- a/jina/clients/python/request.py
+++ b/jina/clients/python/request.py
@@ -2,6 +2,7 @@
__license__ = "Apache-2.0"
import ctypes
+import mimetypes
import os
import random
import urllib.parse
@@ -9,9 +10,10 @@
import numpy as np
-from ...drivers.helper import array2pb
+from ...drivers.helper import array2pb, guess_mime
from ...enums import ClientMode
from ...helper import batch_iterator
+from ...logging import default_logger
from ...proto import jina_pb2
@@ -20,6 +22,19 @@ def _generate(data: Union[Iterator[bytes], Iterator['jina_pb2.Document'], Iterat
random_doc_id: bool = False, mode: ClientMode = ClientMode.INDEX, top_k: int = 50,
mime_type: str = None,
*args, **kwargs) -> Iterator['jina_pb2.Message']:
+ buffer_sniff = False
+
+ try:
+ import magic
+ buffer_sniff = True
+ except (ImportError, ModuleNotFoundError):
+ default_logger.warning(f'can not sniff the MIME type '
+ f'MIME sniffing requires pip install "jina[http]" '
+ f'and brew install libmagic (Mac)/ apt-get install libmagic1 (Linux)')
+
+ if mime_type and (mime_type not in mimetypes.types_map.values()):
+ mime_type = mimetypes.guess_type(f'*.{mime_type}')[0]
+
if isinstance(mode, str):
mode = ClientMode.from_string(mode)
@@ -41,19 +56,26 @@ def _generate(data: Union[Iterator[bytes], Iterator['jina_pb2.Document'], Iterat
d.blob.CopyFrom(array2pb(_raw))
elif isinstance(_raw, bytes):
d.buffer = _raw
- if mime_type:
- d.mime_type = mime_type
+ if not mime_type and buffer_sniff:
+ try:
+ import magic
+ mime_type = magic.from_buffer(_raw, mime=True)
+ except Exception as ex:
+ default_logger.warning(f'can not sniff the MIME type due to the exception {ex}')
elif isinstance(_raw, str):
scheme = urllib.parse.urlparse(_raw).scheme
- if scheme in {'http', 'https'} or os.path.exists(_raw) or os.access(os.path.dirname(_raw), os.W_OK):
- d.file_path = _raw
- elif scheme == 'data':
- d.data_uri = _raw
+ if (scheme in {'http', 'https', 'data'} or os.path.exists(_raw)
+ or os.access(os.path.dirname(_raw), os.W_OK)):
+ d.uri = _raw
+ mime_type = guess_mime(_raw)
else:
d.text = _raw
else:
raise TypeError(f'{type(_raw)} type of input is not supported')
+ if mime_type:
+ d.mime_type = mime_type
+
d.doc_id = first_doc_id if not random_doc_id else random.randint(0, ctypes.c_uint(-1).value)
d.weight = 1.0
first_doc_id += 1
diff --git a/jina/drivers/craft.py b/jina/drivers/craft.py
index d316ee3563b99..91c44ad93a693 100644
--- a/jina/drivers/craft.py
+++ b/jina/drivers/craft.py
@@ -3,11 +3,9 @@
import ctypes
import random
-import urllib.parse
-import urllib.request
from . import BaseExecutableDriver, BaseDriver
-from .helper import array2pb, pb_obj2dict, pb2array
+from .helper import array2pb, pb_obj2dict, pb2array, guess_mime
from ..proto import jina_pb2
@@ -100,6 +98,14 @@ def __init__(self, default_mime: str = 'application/octet-stream', *args, **kwar
"""
super().__init__(*args, **kwargs)
self.default_mime = default_mime
+ self.buffer_sniff = False
+ try:
+ import magic
+ self.buffer_sniff = True
+ except (ImportError, ModuleNotFoundError):
+ self.logger.warning(f'can not sniff the MIME type '
+ f'MIME sniffing requires pip install "jina[http]" '
+ f'and brew install libmagic (Mac)/ apt-get install libmagic1 (Linux)')
def __call__(self, *args, **kwargs):
import mimetypes
@@ -107,29 +113,21 @@ def __call__(self, *args, **kwargs):
for d in self.req.docs:
# mime_type may be a file extension
m_type = d.mime_type
- if m_type and m_type not in mimetypes.types_map.values():
+ if m_type and (m_type not in mimetypes.types_map.values()):
m_type = mimetypes.guess_type(f'*.{m_type}')[0]
- d_type = d.WhichOneof('content')
- if not m_type and d_type: # for ClientInputType=PROTO, d_type could be empty
+ if not m_type: # for ClientInputType=PROTO, d_type could be empty
+ d_type = d.WhichOneof('content')
if d_type == 'buffer':
d_content = getattr(d, d_type)
- # d.mime_type = 'application/octet-stream' # default by IANA standard
- try:
- import magic
- m_type = magic.from_buffer(d_content, mime=True)
- except (ImportError, ModuleNotFoundError):
- self.logger.warning(f'can not sniff the MIME type '
- f'MIME sniffing requires pip install "jina[http]" '
- f'and brew install libmagic (Mac)/ apt-get install libmagic1 (Linux)')
- except Exception as ex:
- self.logger.warning(f'can not sniff the MIME type due to the exception {ex}')
- elif d_type in {'file_path', 'data_uri'}:
- d_content = getattr(d, d_type)
- m_type = mimetypes.guess_type(d_content)[0]
- if not m_type and urllib.parse.urlparse(d_content).scheme in {'http', 'https', 'data'}:
- tmp = urllib.request.urlopen(d_content)
- m_type = tmp.info().get_content_type()
+ if self.buffer_sniff:
+ try:
+ import magic
+ m_type = magic.from_buffer(d_content, mime=True)
+ except Exception as ex:
+ self.logger.warning(f'can not sniff the MIME type due to the exception {ex}')
+ if d.uri:
+ m_type = guess_mime(d.uri)
if m_type:
d.mime_type = m_type
diff --git a/jina/drivers/helper.py b/jina/drivers/helper.py
index 9ed635bacbb6d..730ffa8c33443 100644
--- a/jina/drivers/helper.py
+++ b/jina/drivers/helper.py
@@ -1,7 +1,10 @@
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved."
__license__ = "Apache-2.0"
+import mimetypes
import os
+import urllib.parse
+import urllib.request
from typing import Dict, Any, Iterable, Tuple
import numpy as np
@@ -141,3 +144,13 @@ def pb_obj2dict(obj, keys: Iterable[str]) -> Dict[str, Any]:
:param keys: an iterable of keys for extraction
"""
return {k: getattr(obj, k) for k in keys if hasattr(obj, k)}
+
+
+def guess_mime(uri):
+ # guess when uri points to a local file
+ m_type = mimetypes.guess_type(uri)[0]
+ # guess when uri points to a remote file
+ if not m_type and urllib.parse.urlparse(uri).scheme in {'http', 'https', 'data'}:
+ tmp = urllib.request.urlopen(uri)
+ m_type = tmp.info().get_content_type()
+ return m_type
diff --git a/jina/enums.py b/jina/enums.py
index f1b87ac901c05..8d16101a0b027 100644
--- a/jina/enums.py
+++ b/jina/enums.py
@@ -221,10 +221,3 @@ class ClientMode(BetterEnum):
SEARCH = 1
TRAIN = 2
-
-class ClientInputType(BetterEnum):
- """ The input mode of the client"""
- BUFFER = 0
- DATA_URI = 1
- PROTOBUF = 2
- FILE_PATH = 3
diff --git a/jina/executors/crafters/convert.py b/jina/executors/crafters/convert.py
index 75adfdf5d2a1a..192d1fa70dd60 100644
--- a/jina/executors/crafters/convert.py
+++ b/jina/executors/crafters/convert.py
@@ -13,46 +13,26 @@
from . import BaseDocCrafter
-class FilePath2Buffer(BaseDocCrafter):
+class URI2Buffer(BaseDocCrafter):
""" Convert local file path, remote URL doc to a buffer doc.
"""
- def craft(self, file_path: str, *args, **kwargs):
- if urllib.parse.urlparse(file_path).scheme in {'http', 'https', 'data'}:
- page = urllib.request.Request(file_path, headers={'User-Agent': 'Mozilla/5.0'})
+ def craft(self, uri: str, *args, **kwargs):
+ if urllib.parse.urlparse(uri).scheme in {'http', 'https', 'data'}:
+ page = urllib.request.Request(uri, headers={'User-Agent': 'Mozilla/5.0'})
tmp = urllib.request.urlopen(page)
buffer = tmp.read()
- elif os.path.exists(file_path):
- with open(file_path, 'rb') as fp:
+ elif os.path.exists(uri):
+ with open(uri, 'rb') as fp:
buffer = fp.read()
else:
- raise FileNotFoundError(f'{file_path} is not a URL or a valid local path')
+ raise FileNotFoundError(f'{uri} is not a URL or a valid local path')
return dict(buffer=buffer)
-class DataURI2Buffer(FilePath2Buffer):
- """ Convert a data URI doc to a buffer doc.
- """
-
- def craft(self, data_uri: str, *args, **kwargs):
- return super().craft(data_uri)
-
-
-class PathURI2Buffer(DataURI2Buffer):
- def craft(self, file_path: str, data_uri: str, buffer: bytes, *args, **kwargs):
- if buffer:
- pass
- elif file_path:
- return FilePath2Buffer.craft(self, file_path)
- elif data_uri:
- return DataURI2Buffer.craft(self, data_uri)
- else:
- raise ValueError('this document has no "file_path", no "data_uri" and no "buffer" set')
-
-
-class FilePath2DataURI(FilePath2Buffer):
+class Path2DataURI(URI2Buffer):
def __init__(self, charset: str = 'utf-8', base64: bool = False, *args, **kwargs):
- """ Convert file path doc to data uri doc.
+ """ Convert file path doc to data uri doc. Internally it first reads into buffer and then converts it to data URI.
:param charset: charset may be any character set registered with IANA
:param base64: used to encode arbitrary octet sequences into a form that satisfies the rules of 7bit. Designed to be efficient for non-text 8 bit and binary data. Sometimes used for text data that frequently uses non-US-ASCII characters.
@@ -63,9 +43,9 @@ def __init__(self, charset: str = 'utf-8', base64: bool = False, *args, **kwargs
self.charset = charset
self.base64 = base64
- def craft(self, file_path: str, mime_type: str, *args, **kwargs):
- d = super().craft(file_path)
- return dict(data_uri=self.make_datauri(mime_type, d['buffer']))
+ def craft(self, uri: str, mime_type: str, *args, **kwargs):
+ d = super().craft(uri)
+ return dict(uri=self.make_datauri(mime_type, d['buffer']))
def make_datauri(self, mimetype, buffer):
parts = ['data:', mimetype]
@@ -82,23 +62,23 @@ def make_datauri(self, mimetype, buffer):
return ''.join(parts)
-class Buffer2DataURI(FilePath2DataURI):
+class Buffer2DataURI(Path2DataURI):
"""Convert buffer to data URI"""
def craft(self, buffer: bytes, mime_type: str, *args, **kwargs):
- return dict(data_uri=self.make_datauri(mime_type, buffer))
+ return dict(uri=self.make_datauri(mime_type, buffer))
class Buffer2NdArray(BaseDocCrafter):
"""Convert buffer to numpy array"""
- def craft(self, buffer, *args, **kwargs):
+ def craft(self, buffer: bytes, *args, **kwargs):
return dict(blob=np.frombuffer(buffer))
-class Blob2PNGDataURI(FilePath2DataURI):
+class Blob2PNGDataURI(BaseDocCrafter):
"""Simple DocCrafter used in :command:`jina hello-world`,
- it reads ``buffer`` into base64 png and stored in ``data_uri``"""
+ it reads ``buffer`` into base64 png and stored in ``uri``"""
def __init__(self, width: int = 28, height: int = 28, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -128,4 +108,4 @@ def png_pack(png_tag, data):
png_pack(b'IHDR', struct.pack('!2I5B', self.width, self.height, 8, 6, 0, 0, 0)),
png_pack(b'IDAT', zlib.compress(raw_data, 9)),
png_pack(b'IEND', b'')])
- return dict(data_uri='data:image/png;base64,' + base64.b64encode(png_bytes).decode())
+ return dict(uri='data:image/png;base64,' + base64.b64encode(png_bytes).decode())
diff --git a/jina/helloworld/helper.py b/jina/helloworld/helper.py
index a3f3bfd581a9f..549b7debecdcf 100644
--- a/jina/helloworld/helper.py
+++ b/jina/helloworld/helper.py
@@ -18,10 +18,10 @@
def print_result(resp):
for d in resp.search.docs:
- vi = d.data_uri
+ vi = d.uri
result_html.append(f'
 | ')
for kk in d.topk_results:
- kmi = kk.match_doc.data_uri
+ kmi = kk.match_doc.uri
result_html.append(f' ')
# k['score']['explained'] = json.loads(kk.score.explained)
result_html.append(' |
\n')
diff --git a/jina/proto/jina.proto b/jina/proto/jina.proto
index ece1fb3a7e65f..867348e1e5bf2 100644
--- a/jina/proto/jina.proto
+++ b/jina/proto/jina.proto
@@ -104,12 +104,6 @@ message Document {
// the raw binary content of this document, which often represents the original document when comes into jina
bytes buffer = 3;
- // a data uri document
- string data_uri = 9;
-
- // a local file path, or a remote url starts with http or https points to a document
- string file_path = 11;
-
// the ndarray of the image/audio/video document
NdArray blob = 12;
@@ -134,6 +128,9 @@ message Document {
// mime type of this document, for buffer content, this is required; for other contents, this can be guessed
string mime_type = 10;
+
+ // a uri of the document could be: a local file path, a remote url starts with http or https or data URI scheme
+ string uri = 9;
}
/**
diff --git a/jina/proto/jina_pb2.py b/jina/proto/jina_pb2.py
index b56316f8a9a17..95eaac4512dc6 100644
--- a/jina/proto/jina_pb2.py
+++ b/jina/proto/jina_pb2.py
@@ -1,6 +1,3 @@
-__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved."
-__license__ = "Apache-2.0"
-
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: jina.proto
@@ -22,7 +19,7 @@
package='jina',
syntax='proto3',
serialized_options=None,
- serialized_pb=b'\n\njina.proto\x12\x04jina\x1a\x1fgoogle/protobuf/timestamp.proto\"\xe9\x01\n\x07NdArray\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\x0c\x12\r\n\x05shape\x18\x02 \x03(\r\x12\r\n\x05\x64type\x18\x03 \x01(\t\x12\x34\n\x0cquantization\x18\x04 \x01(\x0e\x32\x1e.jina.NdArray.QuantizationMode\x12\x0f\n\x07max_val\x18\x05 \x01(\x02\x12\x0f\n\x07min_val\x18\x06 \x01(\x02\x12\r\n\x05scale\x18\x07 \x01(\x02\x12\x16\n\x0eoriginal_dtype\x18\x08 \x01(\t\"1\n\x10QuantizationMode\x12\x08\n\x04NONE\x10\x00\x12\x08\n\x04\x46P16\x10\x01\x12\t\n\x05UINT8\x10\x02\"\xf2\x01\n\x0cScoredResult\x12\"\n\x0bmatch_chunk\x18\x01 \x01(\x0b\x32\x0b.jina.ChunkH\x00\x12#\n\tmatch_doc\x18\x02 \x01(\x0b\x32\x0e.jina.DocumentH\x00\x12\'\n\x05score\x18\x03 \x01(\x0b\x32\x18.jina.ScoredResult.Score\x1ah\n\x05Score\x12\r\n\x05value\x18\x01 \x01(\x02\x12\x0f\n\x07op_name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12*\n\x08operands\x18\x04 \x03(\x0b\x32\x18.jina.ScoredResult.ScoreB\x06\n\x04\x62ody\"\x97\x02\n\x05\x43hunk\x12\x0e\n\x06\x64oc_id\x18\x01 \x01(\r\x12\x10\n\x08\x63hunk_id\x18\x02 \x01(\r\x12\x0e\n\x04text\x18\x03 \x01(\tH\x00\x12\x1d\n\x04\x62lob\x18\x04 \x01(\x0b\x32\r.jina.NdArrayH\x00\x12\x10\n\x06\x62uffer\x18\x05 \x01(\x0cH\x00\x12 \n\tembedding\x18\x06 \x01(\x0b\x32\r.jina.NdArray\x12\x0e\n\x06offset\x18\x07 \x01(\r\x12\x0e\n\x06weight\x18\x08 \x01(\x02\x12\x0e\n\x06length\x18\t \x01(\r\x12\x11\n\tmeta_info\x18\n \x01(\x0c\x12(\n\x0ctopk_results\x18\x0b \x03(\x0b\x32\x12.jina.ScoredResult\x12\x11\n\tmime_type\x18\x0c \x01(\tB\t\n\x07\x63ontent\"\x9c\x02\n\x08\x44ocument\x12\x0e\n\x06\x64oc_id\x18\x01 \x01(\r\x12\x10\n\x06\x62uffer\x18\x03 \x01(\x0cH\x00\x12\x12\n\x08\x64\x61ta_uri\x18\t \x01(\tH\x00\x12\x13\n\tfile_path\x18\x0b \x01(\tH\x00\x12\x1d\n\x04\x62lob\x18\x0c \x01(\x0b\x32\r.jina.NdArrayH\x00\x12\x0e\n\x04text\x18\r \x01(\tH\x00\x12\x1b\n\x06\x63hunks\x18\x04 \x03(\x0b\x32\x0b.jina.Chunk\x12\x0e\n\x06weight\x18\x05 \x01(\x02\x12\x0e\n\x06length\x18\x06 \x01(\r\x12\x11\n\tmeta_info\x18\x07 \x01(\x0c\x12(\n\x0ctopk_results\x18\x08 \x03(\x0b\x32\x12.jina.ScoredResult\x12\x11\n\tmime_type\x18\n \x01(\tB\t\n\x07\x63ontent\"\xc1\x03\n\x08\x45nvelope\x12\x11\n\tsender_id\x18\x01 \x01(\t\x12\x13\n\x0breceiver_id\x18\x02 \x01(\t\x12\x12\n\nrequest_id\x18\x03 \x01(\r\x12\x0f\n\x07timeout\x18\x04 \x01(\r\x12$\n\x06routes\x18\x05 \x03(\x0b\x32\x14.jina.Envelope.Route\x12\'\n\x07version\x18\x06 \x01(\x0b\x32\x16.jina.Envelope.Version\x12%\n\x06status\x18\x07 \x01(\x0e\x32\x15.jina.Envelope.Status\x1a\x82\x01\n\x05Route\x12\x0b\n\x03pod\x18\x01 \x01(\t\x12\x0e\n\x06pod_id\x18\x02 \x01(\t\x12.\n\nstart_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x1a\x33\n\x07Version\x12\x0c\n\x04jina\x18\x01 \x01(\t\x12\r\n\x05proto\x18\x02 \x01(\t\x12\x0b\n\x03vcs\x18\x03 \x01(\t\"8\n\x06Status\x12\x0b\n\x07SUCCESS\x10\x00\x12\t\n\x05\x45RROR\x10\x01\x12\x0b\n\x07PENDING\x10\x02\x12\t\n\x05READY\x10\x03\"K\n\x07Message\x12 \n\x08\x65nvelope\x18\x01 \x01(\x0b\x32\x0e.jina.Envelope\x12\x1e\n\x07request\x18\x02 \x01(\x0b\x32\r.jina.Request\"\xf1\x04\n\x07Request\x12\x12\n\nrequest_id\x18\x01 \x01(\r\x12+\n\x05train\x18\x02 \x01(\x0b\x32\x1a.jina.Request.TrainRequestH\x00\x12+\n\x05index\x18\x03 \x01(\x0b\x32\x1a.jina.Request.IndexRequestH\x00\x12-\n\x06search\x18\x04 \x01(\x0b\x32\x1b.jina.Request.SearchRequestH\x00\x12/\n\x07\x63ontrol\x18\x05 \x01(\x0b\x32\x1c.jina.Request.ControlRequestH\x00\x1a;\n\x0cTrainRequest\x12\x1c\n\x04\x64ocs\x18\x01 \x03(\x0b\x32\x0e.jina.Document\x12\r\n\x05\x66lush\x18\x02 \x01(\x08\x1a,\n\x0cIndexRequest\x12\x1c\n\x04\x64ocs\x18\x01 \x03(\x0b\x32\x0e.jina.Document\x1a<\n\rSearchRequest\x12\x1c\n\x04\x64ocs\x18\x01 \x03(\x0b\x32\x0e.jina.Document\x12\r\n\x05top_k\x18\x02 \x01(\r\x1a\xe6\x01\n\x0e\x43ontrolRequest\x12\x35\n\x07\x63ommand\x18\x01 \x01(\x0e\x32$.jina.Request.ControlRequest.Command\x12\x34\n\x04\x61rgs\x18\x02 \x03(\x0b\x32&.jina.Request.ControlRequest.ArgsEntry\x1a+\n\tArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\":\n\x07\x43ommand\x12\r\n\tTERMINATE\x10\x00\x12\n\n\x06STATUS\x10\x01\x12\n\n\x06\x44RYRUN\x10\x02\x12\x08\n\x04IDLE\x10\x03\x42\x06\n\x04\x62ody\"\xc3\x04\n\x0cSpawnRequest\x12\x31\n\x03pea\x18\x01 \x01(\x0b\x32\".jina.SpawnRequest.PeaSpawnRequestH\x00\x12\x31\n\x03pod\x18\x02 \x01(\x0b\x32\".jina.SpawnRequest.PodSpawnRequestH\x00\x12@\n\x0bmutable_pod\x18\x03 \x01(\x0b\x32).jina.SpawnRequest.MutablepodSpawnRequestH\x00\x12\x12\n\nlog_record\x18\x04 \x01(\t\x12)\n\x06status\x18\x05 \x01(\x0e\x32\x19.jina.SpawnRequest.Status\x1a\x1f\n\x0fPeaSpawnRequest\x12\x0c\n\x04\x61rgs\x18\x01 \x03(\t\x1a\x1f\n\x0fPodSpawnRequest\x12\x0c\n\x04\x61rgs\x18\x01 \x03(\t\x1a\xae\x01\n\x16MutablepodSpawnRequest\x12\x30\n\x04head\x18\x01 \x01(\x0b\x32\".jina.SpawnRequest.PeaSpawnRequest\x12\x30\n\x04tail\x18\x02 \x01(\x0b\x32\".jina.SpawnRequest.PeaSpawnRequest\x12\x30\n\x04peas\x18\x03 \x03(\x0b\x32\".jina.SpawnRequest.PeaSpawnRequest\"Q\n\x06Status\x12\x0b\n\x07SUCCESS\x10\x00\x12\x0f\n\x0b\x45RROR_OTHER\x10\x01\x12\x13\n\x0f\x45RROR_DUPLICATE\x10\x02\x12\x14\n\x10\x45RROR_NOTALLOWED\x10\x03\x42\x06\n\x04\x62ody2\x97\x01\n\x07JinaRPC\x12*\n\x04\x43\x61ll\x12\r.jina.Request\x1a\r.jina.Request\"\x00(\x01\x30\x01\x12+\n\tCallUnary\x12\r.jina.Request\x1a\r.jina.Request\"\x00\x12\x33\n\x05Spawn\x12\x12.jina.SpawnRequest\x1a\x12.jina.SpawnRequest\"\x00\x30\x01\x62\x06proto3'
+ serialized_pb=b'\n\njina.proto\x12\x04jina\x1a\x1fgoogle/protobuf/timestamp.proto\"\xe9\x01\n\x07NdArray\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\x0c\x12\r\n\x05shape\x18\x02 \x03(\r\x12\r\n\x05\x64type\x18\x03 \x01(\t\x12\x34\n\x0cquantization\x18\x04 \x01(\x0e\x32\x1e.jina.NdArray.QuantizationMode\x12\x0f\n\x07max_val\x18\x05 \x01(\x02\x12\x0f\n\x07min_val\x18\x06 \x01(\x02\x12\r\n\x05scale\x18\x07 \x01(\x02\x12\x16\n\x0eoriginal_dtype\x18\x08 \x01(\t\"1\n\x10QuantizationMode\x12\x08\n\x04NONE\x10\x00\x12\x08\n\x04\x46P16\x10\x01\x12\t\n\x05UINT8\x10\x02\"\xf2\x01\n\x0cScoredResult\x12\"\n\x0bmatch_chunk\x18\x01 \x01(\x0b\x32\x0b.jina.ChunkH\x00\x12#\n\tmatch_doc\x18\x02 \x01(\x0b\x32\x0e.jina.DocumentH\x00\x12\'\n\x05score\x18\x03 \x01(\x0b\x32\x18.jina.ScoredResult.Score\x1ah\n\x05Score\x12\r\n\x05value\x18\x01 \x01(\x02\x12\x0f\n\x07op_name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12*\n\x08operands\x18\x04 \x03(\x0b\x32\x18.jina.ScoredResult.ScoreB\x06\n\x04\x62ody\"\x97\x02\n\x05\x43hunk\x12\x0e\n\x06\x64oc_id\x18\x01 \x01(\r\x12\x10\n\x08\x63hunk_id\x18\x02 \x01(\r\x12\x0e\n\x04text\x18\x03 \x01(\tH\x00\x12\x1d\n\x04\x62lob\x18\x04 \x01(\x0b\x32\r.jina.NdArrayH\x00\x12\x10\n\x06\x62uffer\x18\x05 \x01(\x0cH\x00\x12 \n\tembedding\x18\x06 \x01(\x0b\x32\r.jina.NdArray\x12\x0e\n\x06offset\x18\x07 \x01(\r\x12\x0e\n\x06weight\x18\x08 \x01(\x02\x12\x0e\n\x06length\x18\t \x01(\r\x12\x11\n\tmeta_info\x18\n \x01(\x0c\x12(\n\x0ctopk_results\x18\x0b \x03(\x0b\x32\x12.jina.ScoredResult\x12\x11\n\tmime_type\x18\x0c \x01(\tB\t\n\x07\x63ontent\"\x80\x02\n\x08\x44ocument\x12\x0e\n\x06\x64oc_id\x18\x01 \x01(\r\x12\x10\n\x06\x62uffer\x18\x03 \x01(\x0cH\x00\x12\x1d\n\x04\x62lob\x18\x0c \x01(\x0b\x32\r.jina.NdArrayH\x00\x12\x0e\n\x04text\x18\r \x01(\tH\x00\x12\x1b\n\x06\x63hunks\x18\x04 \x03(\x0b\x32\x0b.jina.Chunk\x12\x0e\n\x06weight\x18\x05 \x01(\x02\x12\x0e\n\x06length\x18\x06 \x01(\r\x12\x11\n\tmeta_info\x18\x07 \x01(\x0c\x12(\n\x0ctopk_results\x18\x08 \x03(\x0b\x32\x12.jina.ScoredResult\x12\x11\n\tmime_type\x18\n \x01(\t\x12\x0b\n\x03uri\x18\t \x01(\tB\t\n\x07\x63ontent\"\xc1\x03\n\x08\x45nvelope\x12\x11\n\tsender_id\x18\x01 \x01(\t\x12\x13\n\x0breceiver_id\x18\x02 \x01(\t\x12\x12\n\nrequest_id\x18\x03 \x01(\r\x12\x0f\n\x07timeout\x18\x04 \x01(\r\x12$\n\x06routes\x18\x05 \x03(\x0b\x32\x14.jina.Envelope.Route\x12\'\n\x07version\x18\x06 \x01(\x0b\x32\x16.jina.Envelope.Version\x12%\n\x06status\x18\x07 \x01(\x0e\x32\x15.jina.Envelope.Status\x1a\x82\x01\n\x05Route\x12\x0b\n\x03pod\x18\x01 \x01(\t\x12\x0e\n\x06pod_id\x18\x02 \x01(\t\x12.\n\nstart_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x1a\x33\n\x07Version\x12\x0c\n\x04jina\x18\x01 \x01(\t\x12\r\n\x05proto\x18\x02 \x01(\t\x12\x0b\n\x03vcs\x18\x03 \x01(\t\"8\n\x06Status\x12\x0b\n\x07SUCCESS\x10\x00\x12\t\n\x05\x45RROR\x10\x01\x12\x0b\n\x07PENDING\x10\x02\x12\t\n\x05READY\x10\x03\"K\n\x07Message\x12 \n\x08\x65nvelope\x18\x01 \x01(\x0b\x32\x0e.jina.Envelope\x12\x1e\n\x07request\x18\x02 \x01(\x0b\x32\r.jina.Request\"\xf1\x04\n\x07Request\x12\x12\n\nrequest_id\x18\x01 \x01(\r\x12+\n\x05train\x18\x02 \x01(\x0b\x32\x1a.jina.Request.TrainRequestH\x00\x12+\n\x05index\x18\x03 \x01(\x0b\x32\x1a.jina.Request.IndexRequestH\x00\x12-\n\x06search\x18\x04 \x01(\x0b\x32\x1b.jina.Request.SearchRequestH\x00\x12/\n\x07\x63ontrol\x18\x05 \x01(\x0b\x32\x1c.jina.Request.ControlRequestH\x00\x1a;\n\x0cTrainRequest\x12\x1c\n\x04\x64ocs\x18\x01 \x03(\x0b\x32\x0e.jina.Document\x12\r\n\x05\x66lush\x18\x02 \x01(\x08\x1a,\n\x0cIndexRequest\x12\x1c\n\x04\x64ocs\x18\x01 \x03(\x0b\x32\x0e.jina.Document\x1a<\n\rSearchRequest\x12\x1c\n\x04\x64ocs\x18\x01 \x03(\x0b\x32\x0e.jina.Document\x12\r\n\x05top_k\x18\x02 \x01(\r\x1a\xe6\x01\n\x0e\x43ontrolRequest\x12\x35\n\x07\x63ommand\x18\x01 \x01(\x0e\x32$.jina.Request.ControlRequest.Command\x12\x34\n\x04\x61rgs\x18\x02 \x03(\x0b\x32&.jina.Request.ControlRequest.ArgsEntry\x1a+\n\tArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\":\n\x07\x43ommand\x12\r\n\tTERMINATE\x10\x00\x12\n\n\x06STATUS\x10\x01\x12\n\n\x06\x44RYRUN\x10\x02\x12\x08\n\x04IDLE\x10\x03\x42\x06\n\x04\x62ody\"\xc3\x04\n\x0cSpawnRequest\x12\x31\n\x03pea\x18\x01 \x01(\x0b\x32\".jina.SpawnRequest.PeaSpawnRequestH\x00\x12\x31\n\x03pod\x18\x02 \x01(\x0b\x32\".jina.SpawnRequest.PodSpawnRequestH\x00\x12@\n\x0bmutable_pod\x18\x03 \x01(\x0b\x32).jina.SpawnRequest.MutablepodSpawnRequestH\x00\x12\x12\n\nlog_record\x18\x04 \x01(\t\x12)\n\x06status\x18\x05 \x01(\x0e\x32\x19.jina.SpawnRequest.Status\x1a\x1f\n\x0fPeaSpawnRequest\x12\x0c\n\x04\x61rgs\x18\x01 \x03(\t\x1a\x1f\n\x0fPodSpawnRequest\x12\x0c\n\x04\x61rgs\x18\x01 \x03(\t\x1a\xae\x01\n\x16MutablepodSpawnRequest\x12\x30\n\x04head\x18\x01 \x01(\x0b\x32\".jina.SpawnRequest.PeaSpawnRequest\x12\x30\n\x04tail\x18\x02 \x01(\x0b\x32\".jina.SpawnRequest.PeaSpawnRequest\x12\x30\n\x04peas\x18\x03 \x03(\x0b\x32\".jina.SpawnRequest.PeaSpawnRequest\"Q\n\x06Status\x12\x0b\n\x07SUCCESS\x10\x00\x12\x0f\n\x0b\x45RROR_OTHER\x10\x01\x12\x13\n\x0f\x45RROR_DUPLICATE\x10\x02\x12\x14\n\x10\x45RROR_NOTALLOWED\x10\x03\x42\x06\n\x04\x62ody2\x97\x01\n\x07JinaRPC\x12*\n\x04\x43\x61ll\x12\r.jina.Request\x1a\r.jina.Request\"\x00(\x01\x30\x01\x12+\n\tCallUnary\x12\r.jina.Request\x1a\r.jina.Request\"\x00\x12\x33\n\x05Spawn\x12\x12.jina.SpawnRequest\x1a\x12.jina.SpawnRequest\"\x00\x30\x01\x62\x06proto3'
,
dependencies=[google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,])
@@ -79,8 +76,8 @@
],
containing_type=None,
serialized_options=None,
- serialized_start=1497,
- serialized_end=1553,
+ serialized_start=1469,
+ serialized_end=1525,
)
_sym_db.RegisterEnumDescriptor(_ENVELOPE_STATUS)
@@ -109,8 +106,8 @@
],
containing_type=None,
serialized_options=None,
- serialized_start=2192,
- serialized_end=2250,
+ serialized_start=2164,
+ serialized_end=2222,
)
_sym_db.RegisterEnumDescriptor(_REQUEST_CONTROLREQUEST_COMMAND)
@@ -139,8 +136,8 @@
],
containing_type=None,
serialized_options=None,
- serialized_start=2751,
- serialized_end=2832,
+ serialized_start=2723,
+ serialized_end=2804,
)
_sym_db.RegisterEnumDescriptor(_SPAWNREQUEST_STATUS)
@@ -458,75 +455,68 @@
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
- name='data_uri', full_name='jina.Document.data_uri', index=2,
- number=9, type=9, cpp_type=9, label=1,
- has_default_value=False, default_value=b"".decode('utf-8'),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='file_path', full_name='jina.Document.file_path', index=3,
- number=11, type=9, cpp_type=9, label=1,
- has_default_value=False, default_value=b"".decode('utf-8'),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='blob', full_name='jina.Document.blob', index=4,
+ name='blob', full_name='jina.Document.blob', index=2,
number=12, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
- name='text', full_name='jina.Document.text', index=5,
+ name='text', full_name='jina.Document.text', index=3,
number=13, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
- name='chunks', full_name='jina.Document.chunks', index=6,
+ name='chunks', full_name='jina.Document.chunks', index=4,
number=4, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
- name='weight', full_name='jina.Document.weight', index=7,
+ name='weight', full_name='jina.Document.weight', index=5,
number=5, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
- name='length', full_name='jina.Document.length', index=8,
+ name='length', full_name='jina.Document.length', index=6,
number=6, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
- name='meta_info', full_name='jina.Document.meta_info', index=9,
+ name='meta_info', full_name='jina.Document.meta_info', index=7,
number=7, type=12, cpp_type=9, label=1,
has_default_value=False, default_value=b"",
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
- name='topk_results', full_name='jina.Document.topk_results', index=10,
+ name='topk_results', full_name='jina.Document.topk_results', index=8,
number=8, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
- name='mime_type', full_name='jina.Document.mime_type', index=11,
+ name='mime_type', full_name='jina.Document.mime_type', index=9,
number=10, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='uri', full_name='jina.Document.uri', index=10,
+ number=9, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=b"".decode('utf-8'),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
@@ -543,7 +533,7 @@
index=0, containing_type=None, fields=[]),
],
serialized_start=817,
- serialized_end=1101,
+ serialized_end=1073,
)
@@ -594,8 +584,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=1312,
- serialized_end=1442,
+ serialized_start=1284,
+ serialized_end=1414,
)
_ENVELOPE_VERSION = _descriptor.Descriptor(
@@ -638,8 +628,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=1444,
- serialized_end=1495,
+ serialized_start=1416,
+ serialized_end=1467,
)
_ENVELOPE = _descriptor.Descriptor(
@@ -711,8 +701,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=1104,
- serialized_end=1553,
+ serialized_start=1076,
+ serialized_end=1525,
)
@@ -749,8 +739,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=1555,
- serialized_end=1630,
+ serialized_start=1527,
+ serialized_end=1602,
)
@@ -787,8 +777,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=1850,
- serialized_end=1909,
+ serialized_start=1822,
+ serialized_end=1881,
)
_REQUEST_INDEXREQUEST = _descriptor.Descriptor(
@@ -817,8 +807,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=1911,
- serialized_end=1955,
+ serialized_start=1883,
+ serialized_end=1927,
)
_REQUEST_SEARCHREQUEST = _descriptor.Descriptor(
@@ -854,8 +844,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=1957,
- serialized_end=2017,
+ serialized_start=1929,
+ serialized_end=1989,
)
_REQUEST_CONTROLREQUEST_ARGSENTRY = _descriptor.Descriptor(
@@ -891,8 +881,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=2147,
- serialized_end=2190,
+ serialized_start=2119,
+ serialized_end=2162,
)
_REQUEST_CONTROLREQUEST = _descriptor.Descriptor(
@@ -929,8 +919,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=2020,
- serialized_end=2250,
+ serialized_start=1992,
+ serialized_end=2222,
)
_REQUEST = _descriptor.Descriptor(
@@ -990,8 +980,8 @@
name='body', full_name='jina.Request.body',
index=0, containing_type=None, fields=[]),
],
- serialized_start=1633,
- serialized_end=2258,
+ serialized_start=1605,
+ serialized_end=2230,
)
@@ -1021,8 +1011,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=2508,
- serialized_end=2539,
+ serialized_start=2480,
+ serialized_end=2511,
)
_SPAWNREQUEST_PODSPAWNREQUEST = _descriptor.Descriptor(
@@ -1051,8 +1041,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=2541,
- serialized_end=2572,
+ serialized_start=2513,
+ serialized_end=2544,
)
_SPAWNREQUEST_MUTABLEPODSPAWNREQUEST = _descriptor.Descriptor(
@@ -1095,8 +1085,8 @@
extension_ranges=[],
oneofs=[
],
- serialized_start=2575,
- serialized_end=2749,
+ serialized_start=2547,
+ serialized_end=2721,
)
_SPAWNREQUEST = _descriptor.Descriptor(
@@ -1157,8 +1147,8 @@
name='body', full_name='jina.SpawnRequest.body',
index=0, containing_type=None, fields=[]),
],
- serialized_start=2261,
- serialized_end=2840,
+ serialized_start=2233,
+ serialized_end=2812,
)
_NDARRAY.fields_by_name['quantization'].enum_type = _NDARRAY_QUANTIZATIONMODE
@@ -1192,12 +1182,6 @@
_DOCUMENT.oneofs_by_name['content'].fields.append(
_DOCUMENT.fields_by_name['buffer'])
_DOCUMENT.fields_by_name['buffer'].containing_oneof = _DOCUMENT.oneofs_by_name['content']
-_DOCUMENT.oneofs_by_name['content'].fields.append(
- _DOCUMENT.fields_by_name['data_uri'])
-_DOCUMENT.fields_by_name['data_uri'].containing_oneof = _DOCUMENT.oneofs_by_name['content']
-_DOCUMENT.oneofs_by_name['content'].fields.append(
- _DOCUMENT.fields_by_name['file_path'])
-_DOCUMENT.fields_by_name['file_path'].containing_oneof = _DOCUMENT.oneofs_by_name['content']
_DOCUMENT.oneofs_by_name['content'].fields.append(
_DOCUMENT.fields_by_name['blob'])
_DOCUMENT.fields_by_name['blob'].containing_oneof = _DOCUMENT.oneofs_by_name['content']
@@ -1424,18 +1408,18 @@
file=DESCRIPTOR,
index=0,
serialized_options=None,
- serialized_start=2843,
- serialized_end=2994,
+ serialized_start=2815,
+ serialized_end=2966,
methods=[
- _descriptor.MethodDescriptor(
- name='Call',
- full_name='jina.JinaRPC.Call',
- index=0,
- containing_service=None,
- input_type=_REQUEST,
- output_type=_REQUEST,
- serialized_options=None,
- ),
+ _descriptor.MethodDescriptor(
+ name='Call',
+ full_name='jina.JinaRPC.Call',
+ index=0,
+ containing_service=None,
+ input_type=_REQUEST,
+ output_type=_REQUEST,
+ serialized_options=None,
+ ),
_descriptor.MethodDescriptor(
name='CallUnary',
full_name='jina.JinaRPC.CallUnary',
diff --git a/jina/proto/jina_pb2_grpc.py b/jina/proto/jina_pb2_grpc.py
index ac695389891df..f7cd77a24e745 100644
--- a/jina/proto/jina_pb2_grpc.py
+++ b/jina/proto/jina_pb2_grpc.py
@@ -1,6 +1,3 @@
-__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved."
-__license__ = "Apache-2.0"
-
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
diff --git a/tests/executors/__init__.py b/tests/executors/__init__.py
index 4bfe96cabadb3..f408c4ed9e9d3 100644
--- a/tests/executors/__init__.py
+++ b/tests/executors/__init__.py
@@ -1,4 +1,5 @@
import os
+
from jina.executors.metas import get_default_metas
from tests import JinaTestCase
diff --git a/tests/executors/crafters/audio/test_monophone.py b/tests/executors/crafters/audio/test_monophone.py
index 6ab208106845d..1dd00b0f4eacc 100644
--- a/tests/executors/crafters/audio/test_monophone.py
+++ b/tests/executors/crafters/audio/test_monophone.py
@@ -1,6 +1,6 @@
import unittest
-import numpy as np
+import numpy as np
from jina.executors.crafters.audio.monophone import AudioMonophoner
from tests import JinaTestCase
diff --git a/tests/executors/crafters/audio/test_normalize.py b/tests/executors/crafters/audio/test_normalize.py
index 7c29619919340..195b7c604f290 100644
--- a/tests/executors/crafters/audio/test_normalize.py
+++ b/tests/executors/crafters/audio/test_normalize.py
@@ -1,6 +1,6 @@
import unittest
-import numpy as np
+import numpy as np
from jina.executors.crafters.audio.normalize import AudioNormalizer
from tests import JinaTestCase
diff --git a/tests/executors/crafters/audio/test_split.py b/tests/executors/crafters/audio/test_split.py
index 615ecc93ccb1a..159141c64989a 100644
--- a/tests/executors/crafters/audio/test_split.py
+++ b/tests/executors/crafters/audio/test_split.py
@@ -1,6 +1,6 @@
import unittest
-import numpy as np
+import numpy as np
from jina.executors.crafters.audio.split import AudioSlicer, SlidingWindowAudioSlicer
from tests import JinaTestCase
diff --git a/tests/executors/crafters/image/test_crop.py b/tests/executors/crafters/image/test_crop.py
index 445699713379a..2e12874dc12dd 100644
--- a/tests/executors/crafters/image/test_crop.py
+++ b/tests/executors/crafters/image/test_crop.py
@@ -1,7 +1,6 @@
import unittest
import numpy as np
-
from jina.executors.crafters.image.crop import ImageCropper, CenterImageCropper, RandomImageCropper, FiveImageCropper, \
SlidingWindowImageCropper
from tests.executors.crafters.image import JinaImageTestCase
diff --git a/tests/executors/crafters/numeric/test_io.py b/tests/executors/crafters/numeric/test_io.py
index 924d0a4330346..659fd47ca5794 100644
--- a/tests/executors/crafters/numeric/test_io.py
+++ b/tests/executors/crafters/numeric/test_io.py
@@ -1,6 +1,6 @@
import unittest
-import numpy as np
+import numpy as np
from jina.executors.crafters.numeric.io import ArrayReader
from tests import JinaTestCase
diff --git a/tests/executors/crafters/test_mime.py b/tests/executors/crafters/test_mime.py
index 43563869dd1bf..2df3a3b5a6d8d 100644
--- a/tests/executors/crafters/test_mime.py
+++ b/tests/executors/crafters/test_mime.py
@@ -38,20 +38,20 @@ def test_dummy_seg(self):
f.index(input_fn=input_fn(), output_fn=print)
def test_any_file(self):
- f = Flow().add(yaml_path='!FilePath2DataURI\nwith: {base64: true}')
+ f = Flow().add(yaml_path='!Path2DataURI\nwith: {base64: true}')
with f:
f.index(input_fn=input_fn2, output_fn=print)
def test_aba(self):
f = (Flow().add(yaml_path='!Buffer2DataURI\nwith: {mimetype: png}')
- .add(yaml_path='DataURI2Buffer')
+ .add(yaml_path='URI2Buffer')
.add(yaml_path='!Buffer2DataURI\nwith: {mimetype: png}'))
with f:
f.index(input_fn=input_fn, output_fn=print)
def test_pathURI2Buffer(self):
- f = (Flow().add(yaml_path='PathURI2Buffer')
+ f = (Flow().add(yaml_path='URI2Buffer')
.add(yaml_path='Buffer2DataURI'))
with f:
diff --git a/tests/executors/crafters/test_segmenter.py b/tests/executors/crafters/test_segmenter.py
index fedc4713293d2..e29786f2ecb84 100644
--- a/tests/executors/crafters/test_segmenter.py
+++ b/tests/executors/crafters/test_segmenter.py
@@ -1,4 +1,3 @@
-from jina.enums import ClientInputType
from jina.executors.crafters import BaseSegmenter
from jina.flow import Flow
from jina.proto import jina_pb2
diff --git a/tests/executors/encoders/clients.py b/tests/executors/encoders/clients.py
index 08e00283f8ece..beab3647e59f8 100644
--- a/tests/executors/encoders/clients.py
+++ b/tests/executors/encoders/clients.py
@@ -1,9 +1,9 @@
-import unittest
import os
-import numpy as np
+import unittest
-from jina.executors.encoders.clients import UnaryTFServingClientEncoder
+import numpy as np
from jina.executors import BaseExecutor
+from jina.executors.encoders.clients import UnaryTFServingClientEncoder
from tests import JinaTestCase
diff --git a/tests/executors/encoders/image/__init__.py b/tests/executors/encoders/image/__init__.py
index 051508696e2d7..bdf58714734ff 100644
--- a/tests/executors/encoders/image/__init__.py
+++ b/tests/executors/encoders/image/__init__.py
@@ -2,7 +2,6 @@
import unittest
import numpy as np
-
from jina.executors import BaseExecutor
from tests.executors import ExecutorTestCase
diff --git a/tests/executors/encoders/image/test_customtorchvision.py b/tests/executors/encoders/image/test_customtorchvision.py
index 7b13a77dfe0e9..0af2c4d454d4c 100644
--- a/tests/executors/encoders/image/test_customtorchvision.py
+++ b/tests/executors/encoders/image/test_customtorchvision.py
@@ -1,11 +1,11 @@
+import tempfile
import unittest
-from jina.executors.encoders.image.customtorchvision import CustomImageTorchEncoder
-from tests.executors.encoders.image import ImageTestCase
import torch
import torch.nn as nn
import torch.nn.functional as F
-import tempfile
+from jina.executors.encoders.image.customtorchvision import CustomImageTorchEncoder
+from tests.executors.encoders.image import ImageTestCase
class TestNet(nn.Module):
diff --git a/tests/executors/encoders/nlp/__init__.py b/tests/executors/encoders/nlp/__init__.py
index 5651f187b006c..14399a0f1fe49 100644
--- a/tests/executors/encoders/nlp/__init__.py
+++ b/tests/executors/encoders/nlp/__init__.py
@@ -2,7 +2,6 @@
import unittest
import numpy as np
-
from jina.executors import BaseExecutor
from tests.executors import ExecutorTestCase
diff --git a/tests/executors/encoders/nlp/test_char.py b/tests/executors/encoders/nlp/test_char.py
index 8cd3108fb7536..5af023bc72f93 100644
--- a/tests/executors/encoders/nlp/test_char.py
+++ b/tests/executors/encoders/nlp/test_char.py
@@ -2,7 +2,6 @@
import unittest
import numpy as np
-
from jina.executors import BaseExecutor
from jina.executors.encoders.nlp.char import OneHotTextEncoder
from tests import JinaTestCase
diff --git a/tests/executors/encoders/numeric/__init__.py b/tests/executors/encoders/numeric/__init__.py
index 7edf892c8e690..0042551cb9c31 100644
--- a/tests/executors/encoders/numeric/__init__.py
+++ b/tests/executors/encoders/numeric/__init__.py
@@ -1,7 +1,6 @@
import os
import numpy as np
-
from jina.executors import BaseExecutor
from tests import JinaTestCase
diff --git a/tests/executors/encoders/numeric/test_pca.py b/tests/executors/encoders/numeric/test_pca.py
index b62146286d2f1..4cfc97cfbdc7c 100644
--- a/tests/executors/encoders/numeric/test_pca.py
+++ b/tests/executors/encoders/numeric/test_pca.py
@@ -1,7 +1,6 @@
import unittest
import numpy as np
-
from jina.executors.encoders.numeric.pca import IncrementalPCAEncoder
from tests.executors.encoders.numeric import NumericTestCase
diff --git a/tests/executors/encoders/video/__init__.py b/tests/executors/encoders/video/__init__.py
index 8a99c3cccd199..76c7cec23999a 100644
--- a/tests/executors/encoders/video/__init__.py
+++ b/tests/executors/encoders/video/__init__.py
@@ -2,7 +2,6 @@
import unittest
import numpy as np
-
from jina.executors import BaseExecutor
from tests.executors import ExecutorTestCase
diff --git a/tests/executors/indexers/keyvalue/test_leveldb.py b/tests/executors/indexers/keyvalue/test_leveldb.py
index 1076dfb331a2d..99f3dea44749f 100644
--- a/tests/executors/indexers/keyvalue/test_leveldb.py
+++ b/tests/executors/indexers/keyvalue/test_leveldb.py
@@ -1,9 +1,8 @@
import os
import unittest
-from google.protobuf.json_format import MessageToJson
-
import jina.proto.jina_pb2 as jina_pb2
+from google.protobuf.json_format import MessageToJson
from jina.executors.indexers import BaseIndexer
from jina.executors.indexers.keyvalue.leveldb import LeveldbIndexer
from tests import JinaTestCase
diff --git a/tests/executors/indexers/vector/test_annoy.py b/tests/executors/indexers/vector/test_annoy.py
index 410d0bd849e21..ecf61cb4f7e0b 100644
--- a/tests/executors/indexers/vector/test_annoy.py
+++ b/tests/executors/indexers/vector/test_annoy.py
@@ -2,7 +2,6 @@
import unittest
import numpy as np
-
from jina.executors.indexers import BaseIndexer
from jina.executors.indexers.vector.annoy import AnnoyIndexer
from jina.executors.indexers.vector.nmslib import NmslibIndexer
diff --git a/tests/mwu-encoder/mwu_encoder.py b/tests/mwu-encoder/mwu_encoder.py
index 9b2e7a012107d..d8cdbff51e7f2 100644
--- a/tests/mwu-encoder/mwu_encoder.py
+++ b/tests/mwu-encoder/mwu_encoder.py
@@ -1,7 +1,6 @@
from typing import Any
import numpy as np
-
from jina.executors.encoders import BaseEncoder
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 0887ff36a74fa..99df34cb6865f 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -3,13 +3,12 @@
import unittest
from pathlib import Path
-from pkg_resources import resource_filename
-
from jina.clients import py_client
from jina.clients.python.io import input_numpy
from jina.flow import Flow
from jina.helloworld import download_data
from jina.main.parser import set_hw_parser
+from pkg_resources import resource_filename
from tests import JinaTestCase
diff --git a/tests/test_client.py b/tests/test_client.py
index 765db1bcb08c6..85b7b4df4d5a0 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -2,7 +2,6 @@
import numpy as np
import requests
-
from jina.clients import py_client
from jina.clients.python import PyClient
from jina.clients.python.io import input_files, input_numpy
@@ -86,7 +85,7 @@ def test_io_files(self):
PyClient.check_input(input_files('*.*', size=2, read_mode='rb'))
PyClient.check_input(input_files('*.*', sampling_rate=.5))
- f = Flow().add(yaml_path='PathURI2Buffer')
+ f = Flow().add(yaml_path='URI2Buffer')
def validate_mime_type(req):
for d in req.index.docs:
diff --git a/tests/test_container.py b/tests/test_container.py
index 75fc506901057..ab6718fda68c4 100644
--- a/tests/test_container.py
+++ b/tests/test_container.py
@@ -2,7 +2,6 @@
import time
from sys import platform
-from jina.enums import ClientInputType
from jina.flow import Flow
from jina.main.checker import NetworkChecker
from jina.main.parser import set_pea_parser, set_ping_parser
diff --git a/tests/test_driver_yaml.py b/tests/test_driver_yaml.py
index b91d57aa5e6ef..2ae28296f8715 100644
--- a/tests/test_driver_yaml.py
+++ b/tests/test_driver_yaml.py
@@ -1,7 +1,5 @@
import unittest
-from pkg_resources import resource_filename
-
from jina.drivers import BaseDriver
from jina.drivers.control import ControlReqDriver
from jina.drivers.search import KVSearchDriver
@@ -9,6 +7,7 @@
from jina.helper import yaml
from jina.main.parser import set_pod_parser
from jina.peapods import Pod
+from pkg_resources import resource_filename
from tests import JinaTestCase
diff --git a/tests/test_flow.py b/tests/test_flow.py
index 5a0c4743a70b1..1888895eef481 100644
--- a/tests/test_flow.py
+++ b/tests/test_flow.py
@@ -1,9 +1,8 @@
import unittest
import requests
-
from jina import JINA_GLOBAL
-from jina.enums import FlowOptimizeLevel, ClientInputType
+from jina.enums import FlowOptimizeLevel
from jina.flow import Flow
from jina.main.checker import NetworkChecker
from jina.main.parser import set_pea_parser, set_ping_parser
diff --git a/tests/test_index.py b/tests/test_index.py
index 0d7c184750e07..d77c35ccfbed9 100644
--- a/tests/test_index.py
+++ b/tests/test_index.py
@@ -4,9 +4,8 @@
import unittest
import numpy as np
-
from jina.drivers.helper import array2pb
-from jina.enums import FlowOptimizeLevel, ClientInputType
+from jina.enums import FlowOptimizeLevel
from jina.executors.indexers.vector.numpy import NumpyIndexer
from jina.flow import Flow
from jina.main.parser import set_flow_parser
diff --git a/tests/test_index_remote.py b/tests/test_index_remote.py
index 4ee0501ae2ab9..7be2422814f59 100644
--- a/tests/test_index_remote.py
+++ b/tests/test_index_remote.py
@@ -4,9 +4,8 @@
import unittest
import numpy as np
-
from jina.drivers.helper import array2pb
-from jina.enums import FlowOptimizeLevel, ClientInputType
+from jina.enums import FlowOptimizeLevel
from jina.executors.indexers.vector.numpy import NumpyIndexer
from jina.flow import Flow
from jina.main.parser import set_gateway_parser
diff --git a/tests/test_load_yaml.py b/tests/test_load_yaml.py
index ffa9c40b6705e..bf1fe51d7160a 100644
--- a/tests/test_load_yaml.py
+++ b/tests/test_load_yaml.py
@@ -1,7 +1,6 @@
import unittest
import ruamel.yaml
-
from jina.helper import expand_env_var
from jina.logging import default_logger
from tests import JinaTestCase
diff --git a/tests/test_loadbalance.py b/tests/test_loadbalance.py
index c6816f3c9bff9..13dbd5b4049d8 100644
--- a/tests/test_loadbalance.py
+++ b/tests/test_loadbalance.py
@@ -2,9 +2,8 @@
import time
import numpy as np
-
from jina.drivers.helper import array2pb
-from jina.enums import SchedulerType, ClientInputType
+from jina.enums import SchedulerType
from jina.executors.crafters import BaseDocCrafter
from jina.flow import Flow
from jina.proto import jina_pb2
diff --git a/tests/test_quant.py b/tests/test_quant.py
index b6f0c50b7eb59..42e0927122bf4 100644
--- a/tests/test_quant.py
+++ b/tests/test_quant.py
@@ -1,9 +1,7 @@
import os
import numpy as np
-
from jina.drivers.helper import array2pb, pb2array
-from jina.enums import ClientInputType
from jina.flow import Flow
from jina.proto import jina_pb2
from tests import JinaTestCase
diff --git a/tests/test_workspace.py b/tests/test_workspace.py
index 826a736a43626..2eb81ffd38098 100644
--- a/tests/test_workspace.py
+++ b/tests/test_workspace.py
@@ -1,7 +1,6 @@
import os
import numpy as np
-
from jina.executors import BaseExecutor
from tests import JinaTestCase
diff --git a/tests/test_yamlparser.py b/tests/test_yamlparser.py
index 11a66a2f5d425..9d0fe60753c66 100644
--- a/tests/test_yamlparser.py
+++ b/tests/test_yamlparser.py
@@ -1,12 +1,11 @@
import os
-from pkg_resources import resource_filename
-
from jina.executors import BaseExecutor
from jina.executors.metas import fill_metas_with_defaults
from jina.helper import yaml, expand_dict
from jina.main.parser import set_pea_parser
from jina.peapods.pea import BasePea
+from pkg_resources import resource_filename
from tests import JinaTestCase