chore: remove unnecessary str() calls in annotation tasks (#41878)

This commit is contained in:
SONG ZHIFEI 2026-09-07 03:55:20 +00:00 committed by GitHub
parent e7d34f05ba
commit 1f6dadd22c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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: