-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
pea.py
111 lines (95 loc) · 3.31 KB
/
pea.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"""Argparser module for Pea runtimes"""
import argparse
from ..helper import add_arg_group, _SHOW_ALL_ARGS, KVAppendAction
from ...enums import PeaRoleType, RuntimeBackendType
def mixin_pea_parser(parser):
"""Mixing in arguments required by :class:`BasePea` into the given parser.
:param parser: the parser instance to which we add arguments
"""
gp = add_arg_group(parser, title='Pea')
gp.add_argument(
'--daemon',
action='store_true',
default=False,
help='The Pea attempts to terminate all of its Runtime child processes/threads on existing. '
'setting it to true basically tell the Pea do not wait on the Runtime when closing',
)
gp.add_argument(
'--runtime-backend',
'--runtime',
type=RuntimeBackendType.from_string,
choices=list(RuntimeBackendType),
default=RuntimeBackendType.PROCESS,
help='The parallel backend of the runtime inside the Pea',
)
gp.add_argument(
'--runtime-cls',
type=str,
default='ZEDRuntime',
help='The runtime class to run inside the Pea',
)
gp.add_argument(
'--timeout-ready',
type=int,
default=600000,
help='The timeout in milliseconds of a Pea waits for the runtime to be ready, -1 for waiting '
'forever',
)
gp.add_argument(
'--env',
action=KVAppendAction,
metavar='KEY: VALUE',
nargs='*',
help='The map of environment variables that are available inside runtime',
)
gp.add_argument(
'--expose-public',
action='store_true',
default=False,
help='If set, expose the public IP address to remote when necessary, by default it exposes'
'private IP address, which only allows accessing under the same network/subnet. Important to '
'set this to true when the Pea will receive input connections from remote Peas',
)
# hidden CLI used for internal only
gp.add_argument(
'--shard-id',
'--pea-id',
type=int,
default=0,
help='defines the suffix for the workspace path of the pea`'
if _SHOW_ALL_ARGS
else argparse.SUPPRESS,
)
gp.add_argument(
'--pea-role',
type=PeaRoleType.from_string,
choices=list(PeaRoleType),
default=PeaRoleType.SINGLETON,
help='The role of this Pea in a Pod' if _SHOW_ALL_ARGS else argparse.SUPPRESS,
)
gp.add_argument(
'--noblock-on-start',
action='store_true',
default=False,
help='If set, starting a Pea/Pod does not block the thread/process. It then relies on '
'`wait_start_success` at outer function for the postpone check.'
if _SHOW_ALL_ARGS
else argparse.SUPPRESS,
)
gp.add_argument(
'--shards',
'--parallel',
type=int,
default=1,
help='The number of shards in the pod running at the same time, '
'`port_in` and `port_out` will be set to random, '
'and routers will be added automatically when necessary',
)
gp.add_argument(
'--replicas',
type=int,
default=1,
help='The number of replicas in the pod, '
'`port_in` and `port_out` will be set to random, '
'and routers will be added automatically when necessary',
)