Abhishek Thakur
commited on
Commit
·
07a8fe4
1
Parent(s):
fee8b21
use snapshot download
Browse files- competitions/evaluate.py +8 -2
- competitions/oauth.py +5 -5
competitions/evaluate.py
CHANGED
@@ -5,7 +5,7 @@ import shlex
|
|
5 |
import shutil
|
6 |
import subprocess
|
7 |
|
8 |
-
from huggingface_hub import HfApi,
|
9 |
from huggingface_hub.utils._errors import EntryNotFoundError
|
10 |
from loguru import logger
|
11 |
|
@@ -109,7 +109,13 @@ def run(params):
|
|
109 |
utils.uninstall_requirements(requirements_fname)
|
110 |
utils.install_requirements(requirements_fname)
|
111 |
if len(str(params.dataset).strip()) > 0:
|
112 |
-
_ = Repository(local_dir="/tmp/data", clone_from=params.dataset, token=params.token)
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
generate_submission_file(params)
|
114 |
|
115 |
evaluation = compute_metrics(params)
|
|
|
5 |
import shutil
|
6 |
import subprocess
|
7 |
|
8 |
+
from huggingface_hub import HfApi, hf_hub_download, snapshot_download
|
9 |
from huggingface_hub.utils._errors import EntryNotFoundError
|
10 |
from loguru import logger
|
11 |
|
|
|
109 |
utils.uninstall_requirements(requirements_fname)
|
110 |
utils.install_requirements(requirements_fname)
|
111 |
if len(str(params.dataset).strip()) > 0:
|
112 |
+
# _ = Repository(local_dir="/tmp/data", clone_from=params.dataset, token=params.token)
|
113 |
+
_ = snapshot_download(
|
114 |
+
repo_id=params.dataset,
|
115 |
+
local_dir="/tmp/data",
|
116 |
+
token=params.token,
|
117 |
+
repo_type="dataset",
|
118 |
+
)
|
119 |
generate_submission_file(params)
|
120 |
|
121 |
evaluation = compute_metrics(params)
|
competitions/oauth.py
CHANGED
@@ -28,15 +28,15 @@ def attach_oauth(app: fastapi.FastAPI):
|
|
28 |
# Add `/login/huggingface`, `/login/callback` and `/logout` routes to enable OAuth in the Gradio app.
|
29 |
# If the app is running in a Space, OAuth is enabled normally. Otherwise, we mock the "real" routes to make the
|
30 |
# user log in with a fake user profile - without any calls to hf.co.
|
31 |
-
if os.environ.get("SPACE_ID") is not None:
|
32 |
-
|
33 |
-
else:
|
34 |
-
|
35 |
|
36 |
# Session Middleware requires a secret key to sign the cookies. Let's use a hash
|
37 |
# of the OAuth secret key to make it unique to the Space + updated in case OAuth
|
38 |
# config gets updated.
|
39 |
-
session_secret = (OAUTH_CLIENT_SECRET or "") + "-
|
40 |
# ^ if we change the session cookie format in the future, we can bump the version of the session secret to make
|
41 |
# sure cookies are invalidated. Otherwise some users with an old cookie format might get a HTTP 500 error.
|
42 |
app.add_middleware(
|
|
|
28 |
# Add `/login/huggingface`, `/login/callback` and `/logout` routes to enable OAuth in the Gradio app.
|
29 |
# If the app is running in a Space, OAuth is enabled normally. Otherwise, we mock the "real" routes to make the
|
30 |
# user log in with a fake user profile - without any calls to hf.co.
|
31 |
+
# if os.environ.get("SPACE_ID") is not None:
|
32 |
+
_add_oauth_routes(app)
|
33 |
+
# else:
|
34 |
+
# _add_mocked_oauth_routes(app)
|
35 |
|
36 |
# Session Middleware requires a secret key to sign the cookies. Let's use a hash
|
37 |
# of the OAuth secret key to make it unique to the Space + updated in case OAuth
|
38 |
# config gets updated.
|
39 |
+
session_secret = (OAUTH_CLIENT_SECRET or "") + "-v4"
|
40 |
# ^ if we change the session cookie format in the future, we can bump the version of the session secret to make
|
41 |
# sure cookies are invalidated. Otherwise some users with an old cookie format might get a HTTP 500 error.
|
42 |
app.add_middleware(
|