style(env): satisfy ruff (datetime alias, line length, identity check) (#24118)
This commit is contained in:
1 parent
064fdecb67
commit
ae0827cec0
1 file changed
+12
-11
+12
-11
@@ -1,21 +1,21 @@
|
|||||||
|
import datetime as dt
|
||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import sys
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime, timezone
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from pathlib import Path
|
|
||||||
from cryptography.hazmat.primitives import serialization
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
import markdown
|
import markdown
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from cryptography.hazmat.primitives import serialization
|
||||||
|
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
@@ -43,7 +43,8 @@ except ImportError:
|
|||||||
|
|
||||||
DOCKER = os.environ.get('DOCKER', 'False').lower() == 'true'
|
DOCKER = os.environ.get('DOCKER', 'False').lower() == 'true'
|
||||||
|
|
||||||
# device type embedding models - "cpu" (default), "cuda" (nvidia gpu required) or "mps" (apple silicon) - choosing this right can lead to better performance
|
# device type for embedding models - "cpu" (default), "cuda" (nvidia gpu required), or "mps" (apple silicon)
|
||||||
|
# choosing this correctly can lead to better performance
|
||||||
USE_CUDA = os.environ.get('USE_CUDA_DOCKER', 'false')
|
USE_CUDA = os.environ.get('USE_CUDA_DOCKER', 'false')
|
||||||
|
|
||||||
if USE_CUDA.lower() == 'true':
|
if USE_CUDA.lower() == 'true':
|
||||||
@@ -87,7 +88,7 @@ class JSONFormatter(logging.Formatter):
|
|||||||
|
|
||||||
def format(self, record: logging.LogRecord) -> str:
|
def format(self, record: logging.LogRecord) -> str:
|
||||||
log_entry: dict[str, Any] = {
|
log_entry: dict[str, Any] = {
|
||||||
'ts': datetime.fromtimestamp(record.created, tz=timezone.utc).isoformat(timespec='milliseconds'),
|
'ts': dt.datetime.fromtimestamp(record.created, tz=dt.UTC).isoformat(timespec='milliseconds'),
|
||||||
'level': _LEVEL_MAP.get(record.levelname, record.levelname.lower()),
|
'level': _LEVEL_MAP.get(record.levelname, record.levelname.lower()),
|
||||||
'msg': record.getMessage(),
|
'msg': record.getMessage(),
|
||||||
'caller': record.name,
|
'caller': record.name,
|
||||||
@@ -180,7 +181,7 @@ def parse_section(section):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
changelog_path = BASE_DIR / 'CHANGELOG.md'
|
changelog_path = BASE_DIR / 'CHANGELOG.md'
|
||||||
with open(str(changelog_path.absolute()), 'r', encoding='utf8') as file:
|
with open(str(changelog_path.absolute()), encoding='utf8') as file:
|
||||||
changelog_content = file.read()
|
changelog_content = file.read()
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -339,7 +340,7 @@ DATABASE_SCHEMA = os.environ.get('DATABASE_SCHEMA', None)
|
|||||||
|
|
||||||
DATABASE_POOL_SIZE = os.environ.get('DATABASE_POOL_SIZE', None)
|
DATABASE_POOL_SIZE = os.environ.get('DATABASE_POOL_SIZE', None)
|
||||||
|
|
||||||
if DATABASE_POOL_SIZE != None:
|
if DATABASE_POOL_SIZE is not None:
|
||||||
try:
|
try:
|
||||||
DATABASE_POOL_SIZE = int(DATABASE_POOL_SIZE)
|
DATABASE_POOL_SIZE = int(DATABASE_POOL_SIZE)
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -652,7 +653,7 @@ if LICENSE_PUBLIC_KEY:
|
|||||||
-----BEGIN PUBLIC KEY-----
|
-----BEGIN PUBLIC KEY-----
|
||||||
{LICENSE_PUBLIC_KEY}
|
{LICENSE_PUBLIC_KEY}
|
||||||
-----END PUBLIC KEY-----
|
-----END PUBLIC KEY-----
|
||||||
""".encode('utf-8')
|
""".encode()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user