예제 #1
0
    def __init__(self):
        self._name = None  # model name

        self._work_dir = None  # work dir is the place you want to create model
        self._model_dir = None  # model dir

        self._model_config_file_name = "ModelConfig.json"
        self.model_config_file = None  # full path of the model config file

        self._os_platform = Helper.get_os_platform()
        self._shifu_home = Helper.get_shifu_home()   # home directory where shifu script with java package
        self._main_script = path.join(self._shifu_home, "java", "bin", "shifu")  # script to running command
예제 #2
0
    def new(self, name, work_dir=None):
        try:
            self._init_working_directory(work_dir, name)
        except ShifuException as exception:
            print(exception.get_message())

        command_list = ['bash', self._main_script, 'new', self._name]
        status, output = Helper.run_shell(command_list)
        if status == CommandRunningStatus.SUCCESS:
            self._change_to_model_dir()
            print(
                "Configure your ModelConfig.json in %s or directly do initialization step by 'shifu.init()'"
                % self.model_config_file)
            Helper.edit_file(self._os_platform, self.model_config_file)
        else:
            print(
                "Shifu.new() failed! Please check if you successfully install pyshifu."
            )
예제 #3
0
파일: shell.py 프로젝트: m4rkl1u/pyshifu
 def _run_command(self, command, next_command=None):
     command_list = ['bash', self._main_script, command]
     status, output = Helper.run_shell(command_list)
     if status == CommandRunningStatus.SUCCESS:
         if next_command:
             print(
                 "Configure your ModelConfig.json in %s or directly do initialization step by 'shifu.%s()'"
                 % self.model_config_file, next_command)
             # Helper.edit_file(self._os_platform, self.model_config_file)
     else:
         print(
             "Shifu.%s() failed! Please check if you successfully install pyshifu."
             % command)
예제 #4
0
파일: shell.py 프로젝트: m4rkl1u/pyshifu
 def _run_command_new(self, model_name):
     command_list = ['bash', self._main_script, 'new', model_name]
     status, output = Helper.run_shell(command_list)
     if status == CommandRunningStatus.SUCCESS:
         self._change_to_model_dir()
         print(
             "Configure your ModelConfig.json in %s or directly do initialization step by 'shifu.init()'"
             % self.model_config_file)
         # Helper.edit_file(self._os_platform, self.model_config_file)
         self._model_config = ConfigHelper.load_json_data(
             self.model_config_file)
     else:
         print(
             "Shifu.new() failed! Please check if you successfully install pyshifu."
         )
예제 #5
0
 def __run_command(self, command):
     command_list = ['bash', self._main_script, command]
     return Helper.run_shell(command_list)