def train_clean(dataset_id): # Load the dataset dataset = data_service.get_dataset(dataset_id) train(dataset)
def train_existing(model_type, dataset_id): if data_service.get_dataset(dataset_id) is None: return jsonify({"message": "Dataset not found."}), 400 if model_type == SENTIMENT_MODEL_TYPE: if sentiment_service.is_busy(): return jsonify( {"message": "System is busy. Please try again later."}), 500 # endif if config.ADDITIONAL_DEBUGGING_SUPPORT == True: thread = threading.Thread(target=sentiment_service.train_clean, args=(dataset_id, )) thread.start() else: process = Process(target=sentiment_service.train_clean, args=(dataset_id, )) process.start() elif model_type == CATEGORY_MODEL_TYPE: if category_service.is_busy(): return jsonify( {"message": "System is busy. Please try again later."}), 500 # endif if config.ADDITIONAL_DEBUGGING_SUPPORT == True: thread = threading.Thread(target=category_service.train_clean, args=(dataset_id, )) thread.start() else: process = Process(target=category_service.train_clean, args=(dataset_id, )) process.start() elif model_type == STOCK_MODEL_TYPE: if stock_service.is_busy(): return jsonify( {"message": "System is busy. Please try again later."}), 500 # endif if config.ADDITIONAL_DEBUGGING_SUPPORT == True: thread = threading.Thread(target=stock_service.train_clean, args=(dataset_id, )) thread.start() else: process = Process(target=stock_service.train_clean, args=(dataset_id, )) process.start() # endif elif model_type == STOCK_V2_MODEL_TYPE: if stock_service_v2.is_busy(): return jsonify( {"message": "System is busy. Please try again later."}), 500 # endif if config.ADDITIONAL_DEBUGGING_SUPPORT == True: thread = threading.Thread(target=stock_service_v2.train_clean, args=(dataset_id, )) thread.start() else: process = Process(target=stock_service_v2.train_clean, args=(dataset_id, )) process.start() # endif return jsonify({'message': 'Training started.'})