Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -44,15 +44,25 @@ def submit_file(v, file_path, mn):
|
|
44 |
new_file['ppl'] = 0
|
45 |
|
46 |
print('WE READ FILE: ', new_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
buf = BytesIO()
|
48 |
-
buf.write(json.dumps(
|
49 |
-
buf.seek(0) # Rewind the buffer so that its contents can be read.
|
50 |
API.upload_file(
|
51 |
path_or_fileobj=buf,
|
52 |
path_in_repo="model_data/external/" + mn.replace('/', '__') + ".json",
|
53 |
repo_id="kz-transformers/s-openbench-eval",
|
54 |
repo_type="dataset",
|
55 |
)
|
|
|
56 |
os.environ[RESET_JUDGEMENT_ENV] = "1"
|
57 |
return "Success!"
|
58 |
|
|
|
44 |
new_file['ppl'] = 0
|
45 |
|
46 |
print('WE READ FILE: ', new_file)
|
47 |
+
def replace_booleans_with_empty_dict(d):
|
48 |
+
if isinstance(d, dict):
|
49 |
+
return {k: ({} if isinstance(v, bool) else replace_booleans_with_empty_dict(v))
|
50 |
+
for k, v in d.items()}
|
51 |
+
elif isinstance(d, list):
|
52 |
+
return [replace_booleans_with_empty_dict(item) for item in d]
|
53 |
+
else:
|
54 |
+
return d
|
55 |
+
|
56 |
+
clean_data = replace_booleans_with_empty_dict(new_file)
|
57 |
buf = BytesIO()
|
58 |
+
buf.write(json.dumps(clean_data).encode('utf-8'))
|
|
|
59 |
API.upload_file(
|
60 |
path_or_fileobj=buf,
|
61 |
path_in_repo="model_data/external/" + mn.replace('/', '__') + ".json",
|
62 |
repo_id="kz-transformers/s-openbench-eval",
|
63 |
repo_type="dataset",
|
64 |
)
|
65 |
+
|
66 |
os.environ[RESET_JUDGEMENT_ENV] = "1"
|
67 |
return "Success!"
|
68 |
|