def api_start(project_id): # noqa: F401 """Start training the model """ # get the CLI arguments asr_kwargs = deepcopy(app.config['asr_kwargs']) # add the machine learning model to the kwargs # TODO@{Jonathan} validate model choice on server side ml_model = request.form.get("machine_learning_model", None) if ml_model: asr_kwargs["model"] = ml_model # write the kwargs to a file with open(get_kwargs_path(project_id), "w") as fp: json.dump(asr_kwargs, fp) # start training the model py_exe = _get_executable() run_command = [ py_exe, "-m", "asreview", "web_run_model", project_id, "--label_method", "prior" ] subprocess.Popen(run_command) response = jsonify({'success': True}) response.headers.add('Access-Control-Allow-Origin', '*') return response
def api_start(project_id): # noqa: F401 """Start training the model """ py_exe = _get_executable() run_command = [ py_exe, "-m", "asreview", "web_run_model", project_id, "--label_method", "prior" ] subprocess.Popen(run_command) response = jsonify({'success': True}) response.headers.add('Access-Control-Allow-Origin', '*') return response
def api_start(project_id): # noqa: F401 """Start training the model """ try: # start training the model py_exe = _get_executable() run_command = [ py_exe, "-m", "asreview", "web_run_model", project_id, "--label_method", "prior" ] subprocess.Popen(run_command) except Exception as err: logging.error(err) return jsonify(message="Failed to train the model."), 500 response = jsonify({'success': True}) response.headers.add('Access-Control-Allow-Origin', '*') return response