brunneis commited on
Commit
0f68941
1 Parent(s): 64a4821

Notify requests on Discord

Browse files
src/envs.py CHANGED
@@ -9,7 +9,7 @@ from huggingface_hub import HfApi
9
  # Info to change for your repository
10
  # ----------------------------------
11
  TOKEN = os.environ.get("HF_TOKEN")
12
-
13
  OWNER = "braindao"
14
  # ----------------------------------
15
 
 
9
  # Info to change for your repository
10
  # ----------------------------------
11
  TOKEN = os.environ.get("HF_TOKEN")
12
+ DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL")
13
  OWNER = "braindao"
14
  # ----------------------------------
15
 
src/submission/notify.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # flake8: noqa E501
4
+
5
+ import requests
6
+ from src.envs import DISCORD_WEBHOOK_URL
7
+
8
+
9
+ def notify_discord(model_name: str) -> None:
10
+ if not DISCORD_WEBHOOK_URL:
11
+ return
12
+
13
+ discord_message = {
14
+ 'content': 'A new evaluation request has been submitted for the model: {}'.format(model_name)
15
+ }
16
+
17
+ response = requests.post(
18
+ DISCORD_WEBHOOK_URL,
19
+ json=discord_message
20
+ )
21
+
22
+ if response.status_code != 204:
23
+ print('Failed to send message to Discord. Status code: {}'.format(response.status_code))
24
+
25
+ def notify(model_name: str) -> None:
26
+ notify_discord(model_name)
src/submission/submit.py CHANGED
@@ -10,6 +10,7 @@ from src.display.formatting import styled_error, styled_message, styled_warning
10
  from src.envs import API, EVAL_REQUESTS_PATH, REQUESTS_REPO, TOKEN
11
  from src.submission.check_validity import already_submitted_models, check_model_card, get_model_size, is_model_on_hub
12
  from src.utils import get_request_hash, get_request_id
 
13
 
14
  REQUESTED_MODELS = None
15
  USERS_TO_SUBMISSION_DATES = None
@@ -122,6 +123,8 @@ def add_new_eval(
122
  commit_message=f"Add an evaluation request for {model_name}",
123
  )
124
 
 
 
125
  # Remove the local file
126
  os.remove(out_path)
127
 
 
10
  from src.envs import API, EVAL_REQUESTS_PATH, REQUESTS_REPO, TOKEN
11
  from src.submission.check_validity import already_submitted_models, check_model_card, get_model_size, is_model_on_hub
12
  from src.utils import get_request_hash, get_request_id
13
+ from src.submission.notify import notify
14
 
15
  REQUESTED_MODELS = None
16
  USERS_TO_SUBMISSION_DATES = None
 
123
  commit_message=f"Add an evaluation request for {model_name}",
124
  )
125
 
126
+ notify(model_name)
127
+
128
  # Remove the local file
129
  os.remove(out_path)
130