Imane Momayiz
commited on
Commit
·
2c0f00c
1
Parent(s):
c437348
bug: submission
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ import json
|
|
6 |
import os
|
7 |
from huggingface_hub import HfApi, CommitScheduler
|
8 |
import uuid
|
9 |
-
from src.components import ParquetScheduler
|
10 |
|
11 |
|
12 |
HF_API_KEY = os.environ.get("HF_TOKEN", None)
|
@@ -20,20 +19,21 @@ submissions_folder = "submissions"
|
|
20 |
submissions_file = os.path.join(submissions_folder, f"submissions_{uuid.uuid4()}.json")
|
21 |
os.makedirs(submissions_folder, exist_ok=True)
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
|
32 |
# Define the ParquetScheduler instance with your repo details
|
33 |
-
scheduler = ParquetScheduler(repo_id=REPO_ID,
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
|
39 |
def load_data(repo_id):
|
@@ -72,17 +72,17 @@ def store_submission(api: HfApi, sentence: str, translation: str, translation_fr
|
|
72 |
# repo_type="dataset",
|
73 |
# )
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
# "eng": translation,
|
80 |
-
# "darija_ar": sentence}))
|
81 |
-
# f.write("\n")
|
82 |
-
|
83 |
-
scheduler.append({"darija": translation_fr,
|
84 |
"eng": translation,
|
85 |
-
"darija_ar": sentence})
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
st.success(
|
88 |
f"""Translation submitted successfully to
|
|
|
6 |
import os
|
7 |
from huggingface_hub import HfApi, CommitScheduler
|
8 |
import uuid
|
|
|
9 |
|
10 |
|
11 |
HF_API_KEY = os.environ.get("HF_TOKEN", None)
|
|
|
19 |
submissions_file = os.path.join(submissions_folder, f"submissions_{uuid.uuid4()}.json")
|
20 |
os.makedirs(submissions_folder, exist_ok=True)
|
21 |
|
22 |
+
scheduler = CommitScheduler(
|
23 |
+
token=HF_API_KEY,
|
24 |
+
hf_api=api,
|
25 |
+
repo_id=REPO_ID,
|
26 |
+
repo_type="dataset",
|
27 |
+
folder_path=submissions_folder,
|
28 |
+
path_in_repo=submissions_folder,
|
29 |
+
every=1,
|
30 |
+
)
|
31 |
|
32 |
# Define the ParquetScheduler instance with your repo details
|
33 |
+
# scheduler = ParquetScheduler(repo_id=REPO_ID,
|
34 |
+
# token=HF_API_KEY, every=1,
|
35 |
+
# path_in_repo=submissions_folder,
|
36 |
+
# repo_type="dataset")
|
37 |
|
38 |
|
39 |
def load_data(repo_id):
|
|
|
72 |
# repo_type="dataset",
|
73 |
# )
|
74 |
|
75 |
+
with scheduler.lock:
|
76 |
+
with submissions_file.open("a") as f:
|
77 |
+
f.write(json.dumps({
|
78 |
+
"darija": translation_fr,
|
|
|
|
|
|
|
|
|
|
|
79 |
"eng": translation,
|
80 |
+
"darija_ar": sentence}))
|
81 |
+
f.write("\n")
|
82 |
+
|
83 |
+
# scheduler.append({"darija": translation_fr,
|
84 |
+
# "eng": translation,
|
85 |
+
# "darija_ar": sentence})
|
86 |
|
87 |
st.success(
|
88 |
f"""Translation submitted successfully to
|