Spaces:
Running
Running
Another swing at htmx error.
Browse files
main.py
CHANGED
@@ -23,7 +23,6 @@ OPENID_PROVIDER_URL = os.environ.get('OPENID_PROVIDER_URL')
|
|
23 |
SPACE_HOST = os.environ.get('SPACE_HOST')
|
24 |
HF_DATASET_AUTH_TOKEN = os.environ.get('HF_DATASET_AUTH_TOKEN', "none")
|
25 |
|
26 |
-
assert HF_DATASET_AUTH_TOKEN != "none", "Please set the corrent ENV variables!!!"
|
27 |
|
28 |
LOCAL_STORAGE_PATH = ""
|
29 |
|
@@ -48,7 +47,7 @@ try:
|
|
48 |
repo_id="ml-visoft/c-reviewer",
|
49 |
repo_type="dataset",
|
50 |
folder_path=LOCAL_STORAGE_PATH,
|
51 |
-
every=
|
52 |
path_in_repo="raw_data",
|
53 |
token=HF_DATASET_AUTH_TOKEN,
|
54 |
squash_history=False
|
@@ -150,9 +149,9 @@ def html_create_feedback_updown_button(qe_id, ans_id, selected=0, disabled=False
|
|
150 |
if selected == 1: up_col = colors[1]
|
151 |
if selected == -1: down_col = colors[1]
|
152 |
toggle_url = f"/toggle_up_down/{qe_id}/{ans_id}/"
|
153 |
-
up = Button("+",
|
154 |
hx_target="#" + html_target_id, style=f"background-color:{up_col}")
|
155 |
-
down = Button("-",
|
156 |
hx_target="#" + html_target_id, style=f"background-color:{down_col}")
|
157 |
button_row = Div(up, down, _id=html_target_id)
|
158 |
return button_row
|
@@ -174,7 +173,7 @@ def html_augment_evaluation_text_with_feedback(eval_html, qe_id, ans_id, selecte
|
|
174 |
|
175 |
|
176 |
@rt("/toggle_up_down/{qe_id}/{ans_id}")
|
177 |
-
def
|
178 |
"""
|
179 |
Answer to the +/- button presses
|
180 |
|
@@ -189,21 +188,6 @@ def post(session, qe_id:int, ans_id:int, which:int):
|
|
189 |
print(f"The {which=} is bad")
|
190 |
return None
|
191 |
print(f"{qe_id=} {ans_id=} {which=}")
|
192 |
-
# if 'session_id' not in session:
|
193 |
-
# print("toggle_up_down bad session data")
|
194 |
-
# return None
|
195 |
-
# session_id = session["session_id"]
|
196 |
-
# state_rows = session_state_table(limit=1, where=f"session_id == '{session_id}'", order_by="id DESC")
|
197 |
-
# if len(state_rows) <= 0:
|
198 |
-
# return None
|
199 |
-
# answer_id = state_rows[0].current_qeval
|
200 |
-
# qa_obj_row = question_evaluation_table(limit=1, where=f"id == {answer_id}")
|
201 |
-
# if len(qa_obj_row) <= 0:
|
202 |
-
# return None
|
203 |
-
# qe_obj = qa_obj_row[0]
|
204 |
-
# if qe_id != qe_obj.id:
|
205 |
-
# print(f"QE {qe_id} does not belong to {qe_obj.id}")
|
206 |
-
# return None
|
207 |
|
208 |
is_ok, qe_obj = validate_and_get_question_evaluation_objectid(session, qe_id)
|
209 |
if not is_ok:
|
|
|
23 |
SPACE_HOST = os.environ.get('SPACE_HOST')
|
24 |
HF_DATASET_AUTH_TOKEN = os.environ.get('HF_DATASET_AUTH_TOKEN', "none")
|
25 |
|
|
|
26 |
|
27 |
LOCAL_STORAGE_PATH = ""
|
28 |
|
|
|
47 |
repo_id="ml-visoft/c-reviewer",
|
48 |
repo_type="dataset",
|
49 |
folder_path=LOCAL_STORAGE_PATH,
|
50 |
+
every=10,
|
51 |
path_in_repo="raw_data",
|
52 |
token=HF_DATASET_AUTH_TOKEN,
|
53 |
squash_history=False
|
|
|
149 |
if selected == 1: up_col = colors[1]
|
150 |
if selected == -1: down_col = colors[1]
|
151 |
toggle_url = f"/toggle_up_down/{qe_id}/{ans_id}/"
|
152 |
+
up = Button("+", hx_get=f"/toggle_up_down/{qe_id}/{ans_id}/?which=1", disabled=disabled, hx_swap="outerHTML",
|
153 |
hx_target="#" + html_target_id, style=f"background-color:{up_col}")
|
154 |
+
down = Button("-", hx_get=f"{toggle_url}?which=-1", disabled=disabled, hx_swap="outerHTML",
|
155 |
hx_target="#" + html_target_id, style=f"background-color:{down_col}")
|
156 |
button_row = Div(up, down, _id=html_target_id)
|
157 |
return button_row
|
|
|
173 |
|
174 |
|
175 |
@rt("/toggle_up_down/{qe_id}/{ans_id}")
|
176 |
+
def get(session, qe_id:int, ans_id:int, which:int):
|
177 |
"""
|
178 |
Answer to the +/- button presses
|
179 |
|
|
|
188 |
print(f"The {which=} is bad")
|
189 |
return None
|
190 |
print(f"{qe_id=} {ans_id=} {which=}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
is_ok, qe_obj = validate_and_get_question_evaluation_objectid(session, qe_id)
|
193 |
if not is_ok:
|