Spaces:
Sleeping
Sleeping
Add validation for Hugging Face profile and username in run_and_submit_all function
Browse files
app.py
CHANGED
@@ -29,11 +29,21 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
29 |
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
30 |
|
31 |
if profile:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
username = f"{profile.username}"
|
33 |
print(f"User logged in: {username}")
|
34 |
else:
|
35 |
print("User not logged in.")
|
36 |
-
|
|
|
|
|
37 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
38 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
39 |
print(agent_code)
|
|
|
29 |
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
30 |
|
31 |
if profile:
|
32 |
+
if profile.profile != os.getenv("HUGGINGFACE_PROFILE"):
|
33 |
+
raise ValueError(
|
34 |
+
"The logged-in user does not match the expected Hugging Face profile."
|
35 |
+
)
|
36 |
+
if profile.username != os.getenv("HUGGINGFACE_USERNAME"):
|
37 |
+
raise ValueError(
|
38 |
+
"The logged-in user does not match the expected Hugging Face username."
|
39 |
+
)
|
40 |
username = f"{profile.username}"
|
41 |
print(f"User logged in: {username}")
|
42 |
else:
|
43 |
print("User not logged in.")
|
44 |
+
raise ValueError(
|
45 |
+
"You must log in to your Hugging Face account to run this evaluation."
|
46 |
+
)
|
47 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
48 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
49 |
print(agent_code)
|