This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
forked from yummyml/yummy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.py
174 lines (160 loc) · 4.63 KB
/
cli.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
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
import click
def package_installation_hint(package_name: str):
OKGREEN = '\033[92m'
ENDC = '\033[0m'
BOLD = "\033[1m"
print(f"\t{BOLD}Please install:{ENDC}\t{OKGREEN}{package_name}{ENDC}{BOLD}{ENDC}")
@click.group()
@click.pass_context
def cli(
ctx: click.Context
):
pass
@cli.group(name='delta')
def delta_cmd():
"""Delta server run command"""
pass
@delta_cmd.command("server")
@click.option("--host","-h",
type=click.STRING,
default="127.0.0.1",
show_default=True,
help='Host for the feature server.'
)
@click.option("--port","-p",
type=click.INT,
default=8080,
show_default=True,
help='Port for the feature server.'
)
@click.option("--filename","-f",
type=click.STRING,
default="delta.yaml",
show_default=True,
help='Configuration filename for the feature server.'
)
@click.option("--log-level",
type=click.STRING,
default="error",
show_default=True,
help='Log level for the feature server. One of: debug, info, error, warn'
)
@click.pass_context
def delta_server_command(
ctx: click.Context,
host: str,
port: int,
filename: str,
log_level: str,
):
"""Start rust delta."""
try:
import yummy_delta
yummy_delta.run(filename, host, port, log_level)
except ModuleNotFoundError:
package_installation_hint("yummy[delta]")
@delta_cmd.command("apply")
@click.option("--filename","-f",
type=click.STRING,
default="apply.yaml",
show_default=True,
help='Configuration filename for the feature server.'
)
@click.pass_context
def delta_apply_command(
ctx: click.Context,
filename: str,
):
"""Start rust apply delta."""
try:
import yummy_delta
yummy_delta.run_apply(filename)
except ModuleNotFoundError:
package_installation_hint("yummy[delta]")
@cli.group(name='features')
def features_cmd():
"""Features related commands"""
pass
@features_cmd.command("serve")
@click.option("--host","-h",
type=click.STRING,
default="127.0.0.1",
show_default=True,
help='Host for the feature server.'
)
@click.option("--port","-p",
type=click.INT,
default=6566,
show_default=True,
help='Port for the feature server.'
)
@click.option("--filename","-f",
type=click.STRING,
default="feature_store.yaml",
show_default=True,
help='Configuration filename for the feature server.'
)
@click.option("--log-level",
type=click.STRING,
default="error",
show_default=True,
help='Log level for the feature server. One of: debug, info, error, warn'
)
@click.pass_context
def features_serve_command(
ctx: click.Context,
host: str,
port: int,
filename: str,
log_level: str,
):
"""Start rust feature server."""
try:
import yummy_features
yummy_features.serve(filename, host, port, log_level)
except ModuleNotFoundError:
package_installation_hint("yummy[features]")
@cli.group(name='models')
def models_cmd():
"""Models related commands"""
pass
@models_cmd.command("serve")
@click.option("--host","-h",
type=click.STRING,
default="127.0.0.1",
show_default=True,
help='Host for the feature server.'
)
@click.option("--port","-p",
type=click.INT,
default=5000,
show_default=True,
help='Port for the feature server.'
)
@click.option("--model-uri","-m",
type=click.STRING,
required=True,
help='Local model path.'
)
@click.option("--log-level",
type=click.STRING,
default="error",
show_default=True,
help='Log level for the feature server. One of: debug, info, error, warn'
)
@click.pass_context
def models_serve_command(
ctx: click.Context,
host: str,
port: int,
model_uri: str,
log_level: str,
):
"""Start mlflow model server."""
try:
import yummy_mlflow
yummy_mlflow.serve(model_uri, host, port, log_level)
except ModuleNotFoundError:
package_installation_hint("yummy[mlflow]")
if __name__ == '__main__':
cli()