-
Notifications
You must be signed in to change notification settings - Fork 601
/
deploy_models.py
51 lines (42 loc) · 1.42 KB
/
deploy_models.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
import pip
import os
import sys
import platform
import subprocess
from pathlib import Path
from tabpy.models.utils import setup_utils
# pip 10.0 introduced a breaking change that moves the location of main
try:
from pip import main
except ImportError:
from pip._internal import main
def install_dependencies(packages):
pip_arg = ["install"] + packages + ["--no-cache-dir"]
if hasattr(pip, "main"):
pip.main(pip_arg)
else:
pip._internal.main(pip_arg)
def main():
install_dependencies(["sklearn", "pandas", "numpy", "textblob", "nltk", "scipy"])
print("==================================================================")
# Determine if we run python or python3
if platform.system() == "Windows":
py = "python"
else:
py = "python3"
if len(sys.argv) > 1:
config_file_path = sys.argv[1]
else:
config_file_path = setup_utils.get_default_config_file_path()
print(f"Using config file at {config_file_path}")
port, auth_on, prefix = setup_utils.parse_config(config_file_path)
if auth_on:
auth_args = setup_utils.get_creds()
else:
auth_args = []
directory = str(Path(__file__).resolve().parent / "scripts")
# Deploy each model in the scripts directory
for filename in os.listdir(directory):
subprocess.run([py, f"{directory}/{filename}", config_file_path] + auth_args)
if __name__ == "__main__":
main()