[docs]defset_pod_parser(parser=None):"""Set the parser for the Pod :param parser: an optional existing parser to build upon :return: the parser """ifnotparser:fromjina.parsers.baseimportset_base_parserparser=set_base_parser()fromjina.parsers.hubble.pullimportmixin_hub_pull_options_parserfromjina.parsers.orchestrate.baseimportmixin_base_ppr_parserfromjina.parsers.orchestrate.podimportmixin_pod_parserfromjina.parsers.orchestrate.runtimes.containerimport(mixin_container_runtime_parser,)fromjina.parsers.orchestrate.runtimes.distributedimport(mixin_distributed_feature_parser,)fromjina.parsers.orchestrate.runtimes.remoteimportmixin_remote_runtime_parserfromjina.parsers.orchestrate.runtimes.workerimportmixin_worker_runtime_parsermixin_base_ppr_parser(parser)mixin_worker_runtime_parser(parser)mixin_container_runtime_parser(parser)mixin_remote_runtime_parser(parser)mixin_distributed_feature_parser(parser)mixin_pod_parser(parser)mixin_hub_pull_options_parser(parser)mixin_head_parser(parser)returnparser
[docs]defset_deployment_parser(parser=None):"""Set the parser for the Deployment :param parser: an optional existing parser to build upon :return: the parser """ifnotparser:fromjina.parsers.baseimportset_base_parserparser=set_base_parser()set_pod_parser(parser)fromjina.parsers.orchestrate.deploymentimportmixin_base_deployment_parsermixin_base_deployment_parser(parser)returnparser
[docs]defset_gateway_parser(parser=None):"""Set the parser for the gateway arguments :param parser: an optional existing parser to build upon :return: the parser """ifnotparser:fromjina.parsers.baseimportset_base_parserparser=set_base_parser()fromjina.parsers.orchestrate.baseimportmixin_base_ppr_parserfromjina.parsers.orchestrate.podimportmixin_pod_parserfromjina.parsers.orchestrate.runtimes.remoteimport(mixin_gateway_parser,mixin_graphql_parser,mixin_http_gateway_parser,mixin_prefetch_parser,)fromjina.parsers.orchestrate.runtimes.workerimportmixin_worker_runtime_parsermixin_base_ppr_parser(parser)mixin_worker_runtime_parser(parser)mixin_prefetch_parser(parser)mixin_http_gateway_parser(parser)mixin_graphql_parser(parser)mixin_comm_protocol_parser(parser)mixin_gateway_parser(parser)mixin_pod_parser(parser)mixin_head_parser(parser)fromjina.enumsimportDeploymentRoleTypeparser.set_defaults(name='gateway',runtime_cls='GRPCGatewayRuntime',deployment_role=DeploymentRoleType.GATEWAY,)returnparser
[docs]defset_client_cli_parser(parser=None):"""Set the parser for the cli client :param parser: an optional existing parser to build upon :return: the parser """ifnotparser:fromjina.parsers.baseimportset_base_parserparser=set_base_parser()fromjina.parsers.clientimport(mixin_client_features_parser,mixin_comm_protocol_parser,)fromjina.parsers.orchestrate.runtimes.remoteimportmixin_client_gateway_parsermixin_client_gateway_parser(parser)mixin_client_features_parser(parser)mixin_comm_protocol_parser(parser)returnparser
[docs]defset_help_parser(parser=None):"""Set the parser for the jina help lookup :param parser: an optional existing parser to build upon :return: the parser """ifnotparser:fromjina.parsers.baseimportset_base_parserparser=set_base_parser()parser.add_argument('query',type=str,help='Lookup the usage & mention of the argument name in Jina API. The name can be fuzzy',)returnparser
[docs]defget_main_parser():"""The main parser for Jina :return: the parser """fromjina.parsers.baseimportset_base_parserfromjina.parsers.createimportset_new_project_parserfromjina.parsers.export_apiimportset_export_api_parserfromjina.parsers.flowimportset_flow_parserfromjina.parsers.helloworldimportset_hello_parserfromjina.parsers.helperimport_SHOW_ALL_ARGS,_chffromjina.parsers.hubbleimportset_hub_parserfromjina.parsers.pingimportset_ping_parser# create the top-level parserparser=set_base_parser()sp=parser.add_subparsers(dest='cli',description=''' Use `%(prog)-8s [sub-command] --help` to get detailed information about each sub-command. To show all commands, run `JINA_FULL_CLI=1 jina --help`. ''',required=True,)set_hello_parser(sp.add_parser('hello',help='👋 Hello Jina!',description='Start hello world demos.',formatter_class=_chf,))set_pod_parser(sp.add_parser('executor',help='Start an Executor',description='Start an Executor. Executor is how Jina processes Document.',formatter_class=_chf,))set_flow_parser(sp.add_parser('flow',description='Start a Flow. Flow is how Jina streamlines and distributes Executors.',help='Start a Flow',formatter_class=_chf,))set_ping_parser(sp.add_parser('ping',help='Ping an Executor',description='Ping a Deployment and check its network connectivity.',formatter_class=_chf,))set_new_project_parser(sp.add_parser('new',help='Create a new Jina project',description='Create a new Jina toy project with the predefined template.',formatter_class=_chf,))set_gateway_parser(sp.add_parser('gateway',description='Start a Gateway that receives client Requests via gRPC/REST interface',**(dict(help='Start a Gateway'))if_SHOW_ALL_ARGSelse{},formatter_class=_chf,))set_hub_parser(sp.add_parser('hub',help='Push/pull an Executor to/from Jina Hub',description='Push/Pull an Executor to/from Jina Hub',formatter_class=_chf,))set_help_parser(sp.add_parser('help',help='Show help text of a CLI argument',description='Show help text of a CLI argument',formatter_class=_chf,))# Below are low-level / internal / experimental CLIs, hidden from users by defaultset_pod_parser(sp.add_parser('pod',description='Start a Pod. ''You should rarely use this directly unless you ''are doing low-level orchestration',formatter_class=_chf,**(dict(help='Start a Pod'))if_SHOW_ALL_ARGSelse{},))set_deployment_parser(sp.add_parser('deployment',description='Start a Deployment. ''You should rarely use this directly unless you ''are doing low-level orchestration',formatter_class=_chf,**(dict(help='Start a Deployment'))if_SHOW_ALL_ARGSelse{},))set_client_cli_parser(sp.add_parser('client',description='Start a Python client that connects to a remote Jina gateway',formatter_class=_chf,**(dict(help='Start a Client'))if_SHOW_ALL_ARGSelse{},))set_export_api_parser(sp.add_parser('export-api',description='Export Jina API to JSON/YAML file for 3rd party applications',formatter_class=_chf,**(dict(help='Export Jina API to file'))if_SHOW_ALL_ARGSelse{},))returnparser