-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathserve.py
More file actions
234 lines (221 loc) · 5.6 KB
/
serve.py
File metadata and controls
234 lines (221 loc) · 5.6 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import click
from feast.constants import (
DEFAULT_FEATURE_TRANSFORMATION_SERVER_PORT,
DEFAULT_OFFLINE_SERVER_PORT,
DEFAULT_REGISTRY_SERVER_PORT,
)
from feast.repo_operations import create_feature_store
@click.command("serve")
@click.option(
"--host",
"-h",
type=click.STRING,
default="127.0.0.1",
show_default=True,
help="Specify a host for the server",
)
@click.option(
"--port",
"-p",
type=click.INT,
default=6566,
show_default=True,
help="Specify a port for the server",
)
@click.option(
"--type",
"-t",
"type_",
type=click.STRING,
default="http",
show_default=True,
help="Specify a server type: 'http' or 'grpc'",
)
@click.option(
"--no-access-log",
is_flag=True,
show_default=True,
help="Disable the Uvicorn access log",
)
@click.option(
"--workers",
"-w",
type=click.INT,
default=1,
show_default=True,
help="Number of worker",
)
@click.option(
"--keep-alive-timeout",
type=click.INT,
default=5,
show_default=True,
help="Timeout for keep alive",
)
@click.option(
"--registry_ttl_sec",
"-r",
help="Number of seconds after which the registry is refreshed",
type=click.INT,
default=5,
show_default=True,
)
@click.option(
"--key",
"-k",
"tls_key_path",
type=click.STRING,
default="",
show_default=False,
help="path to TLS certificate private key. You need to pass --cert as well to start server in TLS mode",
)
@click.option(
"--cert",
"-c",
"tls_cert_path",
type=click.STRING,
default="",
show_default=False,
help="path to TLS certificate public key. You need to pass --key as well to start server in TLS mode",
)
@click.option(
"--metrics",
"-m",
is_flag=True,
show_default=True,
help="Enable the Metrics Server",
)
@click.pass_context
def serve_command(
ctx: click.Context,
host: str,
port: int,
type_: str,
no_access_log: bool,
workers: int,
metrics: bool,
keep_alive_timeout: int,
tls_key_path: str,
tls_cert_path: str,
registry_ttl_sec: int = 5,
):
"""Start a feature server locally on a given port."""
if (tls_key_path and not tls_cert_path) or (not tls_key_path and tls_cert_path):
raise click.BadParameter(
"Please pass --cert and --key args to start the feature server in TLS mode."
)
store = create_feature_store(ctx)
store.serve(
host=host,
port=port,
type_=type_,
no_access_log=no_access_log,
workers=workers,
metrics=metrics,
keep_alive_timeout=keep_alive_timeout,
tls_key_path=tls_key_path,
tls_cert_path=tls_cert_path,
registry_ttl_sec=registry_ttl_sec,
)
@click.command("serve_transformations")
@click.option(
"--port",
"-p",
type=click.INT,
default=DEFAULT_FEATURE_TRANSFORMATION_SERVER_PORT,
help="Specify a port for the server",
)
@click.pass_context
def serve_transformations_command(ctx: click.Context, port: int):
"""[Experimental] Start a feature consumption server locally on a given port."""
store = create_feature_store(ctx)
store.serve_transformations(port)
@click.command("serve_registry")
@click.option(
"--port",
"-p",
type=click.INT,
default=DEFAULT_REGISTRY_SERVER_PORT,
help="Specify a port for the server",
)
@click.option(
"--key",
"-k",
"tls_key_path",
type=click.STRING,
default="",
show_default=False,
help="path to TLS certificate private key. You need to pass --cert as well to start server in TLS mode",
)
@click.option(
"--cert",
"-c",
"tls_cert_path",
type=click.STRING,
default="",
show_default=False,
help="path to TLS certificate public key. You need to pass --key as well to start server in TLS mode",
)
@click.pass_context
def serve_registry_command(
ctx: click.Context,
port: int,
tls_key_path: str,
tls_cert_path: str,
):
"""Start a registry server locally on a given port."""
if (tls_key_path and not tls_cert_path) or (not tls_key_path and tls_cert_path):
raise click.BadParameter(
"Please pass --cert and --key args to start the registry server in TLS mode."
)
store = create_feature_store(ctx)
store.serve_registry(port, tls_key_path, tls_cert_path)
@click.command("serve_offline")
@click.option(
"--host",
"-h",
type=click.STRING,
default="127.0.0.1",
show_default=True,
help="Specify a host for the server",
)
@click.option(
"--port",
"-p",
type=click.INT,
default=DEFAULT_OFFLINE_SERVER_PORT,
help="Specify a port for the server",
)
@click.option(
"--key",
"-k",
"tls_key_path",
type=click.STRING,
default="",
show_default=False,
help="path to TLS certificate private key. You need to pass --cert as well to start server in TLS mode",
)
@click.option(
"--cert",
"-c",
"tls_cert_path",
type=click.STRING,
default="",
show_default=False,
help="path to TLS certificate public key. You need to pass --key as well to start server in TLS mode",
)
@click.pass_context
def serve_offline_command(
ctx: click.Context,
host: str,
port: int,
tls_key_path: str,
tls_cert_path: str,
):
"""Start a remote server locally on a given host, port."""
if (tls_key_path and not tls_cert_path) or (not tls_key_path and tls_cert_path):
raise click.BadParameter(
"Please pass --cert and --key args to start the offline server in TLS mode."
)
store = create_feature_store(ctx)
store.serve_offline(host, port, tls_key_path, tls_cert_path)