def predict_category(output: str): from robotoff.elasticsearch.category.predict import predict_from_dataset from robotoff.utils import dump_jsonl from robotoff.products import ProductDataset from robotoff import settings dataset = ProductDataset(settings.JSONL_DATASET_PATH) dump_jsonl(output, predict_from_dataset(dataset))
def predict_category(output: str): from robotoff.elasticsearch.category.predict import predict_from_dataset from robotoff.utils import dump_jsonl from robotoff.products import ProductDataset from robotoff import settings dataset = ProductDataset(settings.JSONL_DATASET_PATH) insights = predict_from_dataset(dataset) dict_insights = (i.to_dict() for i in insights) dump_jsonl(output, dict_insights)
def generate_insights(): """Generate and import category insights from the latest dataset dump, for products added at day-1.""" logger.info("Generating new category insights") product_store: ProductStore = CACHED_PRODUCT_STORE.get() importer = CategoryImporter(product_store) datetime_threshold = datetime.datetime.utcnow().replace( hour=0, minute=0, second=0, microsecond=0) - datetime.timedelta(days=1) dataset = ProductDataset(settings.JSONL_DATASET_PATH) category_insights_iter = predict_from_dataset(dataset, datetime_threshold) imported = importer.import_insights(category_insights_iter) logger.info("{} category insights imported".format(imported))
def generate_insights(): """Generate and import category insights from the latest dataset dump, for products added at day-1.""" logger.info("Generating new category insights") datetime_threshold = datetime.datetime.utcnow().replace( hour=0, minute=0, second=0, microsecond=0) - datetime.timedelta(days=1) dataset = ProductDataset(settings.JSONL_DATASET_PATH) product_predictions_iter = predict_from_dataset(dataset, datetime_threshold) imported = import_insights( product_predictions_iter, server_domain=settings.OFF_SERVER_DOMAIN, automatic=False, ) logger.info("{} category insights imported".format(imported))