From e6db0d0acc8f0431db742521cf6fc375969ed7e6 Mon Sep 17 00:00:00 2001 From: slatinsky Date: Tue, 29 Aug 2023 22:08:22 +0200 Subject: [PATCH] preprocess - always flush to console --- backend/preprocess/AssetProcessor.py | 2 ++ backend/preprocess/ChannelCache.py | 2 ++ backend/preprocess/Downloader.py | 4 ++++ backend/preprocess/FileFinder.py | 5 ++++- backend/preprocess/JsonFileStreamer.py | 3 +++ backend/preprocess/JsonProcessor.py | 3 ++- backend/preprocess/MongoDatabase.py | 4 ++++ backend/preprocess/Timer.py | 2 ++ backend/preprocess/helpers.py | 4 ++++ 9 files changed, 27 insertions(+), 2 deletions(-) diff --git a/backend/preprocess/AssetProcessor.py b/backend/preprocess/AssetProcessor.py index 5d36bd33..95a142f9 100644 --- a/backend/preprocess/AssetProcessor.py +++ b/backend/preprocess/AssetProcessor.py @@ -1,4 +1,5 @@ +import functools import os import re from colorthief import ColorThief @@ -8,6 +9,7 @@ from FileFinder import FileFinder from MongoDatabase import MongoDatabase +print = functools.partial(print, flush=True) class AssetProcessor: def __init__(self, file_finder: FileFinder, database: MongoDatabase): diff --git a/backend/preprocess/ChannelCache.py b/backend/preprocess/ChannelCache.py index f9627b88..d96e47af 100644 --- a/backend/preprocess/ChannelCache.py +++ b/backend/preprocess/ChannelCache.py @@ -1,9 +1,11 @@ +import functools import os from MongoDatabase import MongoDatabase from helpers import is_compiled +print = functools.partial(print, flush=True) class ChannelCache: """ diff --git a/backend/preprocess/Downloader.py b/backend/preprocess/Downloader.py index 740c3798..015f6dc9 100644 --- a/backend/preprocess/Downloader.py +++ b/backend/preprocess/Downloader.py @@ -1,10 +1,14 @@ +import functools import os import requests +print = functools.partial(print, flush=True) + + def download_gg(output_directory): """ diff --git a/backend/preprocess/FileFinder.py b/backend/preprocess/FileFinder.py index 4c513944..cb1f3d88 100644 --- a/backend/preprocess/FileFinder.py +++ b/backend/preprocess/FileFinder.py @@ -1,7 +1,10 @@ +import functools import glob import re import os -import traceback + +print = functools.partial(print, flush=True) + class FileFinder(): """ diff --git a/backend/preprocess/JsonFileStreamer.py b/backend/preprocess/JsonFileStreamer.py index 8ea8f5d7..7d5e83ae 100644 --- a/backend/preprocess/JsonFileStreamer.py +++ b/backend/preprocess/JsonFileStreamer.py @@ -1,6 +1,9 @@ +import functools import ijson import datetime +print = functools.partial(print, flush=True) + class JsonFileStreamer(): def __init__(self, json_path: str): diff --git a/backend/preprocess/JsonProcessor.py b/backend/preprocess/JsonProcessor.py index 27a4635c..698b886a 100644 --- a/backend/preprocess/JsonProcessor.py +++ b/backend/preprocess/JsonProcessor.py @@ -1,6 +1,7 @@ import copy +import functools import hashlib from itertools import zip_longest import os @@ -16,7 +17,7 @@ from JsonFileStreamer import JsonFileStreamer from helpers import find_additional_missing_numbers, get_emoji_code, pad_id, batched - +print = functools.partial(print, flush=True) class JsonProcessor: diff --git a/backend/preprocess/MongoDatabase.py b/backend/preprocess/MongoDatabase.py index e7661821..05a5984f 100644 --- a/backend/preprocess/MongoDatabase.py +++ b/backend/preprocess/MongoDatabase.py @@ -1,6 +1,10 @@ +import functools from pymongo import MongoClient +print = functools.partial(print, flush=True) + + class MongoDatabase(): """ Connects to the MongoDB database diff --git a/backend/preprocess/Timer.py b/backend/preprocess/Timer.py index 9f8673b3..3efa85ff 100644 --- a/backend/preprocess/Timer.py +++ b/backend/preprocess/Timer.py @@ -1,5 +1,7 @@ +import functools import time +print = functools.partial(print, flush=True) class Timer(object): def __init__(self, name=None): diff --git a/backend/preprocess/helpers.py b/backend/preprocess/helpers.py index 366ea5f8..6fb28f3b 100644 --- a/backend/preprocess/helpers.py +++ b/backend/preprocess/helpers.py @@ -1,7 +1,11 @@ +import functools from itertools import islice import json import os +print = functools.partial(print, flush=True) + + with open('emojiIndex.json', 'r', encoding='utf8') as f: emoji_index = json.load(f)