def add_files_to_text_set(text_set_id, file_ids): text_set = get(text_set_id) # type: TextSet for file_id in file_ids: file = file_logic.get(file_id) if any(text_set_file for text_set_file in text_set.files if text_set_file.file.id == file.id): continue text_set_file = TextSetFile() text_set_file.file = file text_set.files.append(text_set_file) db.session.commit()
def init_extending(vocabulary_id, file_ids): vocabulary = get(vocabulary_id) for file_id in file_ids: if any(voc_file for voc_file in vocabulary.files if voc_file.id == file_id): continue file = file_logic.get(file_id) vocabulary.files.append(file) db.session.commit() Thread(target=extend, args=( vocabulary_id, flask.current_app._get_current_object(), )).start() return vocabulary
def init_training(model_id, file_ids, extend_vocabulary): model = change_status(model_id, EmbeddingModelStatus.created) for file_id in file_ids: file = file_logic.get(file_id) if not any(model_file for model_file in model.files if model_file.id == file_id): model.files.append(file) if extend_vocabulary and not any(voc_file for voc_file in model.vocabulary.files if voc_file.id == file_id): model.vocabulary.files.append(file) db.session.commit() Thread(target=train, args=( model_id, flask.current_app._get_current_object(), )).start() return model
def init_training(net_id, file_ids, extend_vocabulary): net = change_status(net_id, NetStatus.created) # type: Net for file_id in file_ids: file = file_logic.get(file_id) if not any(net_file for net_file in net.files if net_file.id == file_id): net.files.append(file) if not any(model_file for model_file in net.embedding_model.files if model_file.id not in file_ids): net.embedding_model.files.append(file) if extend_vocabulary and not any( voc_file for voc_file in net.embedding_model.vocabulary.files if voc_file.id == file_id): net.embedding_model.vocabulary.files.append(file) db.session.commit() Thread(target=train, args=( net_id, flask.current_app._get_current_object(), )).start() return net
def get(file_id): file_id = int(file_id) file = file_logic.get(file_id) return jsonify(file.to_dict())
def download(file_id): file_id = int(file_id) file = file_logic.get(file_id) return send_file(file.path, file.mimetype, True, file.name)