amaye15 commited on
Commit
a74c6ae
·
1 Parent(s): 4cf98d3
Files changed (1) hide show
  1. app.py +0 -37
app.py CHANGED
@@ -71,43 +71,6 @@ async def handle_repository_changes(
71
  """
72
  Webhook endpoint that triggers data processing when the dataset is updated.
73
  """
74
- if not payload.event.scope.startswith("repo"):
75
- return Response("No task scheduled", status_code=status.HTTP_200_OK)
76
-
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 Exception as e:
84
- logger.error(f"Error checking branch: {str(e)}")
85
- return Response("No task scheduled", status_code=status.HTTP_200_OK)
86
-
87
- # No need to run for README only updates
88
- try:
89
- commit_files_url = f"{payload.repo.url.api}/compare/{payload.updatedRefs[0].oldSha}..{payload.updatedRefs[0].newSha}?raw=true"
90
- response_text = (
91
- get_session().get(commit_files_url, headers=build_hf_headers()).text
92
- )
93
- logger.info(f"Git Compare URL: {commit_files_url}")
94
-
95
- # Splitting the output into lines
96
- file_lines = response_text.split("\n")
97
-
98
- # Filtering the lines to find file changes
99
- changed_files = [line.split("\t")[-1] for line in file_lines if line.strip()]
100
- logger.info(f"Changed files: {changed_files}")
101
-
102
- # Checking if only README.md has been changed
103
- if all("README.md" in file for file in changed_files):
104
- response_content = "No task scheduled: It's a README only update."
105
- logger.info(response_content)
106
- return Response(response_content, status_code=status.HTTP_200_OK)
107
- except Exception as e:
108
- logger.error(f"Error checking files: {str(e)}")
109
- return Response("Unexpected issue", status_code=status.HTTP_501_NOT_IMPLEMENTED)
110
-
111
  logger.info(
112
  f"Webhook received from {payload.repo.name} indicating a repo {payload.event.action}"
113
  )
 
71
  """
72
  Webhook endpoint that triggers data processing when the dataset is updated.
73
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  logger.info(
75
  f"Webhook received from {payload.repo.name} indicating a repo {payload.event.action}"
76
  )