qgallouedec HF staff commited on
Commit
d554c4b
·
verified ·
1 Parent(s): 4916b93

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +86 -0
README.md CHANGED
@@ -168,3 +168,89 @@ dataset_dict = {key: [d[key] for d in dataset_list] for key in dataset_list[0].k
168
  dataset = Dataset.from_dict(dataset_dict)
169
  dataset.push_to_hub("qgallouedec/trl-metrics", config_name="models")
170
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  dataset = Dataset.from_dict(dataset_dict)
169
  dataset.push_to_hub("qgallouedec/trl-metrics", config_name="models")
170
  ```
171
+
172
+
173
+ ## Issues and comments
174
+
175
+ ```python
176
+ import requests
177
+ from datetime import datetime
178
+ import os
179
+ from datasets import Dataset
180
+ from tqdm import tqdm
181
+
182
+ token = os.environ.get("GITHUB_PAT")
183
+
184
+ def get_full_response(url, headers, params=None):
185
+ page = 1
186
+ output = []
187
+ params = params or {}
188
+ while True:
189
+ params = {**params, "page": page, "per_page": 100}
190
+ response = requests.get(url, headers=headers, params=params)
191
+
192
+ if response.status_code != 200:
193
+ raise Exception(f"Failed to fetch issues: {response.text}")
194
+
195
+ batch = response.json()
196
+ if len(batch) == 0:
197
+ break
198
+ output.extend(batch)
199
+ page += 1
200
+ return output
201
+
202
+ # GitHub API URL for issues (closed and open)
203
+ issues_url = f"https://api.github.com/repos/huggingface/trl/issues"
204
+
205
+ # Set up headers for authentication
206
+ headers = {"Authorization": f"token {token}", "Accept": "application/vnd.github.v3+json"}
207
+
208
+ # Make the request
209
+ issues = get_full_response(issues_url, headers, params={"state": "all"})
210
+
211
+ issues_dataset_dict = {
212
+ "number": [],
213
+ "title": [],
214
+ "user": [],
215
+ "state": [],
216
+ "created_at": [],
217
+ "closed_at": [],
218
+ "comments_count": [],
219
+ }
220
+ comments_dataset_dict = {
221
+ "user": [],
222
+ "created_at": [],
223
+ "body": [],
224
+ "issue_number": [],
225
+ }
226
+ for issue in tqdm(issues):
227
+ # Extract relevant information
228
+ issue_number = issue["number"]
229
+ title = issue["title"]
230
+ created_at = datetime.strptime(issue["created_at"], "%Y-%m-%dT%H:%M:%SZ")
231
+ comments_count = issue["comments"]
232
+ comments_url = issue["comments_url"]
233
+
234
+ comments = get_full_response(comments_url, headers=headers)
235
+ for comment in comments:
236
+ comments_dataset_dict["user"].append(comment["user"]["login"])
237
+ comments_dataset_dict["created_at"].append(datetime.strptime(comment["created_at"], "%Y-%m-%dT%H:%M:%SZ"))
238
+ comments_dataset_dict["body"].append(comment["body"])
239
+ comments_dataset_dict["issue_number"].append(issue_number)
240
+
241
+ issues_dataset_dict["number"].append(issue_number)
242
+ issues_dataset_dict["title"].append(title)
243
+ issues_dataset_dict["user"].append(issue["user"]["login"])
244
+ issues_dataset_dict["state"].append(issue["state"])
245
+ issues_dataset_dict["created_at"].append(datetime.strptime(issue["created_at"], "%Y-%m-%dT%H:%M:%SZ"))
246
+ issues_dataset_dict["closed_at"].append(datetime.strptime(issue["closed_at"], "%Y-%m-%dT%H:%M:%SZ") if issue["closed_at"] else None)
247
+ issues_dataset_dict["comments_count"].append(comments_count)
248
+
249
+ issues_dataset = Dataset.from_dict(issues_dataset_dict)
250
+ comments_dataset = Dataset.from_dict(comments_dataset_dict)
251
+
252
+ issues_dataset.push_to_hub("qgallouedec/trl-metrics", config_name="issues")
253
+ comments_dataset.push_to_hub("qgallouedec/trl-metrics", config_name="issue_comments")
254
+ ```
255
+
256
+