Spaces:
Runtime error
Runtime error
LysandreJik
commited on
Commit
·
c30da09
1
Parent(s):
43f35d8
Static space work
Browse files
app.py
CHANGED
@@ -12,11 +12,13 @@ HF_TOKEN = os.environ['HF_TOKEN']
|
|
12 |
set_access_token(HF_TOKEN)
|
13 |
HfFolder.save_token(HF_TOKEN)
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
"open-source-metrics/
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
|
21 |
def running_mean(x, N, total_length=-1):
|
22 |
cumsum = np.cumsum(np.insert(x, 0, 0))
|
@@ -33,14 +35,20 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
|
33 |
return SimpleHTTPRequestHandler.do_GET(self)
|
34 |
|
35 |
if self.path.startswith("/initialize"):
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
self.send_response(200)
|
40 |
self.send_header("Content-Type", "application/json")
|
41 |
self.end_headers()
|
42 |
|
43 |
-
self.wfile.write(json.dumps(
|
44 |
|
45 |
return SimpleHTTPRequestHandler
|
46 |
|
|
|
12 |
set_access_token(HF_TOKEN)
|
13 |
HfFolder.save_token(HF_TOKEN)
|
14 |
|
15 |
+
|
16 |
+
datasets = {
|
17 |
+
# "stars": load_dataset("open-source-metrics/stars"),
|
18 |
+
"issues": load_dataset("open-source-metrics/issues"),
|
19 |
+
"pip": load_dataset("open-source-metrics/pip")
|
20 |
+
}
|
21 |
+
|
22 |
|
23 |
def running_mean(x, N, total_length=-1):
|
24 |
cumsum = np.cumsum(np.insert(x, 0, 0))
|
|
|
35 |
return SimpleHTTPRequestHandler.do_GET(self)
|
36 |
|
37 |
if self.path.startswith("/initialize"):
|
38 |
+
dataset_keys = {k: set(v.keys()) for k, v in datasets.items()}
|
39 |
+
dataset_keys['issues'].remove('transformers')
|
40 |
+
dataset_with_most_splits = max([d for d in dataset_keys.values()], key=len)
|
41 |
+
warnings = []
|
42 |
+
|
43 |
+
for k, v in dataset_keys.items():
|
44 |
+
if len(v.keys()) < len(dataset_with_most_splits):
|
45 |
+
warnings.extend(f"The {k} dataset does not contain all splits. Missing: {dataset_with_most_splits - v}")
|
46 |
|
47 |
self.send_response(200)
|
48 |
self.send_header("Content-Type", "application/json")
|
49 |
self.end_headers()
|
50 |
|
51 |
+
self.wfile.write(json.dumps(dataset_keys).encode("utf-8"))
|
52 |
|
53 |
return SimpleHTTPRequestHandler
|
54 |
|