Skip to content

Commit

Permalink
docs: add two empty spaces before noqa (#1961)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwanglzu committed Feb 17, 2021
1 parent 9a844b6 commit f02f30c
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 1 deletion.
32 changes: 32 additions & 0 deletions jina/drivers/__init__.py
Expand Up @@ -105,6 +105,8 @@ class QuerySetReader:
@property
def as_querylang(self):
"""Render as QueryLang parameters.
.. # noqa: DAR201"""
parameters = {
name: getattr(self, name) for name in self._init_kwargs_dict.keys()
Expand Down Expand Up @@ -208,14 +210,20 @@ def attach(self, runtime: 'ZEDRuntime', *args, **kwargs) -> None:
@property
def req(self) -> 'Request':
"""Get the current (typed) request, shortcut to ``self.runtime.request``
.. # noqa: DAR201
"""
return self.runtime.request

@property
def partial_reqs(self) -> Sequence['Request']:
"""The collected partial requests under the current ``request_id``
.. # noqa: DAR401
.. # noqa: DAR201
"""
if self.expect_parts > 1:
Expand All @@ -229,22 +237,32 @@ def partial_reqs(self) -> Sequence['Request']:
@property
def expect_parts(self) -> int:
"""The expected number of partial messages
.. # noqa: DAR201
"""
return self.runtime.expect_parts

@property
def msg(self) -> 'Message':
"""Get the current request, shortcut to ``self.runtime.message``
.. # noqa: DAR201
"""
return self.runtime.message

@property
def queryset(self) -> 'QueryLangSet':
"""
.. # noqa: DAR101
.. # noqa: DAR102
.. # noqa: DAR201
"""
if self.msg:
Expand All @@ -255,13 +273,19 @@ def queryset(self) -> 'QueryLangSet':
@property
def logger(self) -> 'JinaLogger':
"""Shortcut to ``self.runtime.logger``
.. # noqa: DAR201
"""
return self.runtime.logger

def __call__(self, *args, **kwargs) -> None:
"""
.. # noqa: DAR102
.. # noqa: DAR101
"""
raise NotImplementedError
Expand All @@ -287,7 +311,11 @@ class RecursiveMixin(BaseDriver):
@property
def docs(self):
"""
.. # noqa: DAR102
.. # noqa: DAR201
"""
if self.expect_parts > 1:
Expand Down Expand Up @@ -382,6 +410,8 @@ def __call__(self, *args, **kwargs):
@property
def docs(self) -> 'DocumentSet':
"""The DocumentSet after applying the traversal
.. # noqa: DAR201"""
from ..types.sets import DocumentSet

Expand Down Expand Up @@ -442,6 +472,8 @@ def __init__(
@property
def exec(self) -> 'AnyExecutor':
"""the executor that to which the instance is attached
.. # noqa: DAR201
"""
return self._exec
Expand Down
5 changes: 5 additions & 0 deletions jina/drivers/control.py
Expand Up @@ -18,6 +18,8 @@ class BaseControlDriver(BaseDriver):
@property
def envelope(self) -> 'jina_pb2.EnvelopeProto':
"""Get the current request, shortcut to ``self.runtime.message``
.. # noqa: DAR201
"""
return self.msg.envelope
Expand Down Expand Up @@ -57,6 +59,8 @@ class WaitDriver(BaseControlDriver):

def __call__(self, *args, **kwargs):
"""Wait for some seconds, mainly for demo purpose
.. # noqa: DAR101
"""
time.sleep(5)
Expand Down Expand Up @@ -112,6 +116,7 @@ def __call__(self, *args, **kwargs):
:param *args: *args for super().__call__
:param **kwargs: **kwargs for super().__call__
.. # noqa: DAR401
"""
if self.msg.is_data_request:
Expand Down
4 changes: 4 additions & 0 deletions jina/drivers/encode.py
Expand Up @@ -70,6 +70,8 @@ def __init__(self,
@property
def available_capacity(self):
"""The capacity left in the cache
.. # noqa: DAR201
"""
return self.capacity - len(self._doc_set)
Expand All @@ -89,6 +91,8 @@ def __len__(self):

def get(self):
"""Get the DocumentSet
.. # noqa: DAR201
"""
return self._doc_set
Expand Down
2 changes: 1 addition & 1 deletion jina/drivers/evaluate.py
Expand Up @@ -72,8 +72,8 @@ def extract(self, doc: 'Document') -> Any:
This function will be invoked two times in :meth:`_apply_all`:
once with actual doc, once with groundtruth doc.
.. # noqa: DAR401
.. # noqa: DAR401
:param doc: the Document
"""
raise NotImplementedError
Expand Down
6 changes: 6 additions & 0 deletions jina/drivers/predict.py
Expand Up @@ -51,7 +51,11 @@ def prediction2label(self, prediction: 'np.ndarray') -> List[Any]:
:param prediction: the float/int numpy ndarray given by :class:`BaseClassifier`
:return: the readable label to be stored.
.. # noqa: DAR401
.. # noqa: DAR202
"""
raise NotImplementedError
Expand Down Expand Up @@ -81,6 +85,7 @@ def prediction2label(self, prediction: 'np.ndarray') -> List[str]:
:param prediction: a (B,) or (B, 1) zero one array
:return: the labels as either ``self.one_label`` or ``self.zero_label``
.. # noqa: DAR401
"""
p = np.squeeze(prediction)
Expand Down Expand Up @@ -108,6 +113,7 @@ def validate_labels(self, prediction: 'np.ndarray'):
:param prediction: the predictions
.. # noqa: DAR401
"""
if prediction.ndim != 2:
Expand Down
10 changes: 10 additions & 0 deletions jina/drivers/querylang/select.py
Expand Up @@ -68,7 +68,11 @@ class ExcludeReqQL(ExcludeQL):

def __call__(self, *args, **kwargs):
"""
.. # noqa: DAR102
.. # noqa: DAR101
"""
for k in self.fields:
Expand All @@ -78,12 +82,18 @@ def __call__(self, *args, **kwargs):
class SelectReqQL(ExcludeReqQL):
"""Clean up request from the request-level protobuf message to reduce the total size of the message, it works with the opposite
logic as `:class:`ExcludeReqQL`
.. # noqa: DAR101
"""

def __call__(self, *args, **kwargs):
"""
.. # noqa: DAR102
.. # noqa: DAR101
"""
for k in self.req.DESCRIPTOR.fields_by_name.keys():
Expand Down
29 changes: 29 additions & 0 deletions jina/flow/base.py
Expand Up @@ -93,7 +93,11 @@ def _update_args(self, args, **kwargs):
def yaml_spec(self):
"""
get the YAML representation of the instance
.. # noqa: DAR401
.. # noqa: DAR201
"""
return JAML.dump(self)
Expand Down Expand Up @@ -123,7 +127,11 @@ def _parse_endpoints(op_flow, pod_name, endpoint, connect_to_last_pod=False) ->
@property
def last_pod(self):
"""Last pod
.. # noqa: DAR401
.. # noqa: DAR201
"""
return self._last_changed_pod[-1]
Expand All @@ -133,6 +141,7 @@ def last_pod(self, name: str):
"""
Set a Pod as the last Pod in the Flow, useful when modifying the Flow.
.. # noqa: DAR401
:param name: the name of the existing Pod
"""
Expand Down Expand Up @@ -169,6 +178,7 @@ def needs(self, needs: Union[Tuple[str], List[str]],
"""
Add a blocker to the Flow, wait until all peas defined in **needs** completed.
.. # noqa: DAR401
:param needs: list of service names to wait
:param name: the name of this joiner, by default is ``joiner``
Expand Down Expand Up @@ -208,6 +218,7 @@ def add(self,
Recommend to use :py:meth:`add_encoder`, :py:meth:`add_preprocessor`,
:py:meth:`add_router`, :py:meth:`add_indexer` whenever possible.
.. # noqa: DAR401
:param needs: the name of the Pod(s) that this Pod receives data from.
One can also use 'pod.Gateway' to indicate the connection with the gateway.
Expand Down Expand Up @@ -366,6 +377,7 @@ def build(self, copy_flow: bool = False) -> 'BaseFlow':
with f.build(copy_flow=True) as fl:
fl.search()
.. # noqa: DAR401
"""

Expand Down Expand Up @@ -443,6 +455,7 @@ def start(self):
Note that this method has a timeout of ``timeout_ready`` set in CLI,
which is inherited all the way from :class:`jina.peapods.peas.BasePea`
.. # noqa: DAR401
:return: this instance
Expand Down Expand Up @@ -477,12 +490,16 @@ def start(self):
@property
def num_pods(self) -> int:
"""Get the number of Pods in this Flow
.. # noqa: DAR201"""
return len(self._pod_nodes)

@property
def num_peas(self) -> int:
"""Get the number of peas (parallel count) in this Flow
.. # noqa: DAR201"""
return sum(v.num_peas for v in self._pod_nodes.values())

Expand Down Expand Up @@ -689,27 +706,35 @@ def to_swarm_yaml(self, path: TextIO):
@build_required(FlowBuildLevel.GRAPH)
def port_expose(self) -> int:
"""Return the exposed port of the gateway
.. # noqa: DAR201"""
return self._pod_nodes['gateway'].port_expose

@property
@build_required(FlowBuildLevel.GRAPH)
def host(self) -> str:
"""Return the local address of the gateway
.. # noqa: DAR201"""
return self._pod_nodes['gateway'].host

@property
@build_required(FlowBuildLevel.GRAPH)
def address_private(self) -> str:
"""Return the private IP address of the gateway for connecting from other machine in the same network
.. # noqa: DAR201"""
return get_internal_ip()

@property
@build_required(FlowBuildLevel.GRAPH)
def address_public(self) -> str:
"""Return the public IP address of the gateway for connecting from other machine in the public network
.. # noqa: DAR201"""
return get_public_ip()

Expand Down Expand Up @@ -771,6 +796,8 @@ def _update_client(self):
@property
def workspace_id(self) -> Dict[str, str]:
"""Get all Pods' ``workspace_id`` values in a dict
.. # noqa: DAR201"""
return {k: p.args.workspace_id for k, p in self if hasattr(p.args, 'workspace_id')}

Expand All @@ -794,6 +821,8 @@ def workspace_id(self, value: str):
@property
def identity(self) -> Dict[str, str]:
"""Get all Pods' ``identity`` values in a dict
.. # noqa: DAR201
"""
return {k: p.args.identity for k, p in self}
Expand Down
1 change: 1 addition & 0 deletions jina/flow/builder.py
Expand Up @@ -110,6 +110,7 @@ def _connect_two_nodes(flow: 'Flow', start_node_name: str, end_node_name: str):
def _connect(first: 'BasePod', second: 'BasePod', first_socket_type: 'SocketType') -> None:
"""Connect two Pods
.. # noqa: DAR401
:param first: the first BasePod
:param second: the second BasePod
Expand Down
1 change: 1 addition & 0 deletions jina/jaml/__init__.py
Expand Up @@ -384,6 +384,7 @@ def load_config(cls,
# disable substitute
b = BaseExecutor.load_config('a.yml', substitute=False)
.. # noqa: DAR401
:param source: the multi-kind source of the configs.
:param allow_py_modules: allow importing plugins specified by ``py_modules`` in YAML at any levels
Expand Down
1 change: 1 addition & 0 deletions jina/jaml/helper.py
Expand Up @@ -89,6 +89,7 @@ def parse_config_source(path: Union[str, TextIO, Dict],
*args, **kwargs) -> Tuple[TextIO, Optional[str]]:
"""Check if the text or text stream is valid.
.. # noqa: DAR401
:param path: the multi-kind source of the configs.
:param allow_stream: flag
Expand Down
2 changes: 2 additions & 0 deletions jina/jaml/parsers/__init__.py
Expand Up @@ -48,6 +48,8 @@ def _get_default_parser():

def get_parser(cls: Type['JAMLCompatible'], version: Optional[str]) -> 'VersionedYAMLParser':
"""
.. # noqa: DAR401
:param cls: the target class to parse
:param version: yaml version number in "MAJOR[.MINOR]" format
Expand Down

0 comments on commit f02f30c

Please sign in to comment.