Fixed log not displaying (#3946)
Browse files### What problem does this PR solve?
Fixed log not displaying
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- .github/workflows/tests.yml +1 -0
- api/ragflow_server.py +3 -5
- api/utils/log_utils.py +3 -2
- rag/nlp/__init__.py +1 -1
- rag/svr/task_executor.py +5 -9
.github/workflows/tests.yml
CHANGED
@@ -54,6 +54,7 @@ jobs:
|
|
54 |
uses: astral-sh/ruff-action@v2
|
55 |
with:
|
56 |
version: ">=0.8.2"
|
|
|
57 |
|
58 |
- name: Build ragflow:nightly-slim
|
59 |
run: |
|
|
|
54 |
uses: astral-sh/ruff-action@v2
|
55 |
with:
|
56 |
version: ">=0.8.2"
|
57 |
+
args: "check --ignore E402"
|
58 |
|
59 |
- name: Build ragflow:nightly-slim
|
60 |
run: |
|
api/ragflow_server.py
CHANGED
@@ -18,10 +18,11 @@
|
|
18 |
# from beartype.claw import beartype_all # <-- you didn't sign up for this
|
19 |
# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code
|
20 |
|
21 |
-
import logging
|
22 |
-
import os
|
23 |
from api.utils.log_utils import initRootLogger
|
|
|
24 |
|
|
|
|
|
25 |
import signal
|
26 |
import sys
|
27 |
import time
|
@@ -41,9 +42,6 @@ from api.versions import get_ragflow_version
|
|
41 |
from api.utils import show_configs
|
42 |
from rag.settings import print_rag_settings
|
43 |
|
44 |
-
LOG_LEVELS = os.environ.get("LOG_LEVELS", "")
|
45 |
-
initRootLogger("ragflow_server", LOG_LEVELS)
|
46 |
-
|
47 |
|
48 |
def update_progress():
|
49 |
while True:
|
|
|
18 |
# from beartype.claw import beartype_all # <-- you didn't sign up for this
|
19 |
# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code
|
20 |
|
|
|
|
|
21 |
from api.utils.log_utils import initRootLogger
|
22 |
+
initRootLogger("ragflow_server")
|
23 |
|
24 |
+
import logging
|
25 |
+
import os
|
26 |
import signal
|
27 |
import sys
|
28 |
import time
|
|
|
42 |
from api.utils import show_configs
|
43 |
from rag.settings import print_rag_settings
|
44 |
|
|
|
|
|
|
|
45 |
|
46 |
def update_progress():
|
47 |
while True:
|
api/utils/log_utils.py
CHANGED
@@ -28,7 +28,7 @@ def get_project_base_directory():
|
|
28 |
)
|
29 |
return PROJECT_BASE
|
30 |
|
31 |
-
def initRootLogger(logfile_basename: str,
|
32 |
logger = logging.getLogger()
|
33 |
if logger.hasHandlers():
|
34 |
return
|
@@ -48,8 +48,9 @@ def initRootLogger(logfile_basename: str, log_levels: str, log_format: str = "%(
|
|
48 |
|
49 |
logging.captureWarnings(True)
|
50 |
|
|
|
51 |
pkg_levels = {}
|
52 |
-
for pkg_name_level in
|
53 |
terms = pkg_name_level.split("=")
|
54 |
if len(terms)!= 2:
|
55 |
continue
|
|
|
28 |
)
|
29 |
return PROJECT_BASE
|
30 |
|
31 |
+
def initRootLogger(logfile_basename: str, log_format: str = "%(asctime)-15s %(levelname)-8s %(process)d %(message)s"):
|
32 |
logger = logging.getLogger()
|
33 |
if logger.hasHandlers():
|
34 |
return
|
|
|
48 |
|
49 |
logging.captureWarnings(True)
|
50 |
|
51 |
+
LOG_LEVELS = os.environ.get("LOG_LEVELS", "")
|
52 |
pkg_levels = {}
|
53 |
+
for pkg_name_level in LOG_LEVELS.split(","):
|
54 |
terms = pkg_name_level.split("=")
|
55 |
if len(terms)!= 2:
|
56 |
continue
|
rag/nlp/__init__.py
CHANGED
@@ -22,11 +22,11 @@ from rag.utils import num_tokens_from_string
|
|
22 |
from . import rag_tokenizer
|
23 |
import re
|
24 |
import copy
|
|
|
25 |
import roman_numbers as r
|
26 |
from word2number import w2n
|
27 |
from cn2an import cn2an
|
28 |
from PIL import Image
|
29 |
-
import json
|
30 |
|
31 |
import chardet
|
32 |
|
|
|
22 |
from . import rag_tokenizer
|
23 |
import re
|
24 |
import copy
|
25 |
+
import json
|
26 |
import roman_numbers as r
|
27 |
from word2number import w2n
|
28 |
from cn2an import cn2an
|
29 |
from PIL import Image
|
|
|
30 |
|
31 |
import chardet
|
32 |
|
rag/svr/task_executor.py
CHANGED
@@ -17,13 +17,14 @@
|
|
17 |
# from beartype.claw import beartype_all # <-- you didn't sign up for this
|
18 |
# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code
|
19 |
|
20 |
-
import logging
|
21 |
import sys
|
22 |
-
import os
|
23 |
-
|
24 |
from api.utils.log_utils import initRootLogger
|
|
|
|
|
|
|
25 |
|
26 |
-
|
|
|
27 |
from datetime import datetime
|
28 |
import json
|
29 |
import hashlib
|
@@ -57,11 +58,6 @@ from rag.utils import rmSpace, num_tokens_from_string
|
|
57 |
from rag.utils.redis_conn import REDIS_CONN, Payload
|
58 |
from rag.utils.storage_factory import STORAGE_IMPL
|
59 |
|
60 |
-
CONSUMER_NO = "0" if len(sys.argv) < 2 else sys.argv[1]
|
61 |
-
CONSUMER_NAME = "task_executor_" + CONSUMER_NO
|
62 |
-
LOG_LEVELS = os.environ.get("LOG_LEVELS", "")
|
63 |
-
initRootLogger(CONSUMER_NAME, LOG_LEVELS)
|
64 |
-
|
65 |
BATCH_SIZE = 64
|
66 |
|
67 |
FACTORY = {
|
|
|
17 |
# from beartype.claw import beartype_all # <-- you didn't sign up for this
|
18 |
# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code
|
19 |
|
|
|
20 |
import sys
|
|
|
|
|
21 |
from api.utils.log_utils import initRootLogger
|
22 |
+
CONSUMER_NO = "0" if len(sys.argv) < 2 else sys.argv[1]
|
23 |
+
CONSUMER_NAME = "task_executor_" + CONSUMER_NO
|
24 |
+
initRootLogger(CONSUMER_NAME)
|
25 |
|
26 |
+
import logging
|
27 |
+
import os
|
28 |
from datetime import datetime
|
29 |
import json
|
30 |
import hashlib
|
|
|
58 |
from rag.utils.redis_conn import REDIS_CONN, Payload
|
59 |
from rag.utils.storage_factory import STORAGE_IMPL
|
60 |
|
|
|
|
|
|
|
|
|
|
|
61 |
BATCH_SIZE = 64
|
62 |
|
63 |
FACTORY = {
|