Skip to content

Commit

Permalink
docs: add missing docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianmtr committed Feb 15, 2021
1 parent da79811 commit b2f1616
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 0 deletions.
29 changes: 29 additions & 0 deletions jina/parsers/__init__.py
Expand Up @@ -5,6 +5,12 @@


def set_pea_parser(parser=None):
"""
Set the parser for the Pea
:param parser: an optional existing parser to build upon
:return: the parser
"""
if not parser:
from .base import set_base_parser
parser = set_base_parser()
Expand All @@ -28,6 +34,12 @@ def set_pea_parser(parser=None):


def set_pod_parser(parser=None):
"""
Set the parser for the Pod
:param parser: an optional existing parser to build upon
:return: the parser
"""
if not parser:
from .base import set_base_parser
parser = set_base_parser()
Expand All @@ -42,6 +54,12 @@ def set_pod_parser(parser=None):


def set_gateway_parser(parser=None):
"""
Set the parser for the gateway arguments
:param parser: an optional existing parser to build upon
:return: the parser
"""
if not parser:
from .base import set_base_parser
parser = set_base_parser()
Expand Down Expand Up @@ -74,6 +92,12 @@ def set_gateway_parser(parser=None):


def set_client_cli_parser(parser=None):
"""
Set the parser for the cli client
:param parser: an optional existing parser to build upon
:return: the parser
"""
if not parser:
from .base import set_base_parser
parser = set_base_parser()
Expand All @@ -89,6 +113,11 @@ def set_client_cli_parser(parser=None):


def get_main_parser():
"""
The main parser for Jina
:return: the parser
"""
from .base import set_base_parser
from .helloworld import set_hw_parser, set_hw_chatbot_parser
from .helper import _chf, _SHOW_ALL_ARGS
Expand Down
5 changes: 5 additions & 0 deletions jina/parsers/base.py
Expand Up @@ -5,6 +5,11 @@


def set_base_parser():
"""
Set the base parser
:return: the parser
"""
from .. import __version__
from ..helper import colored, get_full_version, format_full_version_info
# create the top-level parser
Expand Down
6 changes: 6 additions & 0 deletions jina/parsers/check.py
Expand Up @@ -3,6 +3,12 @@


def set_check_parser(parser=None):
"""
Set the `check` parser
:param parser: an optional existing parser to build upon
:return: parser
"""
if not parser:
parser = set_base_parser()

Expand Down
5 changes: 5 additions & 0 deletions jina/parsers/client.py
Expand Up @@ -4,6 +4,11 @@


def mixin_client_cli_parser(parser):
"""
Add the arguments for the client to the parser
:param parser: the parser configure
"""
gp = add_arg_group(parser, title='Client')

