Making multi-tenant with profile.username
Browse files- app.py +3 -3
- evaluator.py +4 -1
app.py
CHANGED
@@ -46,18 +46,18 @@ def run_one(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
|
46 |
if not user_logged_in(profile):
|
47 |
return LOGIN_MESSAGE, EMPTY_RESULTS_TABLE
|
48 |
questions = [evaluator.get_one_question()]
|
49 |
-
return "
|
50 |
|
51 |
def run_all(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
52 |
if not user_logged_in(profile):
|
53 |
return LOGIN_MESSAGE, EMPTY_RESULTS_TABLE
|
54 |
questions = evaluator.get_questions()
|
55 |
-
return "
|
56 |
|
57 |
def submit(profile: gr.OAuthProfile | None) -> str:
|
58 |
if not user_logged_in(profile):
|
59 |
return LOGIN_MESSAGE
|
60 |
-
return evaluator.submit_answers()
|
61 |
|
62 |
|
63 |
# --- Build Gradio Interface using Blocks ---
|
|
|
46 |
if not user_logged_in(profile):
|
47 |
return LOGIN_MESSAGE, EMPTY_RESULTS_TABLE
|
48 |
questions = [evaluator.get_one_question()]
|
49 |
+
return "Complete.", runner.run_agent(questions)
|
50 |
|
51 |
def run_all(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
52 |
if not user_logged_in(profile):
|
53 |
return LOGIN_MESSAGE, EMPTY_RESULTS_TABLE
|
54 |
questions = evaluator.get_questions()
|
55 |
+
return "Complete.", runner.run_agent(questions)
|
56 |
|
57 |
def submit(profile: gr.OAuthProfile | None) -> str:
|
58 |
if not user_logged_in(profile):
|
59 |
return LOGIN_MESSAGE
|
60 |
+
return evaluator.submit_answers(profile.username)
|
61 |
|
62 |
|
63 |
# --- Build Gradio Interface using Blocks ---
|
evaluator.py
CHANGED
@@ -64,8 +64,11 @@ class Evaluator():
|
|
64 |
# Return count and the formatted data
|
65 |
return formatted_data
|
66 |
|
67 |
-
def submit_answers(self) -> str:
|
68 |
"""Submits saved answers to the scoring endpoint and returns the result."""
|
|
|
|
|
|
|
69 |
answers_payload = self._read_answer_file()
|
70 |
agent_code = f"https://huggingface.co/spaces/{self.settings.space_id}/tree/main"
|
71 |
submission_data = {
|
|
|
64 |
# Return count and the formatted data
|
65 |
return formatted_data
|
66 |
|
67 |
+
def submit_answers(self, username: str) -> str:
|
68 |
"""Submits saved answers to the scoring endpoint and returns the result."""
|
69 |
+
|
70 |
+
logger.info(f"Requesting user: {username}")
|
71 |
+
|
72 |
answers_payload = self._read_answer_file()
|
73 |
agent_code = f"https://huggingface.co/spaces/{self.settings.space_id}/tree/main"
|
74 |
submission_data = {
|