derek-thomas
commited on
Commit
·
5802d42
1
Parent(s):
c9245bc
Adding better response logs
Browse files
app.py
CHANGED
|
@@ -77,19 +77,27 @@ async def community(payload: WebhookPayload, task_queue: BackgroundTasks):
|
|
| 77 |
# Only run if change is on main branch
|
| 78 |
try:
|
| 79 |
if payload.updatedRefs[0].ref != 'refs/heads/main':
|
| 80 |
-
|
|
|
|
|
|
|
| 81 |
except:
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
|
| 84 |
# No need to run for README updates
|
| 85 |
try:
|
| 86 |
commit_files_url = f"""{payload.repo.url.api}/compare/{payload.updatedRefs[0].oldSha}..{payload.updatedRefs[0].newSha}?raw=true"""
|
| 87 |
response_text = requests.get(commit_files_url, headers=build_hf_headers()).text
|
| 88 |
if 'README.md' in response_text:
|
| 89 |
-
|
|
|
|
|
|
|
| 90 |
except Exception as e:
|
| 91 |
logger.info(f"{str(e)}")
|
| 92 |
-
|
|
|
|
|
|
|
| 93 |
|
| 94 |
logger.info(f"Webhook received from {payload.repo.name} indicating a repo {payload.event.action}")
|
| 95 |
task_queue.add_task(_process_webhook, payload=payload)
|
|
|
|
| 77 |
# Only run if change is on main branch
|
| 78 |
try:
|
| 79 |
if payload.updatedRefs[0].ref != 'refs/heads/main':
|
| 80 |
+
response_content = "No task scheduled: Change not on main branch"
|
| 81 |
+
logger.info(response_content)
|
| 82 |
+
return Response(response_content, status_code=status.HTTP_200_OK)
|
| 83 |
except:
|
| 84 |
+
response_content = "No task scheduled"
|
| 85 |
+
logger.info(response_content)
|
| 86 |
+
return Response(response_content, status_code=status.HTTP_200_OK)
|
| 87 |
|
| 88 |
# No need to run for README updates
|
| 89 |
try:
|
| 90 |
commit_files_url = f"""{payload.repo.url.api}/compare/{payload.updatedRefs[0].oldSha}..{payload.updatedRefs[0].newSha}?raw=true"""
|
| 91 |
response_text = requests.get(commit_files_url, headers=build_hf_headers()).text
|
| 92 |
if 'README.md' in response_text:
|
| 93 |
+
response_content = "No task scheduled: its a README update."
|
| 94 |
+
logger.info(response_content)
|
| 95 |
+
return Response(response_content, status_code=status.HTTP_200_OK)
|
| 96 |
except Exception as e:
|
| 97 |
logger.info(f"{str(e)}")
|
| 98 |
+
response_content = "Something weird with the webhook?"
|
| 99 |
+
logger.info(response_content)
|
| 100 |
+
return Response(response_content, status_code=status.HTTP_501_NOT_IMPLEMENTED)
|
| 101 |
|
| 102 |
logger.info(f"Webhook received from {payload.repo.name} indicating a repo {payload.event.action}")
|
| 103 |
task_queue.add_task(_process_webhook, payload=payload)
|