| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pip |
||
| 2 | import os |
||
| 3 | import sys |
||
| 4 | import platform |
||
| 5 | import subprocess |
||
| 6 | from pathlib import Path |
||
| 7 | from tabpy.models.utils import setup_utils |
||
| 8 | |||
| 9 | # pip 10.0 introduced a breaking change that moves the location of main |
||
| 10 | try: |
||
| 11 | from pip import main |
||
| 12 | except ImportError: |
||
| 13 | from pip._internal import main |
||
| 14 | |||
| 15 | |||
| 16 | def install_dependencies(packages): |
||
| 17 | pip_arg = ["install"] + packages + ["--no-cache-dir"] |
||
| 18 | if hasattr(pip, "main"): |
||
| 19 | pip.main(pip_arg) |
||
| 20 | else: |
||
| 21 | pip._internal.main(pip_arg) |
||
| 22 | |||
| 23 | |||
| 24 | def main(): |
||
| 25 | install_dependencies(["sklearn", "pandas", "numpy", "textblob", "nltk", "scipy"]) |
||
| 26 | print("==================================================================") |
||
| 27 | # Determine if we run python or python3 |
||
| 28 | if platform.system() == "Windows": |
||
| 29 | py = "python" |
||
| 30 | else: |
||
| 31 | py = "python3" |
||
| 32 | |||
| 33 | if len(sys.argv) > 1: |
||
| 34 | config_file_path = sys.argv[1] |
||
| 35 | else: |
||
| 36 | config_file_path = setup_utils.get_default_config_file_path() |
||
| 37 | print(f"Using config file at {config_file_path}") |
||
| 38 | port, auth_on, prefix = setup_utils.parse_config(config_file_path) |
||
| 39 | if auth_on: |
||
| 40 | auth_args = setup_utils.get_creds() |
||
| 41 | else: |
||
| 42 | auth_args = [] |
||
| 43 | |||
| 44 | directory = str(Path(__file__).resolve().parent / "scripts") |
||
| 45 | # Deploy each model in the scripts directory |
||
| 46 | for filename in os.listdir(directory): |
||
| 47 | subprocess.run([py, f"{directory}/{filename}", config_file_path] + auth_args) |
||
| 48 | |||
| 49 | |||
| 50 | if __name__ == "__main__": |
||
| 51 | main() |
||
| 52 |