example for logging (#24441)
This commit is contained in:
@@ -5,6 +5,8 @@ from configs import dify_config
|
|||||||
from contexts.wrapper import RecyclableContextVar
|
from contexts.wrapper import RecyclableContextVar
|
||||||
from dify_app import DifyApp
|
from dify_app import DifyApp
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
# Application Factory Function
|
# Application Factory Function
|
||||||
@@ -32,7 +34,7 @@ def create_app() -> DifyApp:
|
|||||||
initialize_extensions(app)
|
initialize_extensions(app)
|
||||||
end_time = time.perf_counter()
|
end_time = time.perf_counter()
|
||||||
if dify_config.DEBUG:
|
if dify_config.DEBUG:
|
||||||
logging.info("Finished create_app (%s ms)", round((end_time - start_time) * 1000, 2))
|
logger.info("Finished create_app (%s ms)", round((end_time - start_time) * 1000, 2))
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
@@ -93,14 +95,14 @@ def initialize_extensions(app: DifyApp):
|
|||||||
is_enabled = ext.is_enabled() if hasattr(ext, "is_enabled") else True
|
is_enabled = ext.is_enabled() if hasattr(ext, "is_enabled") else True
|
||||||
if not is_enabled:
|
if not is_enabled:
|
||||||
if dify_config.DEBUG:
|
if dify_config.DEBUG:
|
||||||
logging.info("Skipped %s", short_name)
|
logger.info("Skipped %s", short_name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
ext.init_app(app)
|
ext.init_app(app)
|
||||||
end_time = time.perf_counter()
|
end_time = time.perf_counter()
|
||||||
if dify_config.DEBUG:
|
if dify_config.DEBUG:
|
||||||
logging.info("Loaded %s (%s ms)", short_name, round((end_time - start_time) * 1000, 2))
|
logger.info("Loaded %s (%s ms)", short_name, round((end_time - start_time) * 1000, 2))
|
||||||
|
|
||||||
|
|
||||||
def create_migrations_app():
|
def create_migrations_app():
|
||||||
|
@@ -410,18 +410,18 @@ class TestAnnotationService:
|
|||||||
app, account = self._create_test_app_and_account(db_session_with_containers, mock_external_service_dependencies)
|
app, account = self._create_test_app_and_account(db_session_with_containers, mock_external_service_dependencies)
|
||||||
|
|
||||||
# Create annotations with specific keywords
|
# Create annotations with specific keywords
|
||||||
unique_keyword = fake.word()
|
unique_keyword = f"unique_{fake.uuid4()[:8]}"
|
||||||
annotation_args = {
|
annotation_args = {
|
||||||
"question": f"Question with {unique_keyword} keyword",
|
"question": f"Question with {unique_keyword} keyword",
|
||||||
"answer": f"Answer with {unique_keyword} keyword",
|
"answer": f"Answer with {unique_keyword} keyword",
|
||||||
}
|
}
|
||||||
AppAnnotationService.insert_app_annotation_directly(annotation_args, app.id)
|
AppAnnotationService.insert_app_annotation_directly(annotation_args, app.id)
|
||||||
|
|
||||||
# Create another annotation without the keyword
|
# Create another annotation without the keyword
|
||||||
other_args = {
|
other_args = {
|
||||||
"question": "Question without keyword",
|
"question": "Different question without special term",
|
||||||
"answer": "Answer without keyword",
|
"answer": "Different answer without special content",
|
||||||
}
|
}
|
||||||
|
|
||||||
AppAnnotationService.insert_app_annotation_directly(other_args, app.id)
|
AppAnnotationService.insert_app_annotation_directly(other_args, app.id)
|
||||||
|
|
||||||
# Search with keyword
|
# Search with keyword
|
||||||
|
Reference in New Issue
Block a user