gp.add_argument('--request-size', type=int, default=100,
Expand Down
6 changes: 6 additions & 0 deletions jina/parsers/export_api.py
Expand Up @@ -3,6 +3,12 @@


def set_export_api_parser(parser=None):
"""
Set the parser for the API export
:param parser: an optional existing parser to build upon
:return: the parser
"""
if not parser:
parser = set_base_parser()

Expand Down
6 changes: 6 additions & 0 deletions jina/parsers/flow.py
Expand Up @@ -8,6 +8,12 @@


def set_flow_parser(parser=None):
"""
Set the parser for the flow
:param parser: an (optional) initial parser to build upon
:return: the parser
"""
if not parser:
parser = set_base_parser()

Expand Down
17 changes: 17 additions & 0 deletions jina/parsers/helloworld.py
Expand Up @@ -9,6 +9,11 @@


def mixin_hw_base_parser(parser):
"""
Add the arguments for hello world to the parser
:param parser: the parser configure
"""
gp = add_arg_group(parser, title='General')
gp.add_argument('--workdir', type=str, default=random_identity(),
help='The workdir for hello-world demo'
Expand All @@ -18,6 +23,12 @@ def mixin_hw_base_parser(parser):


def set_hw_parser(parser=None):
"""
Set the hello world parser
:param parser: the parser configure
:return: the new parser
"""
if not parser:
parser = set_base_parser()

Expand Down Expand Up @@ -66,6 +77,12 @@ def set_hw_parser(parser=None):


def set_hw_chatbot_parser(parser=None):
"""
Set the parser for the hello world chatbot
:param parser: the parser configure
:return: the new parser
"""
if not parser:
parser = set_base_parser()

Expand Down
25 changes: 25 additions & 0 deletions jina/parsers/helper.py
Expand Up @@ -11,6 +11,13 @@


def add_arg_group(parser, title):
"""
Add the arguments for a specific group to the parser
:param parser: the parser configure
:param title: the group name
:return: the new parser
"""
return parser.add_argument_group(f'{title} arguments')


Expand All @@ -32,6 +39,15 @@ class KVAppendAction(argparse.Action):
"""

def __call__(self, parser, args, values, option_string=None):
"""
call the KVAppendAction
# noqa: DAR401
:param parser: the parser
:param args: args to initialize the values
:param values: the values to add to the parser
:param option_string: inherited, not used
"""
import json
d = getattr(args, self.dest) or {}
for value in values:
Expand All @@ -54,6 +70,15 @@ class DockerKwargsAppendAction(argparse.Action):
"""

def __call__(self, parser, args, values, option_string=None):
"""
call the DockerKwargsAppendAction
# noqa: DAR401
:param parser: the parser
:param args: args to initialize the values
:param values: the values to add to the parser
:param option_string: inherited, not used
"""
import json
d = getattr(args, self.dest) or {}

Expand Down
29 changes: 29 additions & 0 deletions jina/parsers/hub/__init__.py
Expand Up @@ -3,6 +3,12 @@


def set_hub_pushpull_parser(parser=None):
"""
Set the parser for the hub push or hub pull
:param parser: an optional existing parser to build upon
:return: the parser
"""
if not parser:
parser = set_base_parser()

Expand All @@ -15,6 +21,12 @@ def set_hub_pushpull_parser(parser=None):


def set_hub_build_parser(parser=None):
"""
Set the parser for `hub build`
:param parser: the parser configure
:return: the new parser
"""
if not parser:
parser = set_base_parser()

Expand All @@ -28,6 +40,12 @@ def set_hub_build_parser(parser=None):


def set_hub_list_parser(parser=None):
"""
Set the parser for `hub list`
:param parser: the parser configure
:return: the new parser
"""
if not parser:
parser = set_base_parser()

Expand All @@ -38,6 +56,12 @@ def set_hub_list_parser(parser=None):


def set_hub_new_parser(parser=None):
"""
Set the parser for the `hub new` command
:param parser: the parser configure
:return: the new parser
"""
if not parser:
parser = set_base_parser()

Expand All @@ -48,6 +72,11 @@ def set_hub_new_parser(parser=None):


def set_hub_parser(parser=None):
"""
Set the parser for the hub
:param parser: the parser configure
"""
if not parser:
parser = set_base_parser()

Expand Down
5 changes: 5 additions & 0 deletions jina/parsers/hub/build.py
Expand Up @@ -4,6 +4,11 @@


def mixin_hub_build_parser(parser):
"""
Add the arguments for hub build to the parser
:param parser: the parser configure
"""
gp = add_arg_group(parser, title='Build')
gp.add_argument('path', type=str, help='path to the directory containing '
'Dockerfile, manifest.yml, README.md '
Expand Down
5 changes: 5 additions & 0 deletions jina/parsers/hub/list.py
Expand Up @@ -3,6 +3,11 @@


def mixin_hub_list_parser(parser):
"""
Add the arguments for hub list to the parser
:param parser: the parser configure
"""
gp = add_arg_group(parser, title='List')
gp.add_argument('--name', type=str,
help='The name of hub image')
Expand Down
4 changes: 4 additions & 0 deletions jina/parsers/hub/login.py
Expand Up @@ -5,6 +5,10 @@


def mixin_hub_docker_login_parser(parser):
"""
Add the options for the docker login
:param parser: the parser
"""
gp = add_arg_group(parser, title='Docker login')

gp.add_argument('--username', type=str, help='The Docker registry username',
Expand Down
4 changes: 4 additions & 0 deletions jina/parsers/hub/new.py
Expand Up @@ -3,6 +3,10 @@


def mixin_hub_new_parser(parser):
"""
Add the options for `hub new` to the parser
:param parser: the parser
"""
gp = add_arg_group(parser, title='Create')

gp.add_argument('--output-dir', type=str, default='.',
Expand Down
5 changes: 5 additions & 0 deletions jina/parsers/hub/pushpull.py
Expand Up @@ -3,6 +3,11 @@


def mixin_hub_pushpull_parser(parser):
"""
Add the arguments for hub push pull to the parser
:param parser: the parser configure
"""
gp = add_arg_group(parser, title='Push/Pull')
gp.add_argument('name', type=str, help='The name of the image.')
gp.add_argument('--no-overwrite', action='store_true', default=False,
Expand Down
7 changes: 7 additions & 0 deletions jina/parsers/optimizer.py
Expand Up @@ -2,11 +2,18 @@
from .base import set_base_parser
from .peapods.base import mixin_base_ppr_parser

# noinspection PyUnreachableCode
if False:
from argparse import ArgumentParser


def set_optimizer_parser(parser: 'ArgumentParser' = None):
"""
Set the parser for the optimizer
:param parser: an optional existing parser to build upon
:return: the parser
"""
if not parser:
parser = set_base_parser()
mixin_base_ppr_parser(parser)
Expand Down
8 changes: 8 additions & 0 deletions jina/parsers/peapods/runtimes/remote.py
Expand Up @@ -6,6 +6,10 @@


def mixin_remote_parser(parser):
"""
Add the options for remote expose
:param parser: the parser
"""
gp = add_arg_group(parser, title='Expose')

gp.add_argument('--host', type=str, default=__default_host__,
Expand All @@ -18,6 +22,10 @@ def mixin_remote_parser(parser):


def mixin_grpc_parser(parser=None):
"""
Add the options for gRPC
:param parser: the parser
"""
gp = add_arg_group(parser, title='GRPC/REST')

gp.add_argument('--max-message-size', type=int, default=-1,
Expand Down
6 changes: 6 additions & 0 deletions jina/parsers/ping.py
Expand Up @@ -3,6 +3,12 @@


def set_ping_parser(parser=None):
"""
Set the parser for `ping`
:param parser: an existing parser to build upon
:return: the parser
"""
if not parser:
parser = set_base_parser()

Expand Down

0 comments on commit b2f1616

Please sign in to comment.