make logging not use f-str, change others to f-str (#22882)
This commit is contained in:
@@ -19,21 +19,21 @@ def remove_document_from_index_task(document_id: str):
|
||||
|
||||
Usage: remove_document_from_index.delay(document_id)
|
||||
"""
|
||||
logging.info(click.style("Start remove document segments from index: {}".format(document_id), fg="green"))
|
||||
logging.info(click.style(f"Start remove document segments from index: {document_id}", fg="green"))
|
||||
start_at = time.perf_counter()
|
||||
|
||||
document = db.session.query(Document).where(Document.id == document_id).first()
|
||||
if not document:
|
||||
logging.info(click.style("Document not found: {}".format(document_id), fg="red"))
|
||||
logging.info(click.style(f"Document not found: {document_id}", fg="red"))
|
||||
db.session.close()
|
||||
return
|
||||
|
||||
if document.indexing_status != "completed":
|
||||
logging.info(click.style("Document is not completed, remove is not allowed: {}".format(document_id), fg="red"))
|
||||
logging.info(click.style(f"Document is not completed, remove is not allowed: {document_id}", fg="red"))
|
||||
db.session.close()
|
||||
return
|
||||
|
||||
indexing_cache_key = "document_{}_indexing".format(document.id)
|
||||
indexing_cache_key = f"document_{document.id}_indexing"
|
||||
|
||||
try:
|
||||
dataset = document.dataset
|
||||
@@ -49,7 +49,7 @@ def remove_document_from_index_task(document_id: str):
|
||||
try:
|
||||
index_processor.clean(dataset, index_node_ids, with_keywords=True, delete_child_chunks=False)
|
||||
except Exception:
|
||||
logging.exception(f"clean dataset {dataset.id} from index failed")
|
||||
logging.exception("clean dataset %s from index failed", dataset.id)
|
||||
# update segment to disable
|
||||
db.session.query(DocumentSegment).where(DocumentSegment.document_id == document.id).update(
|
||||
{
|
||||
@@ -63,9 +63,7 @@ def remove_document_from_index_task(document_id: str):
|
||||
|
||||
end_at = time.perf_counter()
|
||||
logging.info(
|
||||
click.style(
|
||||
"Document removed from index: {} latency: {}".format(document.id, end_at - start_at), fg="green"
|
||||
)
|
||||
click.style(f"Document removed from index: {document.id} latency: {end_at - start_at}", fg="green")
|
||||
)
|
||||
except Exception:
|
||||
logging.exception("remove document from index failed")
|
||||
|
Reference in New Issue
Block a user