Skip to content

Commit 3adb15b

Browse files
authored
Revert use of celery task for Discord notifications (LAION-AI#3516)
Should fix LAION-AI#3504
1 parent 4f1b1eb commit 3adb15b

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

backend/oasst_backend/prompt_repository.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
from oasst_backend.models.payload_column_type import PayloadContainer
3131
from oasst_backend.task_repository import TaskRepository, validate_frontend_message_id
3232
from oasst_backend.user_repository import UserRepository
33+
from oasst_backend.utils import discord
3334
from oasst_backend.utils.database_utils import CommitMode, db_lang_to_postgres_ts_lang, managed_tx_method
34-
from oasst_backend.utils.discord import send_new_report_message
3535
from oasst_shared.exceptions import OasstError, OasstErrorCode
3636
from oasst_shared.schemas import protocol as protocol_schema
3737
from oasst_shared.schemas.protocol import SystemStats
@@ -595,7 +595,7 @@ def store_text_labels(self, text_labels: protocol_schema.TextLabels) -> tuple[Te
595595
message_id, protocol_schema.EmojiOp.add, protocol_schema.EmojiCode.red_flag
596596
)
597597

598-
send_new_report_message.delay(message=message, label_text=text_labels.text, user_id=self.user_id)
598+
discord.send_new_report_message(message=message, label_text=text_labels.text, user_id=self.user_id)
599599

600600
# update existing record for repeated updates (same user no task associated)
601601
existing_text_label = self.fetch_non_task_text_labels(message_id, self.user_id)

backend/oasst_backend/utils/discord.py

-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22

33
import requests
44
from loguru import logger
5-
from oasst_backend.celery_worker import app as celery_app
65
from oasst_backend.config import settings
76
from oasst_backend.models.message import Message
87

98
ROOT_ENDPOINT = "https://discord.com/api/v10"
109

1110

12-
@celery_app.task(name="send_new_report_message")
1311
def send_new_report_message(message: Message, label_text: str, user_id: UUID):
1412
"""
1513
Send a message to the Discord channel when a new message is flagged.
16-
Note: this is a Celery task.
1714
1815
Args:
1916
message (Message): the flagged message

backend/update_message_attributes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from loguru import logger
44
from oasst_backend.models import ApiClient, Message
5-
from oasst_backend.scheduled_tasks import check_toxicity, hf_feature_extraction
5+
from oasst_backend.scheduled_tasks import hf_feature_extraction, toxicity
66
from oasst_backend.utils.database_utils import default_session_factory
77
from sqlmodel import text
88

@@ -71,7 +71,7 @@ def find_and_update_toxicity(message_ids):
7171
text = result.payload.payload.text
7272
api_client = session.query(ApiClient).filter(ApiClient.id == api_client_id).first()
7373
if api_client is not None and text is not None:
74-
check_toxicity(text=text, message_id=message_id, api_client=api_client.__dict__)
74+
toxicity(text=text, message_id=message_id, api_client=api_client.__dict__)
7575
# to not get rate limited from HF
7676
time.sleep(10)
7777
except Exception as e:

0 commit comments

Comments
 (0)