mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 02:43:49 +08:00
chore: remove unnecessary str() calls in annotation tasks (#41878)
This commit is contained in:
parent
e7d34f05ba
commit
1f6dadd22c
@ -31,7 +31,7 @@ def batch_import_annotations_task(job_id: str, content_list: list[dict], app_id:
|
||||
"""
|
||||
logger.info(click.style(f"Start batch import annotation: {job_id}", fg="green"))
|
||||
start_at = time.perf_counter()
|
||||
indexing_cache_key = f"app_annotation_batch_import_{str(job_id)}"
|
||||
indexing_cache_key = f"app_annotation_batch_import_{job_id}"
|
||||
active_jobs_key = f"annotation_import_active:{tenant_id}"
|
||||
|
||||
with session_factory.create_session() as session:
|
||||
@ -94,7 +94,7 @@ def batch_import_annotations_task(job_id: str, content_list: list[dict], app_id:
|
||||
except Exception as e:
|
||||
session.rollback()
|
||||
redis_client.setex(indexing_cache_key, 600, "error")
|
||||
indexing_error_msg_key = f"app_annotation_batch_import_error_msg_{str(job_id)}"
|
||||
indexing_error_msg_key = f"app_annotation_batch_import_error_msg_{job_id}"
|
||||
redis_client.setex(indexing_error_msg_key, 600, str(e))
|
||||
logger.exception("Build index for batch import annotations failed")
|
||||
finally:
|
||||
|
||||
@ -40,8 +40,8 @@ def disable_annotation_reply_task(job_id: str, app_id: str, tenant_id: str):
|
||||
logger.info(click.style(f"App annotation setting not found: {app_id}", fg="red"))
|
||||
return
|
||||
|
||||
disable_app_annotation_key = f"disable_app_annotation_{str(app_id)}"
|
||||
disable_app_annotation_job_key = f"disable_app_annotation_job_{str(job_id)}"
|
||||
disable_app_annotation_key = f"disable_app_annotation_{app_id}"
|
||||
disable_app_annotation_job_key = f"disable_app_annotation_job_{job_id}"
|
||||
|
||||
try:
|
||||
dataset = Dataset(
|
||||
@ -73,7 +73,7 @@ def disable_annotation_reply_task(job_id: str, app_id: str, tenant_id: str):
|
||||
except Exception as e:
|
||||
logger.exception("Annotation batch deleted index failed")
|
||||
redis_client.setex(disable_app_annotation_job_key, 600, "error")
|
||||
disable_app_annotation_error_key = f"disable_app_annotation_error_{str(job_id)}"
|
||||
disable_app_annotation_error_key = f"disable_app_annotation_error_{job_id}"
|
||||
redis_client.setex(disable_app_annotation_error_key, 600, str(e))
|
||||
finally:
|
||||
redis_client.delete(disable_app_annotation_key)
|
||||
|
||||
@ -45,8 +45,8 @@ def enable_annotation_reply_task(
|
||||
return
|
||||
|
||||
annotations = session.scalars(select(MessageAnnotation).where(MessageAnnotation.app_id == app_id)).all()
|
||||
enable_app_annotation_key = f"enable_app_annotation_{str(app_id)}"
|
||||
enable_app_annotation_job_key = f"enable_app_annotation_job_{str(job_id)}"
|
||||
enable_app_annotation_key = f"enable_app_annotation_{app_id}"
|
||||
enable_app_annotation_job_key = f"enable_app_annotation_job_{job_id}"
|
||||
|
||||
try:
|
||||
documents = []
|
||||
@ -131,7 +131,7 @@ def enable_annotation_reply_task(
|
||||
except Exception as e:
|
||||
logger.exception("Annotation batch created index failed")
|
||||
redis_client.setex(enable_app_annotation_job_key, 600, "error")
|
||||
enable_app_annotation_error_key = f"enable_app_annotation_error_{str(job_id)}"
|
||||
enable_app_annotation_error_key = f"enable_app_annotation_error_{job_id}"
|
||||
redis_client.setex(enable_app_annotation_error_key, 600, str(e))
|
||||
session.rollback()
|
||||
finally:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user