-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.py
More file actions
65 lines (53 loc) · 1.48 KB
/
generate.py
File metadata and controls
65 lines (53 loc) · 1.48 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
import os
import shutil
import subprocess
import fire
import config
from utils import safe_remove, unzip
class CLI:
"""Simple wrapper class to expose to "fire" to auto-generate a command line
interface for this project.
"""
@staticmethod
def clients():
try:
shutil.rmtree("clients")
except:
pass
os.makedirs("clients")
generate_client_for("python")
generate_client_for("java")
generate_client_for("scala")
# generate_client_for("r")
@staticmethod
def copy_server_files(path):
shutil.copyfile(os.path.join(path, "saved_model.zip"), config.PATHMIND_POLICY)
shutil.copyfile(os.path.join(path, "schema.yaml"), config.PATHMIND_SCHEMA)
unzip(config.PATHMIND_POLICY)
@staticmethod
def unzip():
unzip(config.PATHMIND_POLICY)
@staticmethod
def clean():
safe_remove(config.PATHMIND_POLICY)
safe_remove(config.PATHMIND_SCHEMA)
safe_remove(config.LOCAL_SWAGGER)
safe_remove(config.CLIENTS_ZIP)
shutil.rmtree(config.MODEL_FOLDER)
os.makedirs(config.MODEL_FOLDER)
def generate_client_for(lang):
os.makedirs(f"./clients/{lang}")
subprocess.run(
[
"./swagger-codegen",
"generate",
"-i",
config.LOCAL_SWAGGER,
"-l",
lang,
"-o",
f"clients/{lang}",
]
)
if __name__ == "__main__":
fire.Fire(CLI)