Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
add longform tab
Browse files
init.py
CHANGED
|
@@ -6,8 +6,10 @@ from huggingface_hub import HfApi, Repository
|
|
| 6 |
TOKEN_HUB = os.environ.get("TOKEN_HUB", None)
|
| 7 |
QUEUE_REPO = os.environ.get("QUEUE_REPO", None)
|
| 8 |
QUEUE_REPO_MULTI = os.environ.get("QUEUE_REPO_MULTI", None)
|
|
|
|
| 9 |
QUEUE_PATH = os.environ.get("QUEUE_PATH", None)
|
| 10 |
QUEUE_PATH_MULTI = os.environ.get("QUEUE_PATH_MULTI", None)
|
|
|
|
| 11 |
|
| 12 |
hf_api = HfApi(
|
| 13 |
endpoint="https://huggingface.co",
|
|
@@ -45,8 +47,11 @@ def load_all_info_from_dataset_hub():
|
|
| 45 |
|
| 46 |
# Load multilingual data in the same way
|
| 47 |
multilingual_csv_results = load_multilingual_data()
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
return eval_queue_repo, requested_models, csv_results, multilingual_csv_results
|
| 50 |
|
| 51 |
def load_multilingual_data():
|
| 52 |
"""Load multilingual evaluation data from CSV"""
|
|
@@ -64,7 +69,7 @@ def load_multilingual_data():
|
|
| 64 |
repo_type="dataset",
|
| 65 |
)
|
| 66 |
multilingual_repo.git_pull()
|
| 67 |
-
multilingual_csv =
|
| 68 |
except Exception as e:
|
| 69 |
print(f"Failed to pull from multilingual repo: {e}")
|
| 70 |
multilingual_csv = None
|
|
@@ -74,13 +79,46 @@ def load_multilingual_data():
|
|
| 74 |
# Fallback to local file
|
| 75 |
if multilingual_csv is None:
|
| 76 |
print("Using local multilingual CSV file.")
|
| 77 |
-
multilingual_csv =
|
| 78 |
|
| 79 |
return multilingual_csv
|
| 80 |
except Exception as e:
|
| 81 |
print(f"Error loading multilingual data: {e}")
|
| 82 |
return None
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
def upload_file(requested_model_name, path_or_fileobj):
|
| 86 |
dest_repo_file = Path(EVAL_REQUESTS_PATH) / path_or_fileobj.name
|
|
@@ -106,20 +144,6 @@ def get_csv_with_results(directory):
|
|
| 106 |
return None
|
| 107 |
return latest[0]
|
| 108 |
|
| 109 |
-
def get_multilingual_csv_with_results(directory):
|
| 110 |
-
"""Get multilingual CSV results file"""
|
| 111 |
-
directory = Path(directory)
|
| 112 |
-
multilingual_csv_files = list(directory.glob("multilingual_results_latest.csv"))
|
| 113 |
-
if len(multilingual_csv_files) != 1:
|
| 114 |
-
# Try local directory as fallback
|
| 115 |
-
local_multilingual = Path("multilingual_results_latest.csv")
|
| 116 |
-
if local_multilingual.exists():
|
| 117 |
-
return local_multilingual
|
| 118 |
-
return None
|
| 119 |
-
return multilingual_csv_files[0]
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
def is_model_on_hub(model_name, revision="main") -> bool:
|
| 124 |
try:
|
| 125 |
model_name = model_name.replace(" ","")
|
|
|
|
| 6 |
TOKEN_HUB = os.environ.get("TOKEN_HUB", None)
|
| 7 |
QUEUE_REPO = os.environ.get("QUEUE_REPO", None)
|
| 8 |
QUEUE_REPO_MULTI = os.environ.get("QUEUE_REPO_MULTI", None)
|
| 9 |
+
QUEUE_REPO_LONGFORM = os.environ.get("QUEUE_REPO_LONGFORM", None)
|
| 10 |
QUEUE_PATH = os.environ.get("QUEUE_PATH", None)
|
| 11 |
QUEUE_PATH_MULTI = os.environ.get("QUEUE_PATH_MULTI", None)
|
| 12 |
+
QUEUE_PATH_LONGFORM = os.environ.get("QUEUE_PATH_LONGFORM", None)
|
| 13 |
|
| 14 |
hf_api = HfApi(
|
| 15 |
endpoint="https://huggingface.co",
|
|
|
|
| 47 |
|
| 48 |
# Load multilingual data in the same way
|
| 49 |
multilingual_csv_results = load_multilingual_data()
|
| 50 |
+
|
| 51 |
+
# Load longform data in the same way
|
| 52 |
+
longform_csv_results = load_longform_data()
|
| 53 |
|
| 54 |
+
return eval_queue_repo, requested_models, csv_results, multilingual_csv_results, longform_csv_results
|
| 55 |
|
| 56 |
def load_multilingual_data():
|
| 57 |
"""Load multilingual evaluation data from CSV"""
|
|
|
|
| 69 |
repo_type="dataset",
|
| 70 |
)
|
| 71 |
multilingual_repo.git_pull()
|
| 72 |
+
multilingual_csv = get_csv_with_results(multilingual_queue_path)
|
| 73 |
except Exception as e:
|
| 74 |
print(f"Failed to pull from multilingual repo: {e}")
|
| 75 |
multilingual_csv = None
|
|
|
|
| 79 |
# Fallback to local file
|
| 80 |
if multilingual_csv is None:
|
| 81 |
print("Using local multilingual CSV file.")
|
| 82 |
+
multilingual_csv = get_csv_with_results(".")
|
| 83 |
|
| 84 |
return multilingual_csv
|
| 85 |
except Exception as e:
|
| 86 |
print(f"Error loading multilingual data: {e}")
|
| 87 |
return None
|
| 88 |
|
| 89 |
+
def load_longform_data():
|
| 90 |
+
"""Load longform evaluation data from CSV"""
|
| 91 |
+
longform_queue_path = QUEUE_PATH_LONGFORM
|
| 92 |
+
|
| 93 |
+
try:
|
| 94 |
+
# Try to get from dedicated longform HF repo first
|
| 95 |
+
if TOKEN_HUB is not None:
|
| 96 |
+
print("Pulling longform evaluation data.")
|
| 97 |
+
try:
|
| 98 |
+
longform_repo = Repository(
|
| 99 |
+
local_dir=longform_queue_path,
|
| 100 |
+
clone_from=QUEUE_REPO_LONGFORM,
|
| 101 |
+
use_auth_token=TOKEN_HUB,
|
| 102 |
+
repo_type="dataset",
|
| 103 |
+
)
|
| 104 |
+
longform_repo.git_pull()
|
| 105 |
+
longform_csv = get_csv_with_results(longform_queue_path)
|
| 106 |
+
except Exception as e:
|
| 107 |
+
print(f"Failed to pull from longform repo: {e}")
|
| 108 |
+
longform_csv = None
|
| 109 |
+
else:
|
| 110 |
+
longform_csv = None
|
| 111 |
+
|
| 112 |
+
# Fallback to local file
|
| 113 |
+
if longform_csv is None:
|
| 114 |
+
print("Using local longform CSV file.")
|
| 115 |
+
longform_csv = get_csv_with_results(".")
|
| 116 |
+
|
| 117 |
+
return longform_csv
|
| 118 |
+
except Exception as e:
|
| 119 |
+
print(f"Error loading longform data: {e}")
|
| 120 |
+
return None
|
| 121 |
+
|
| 122 |
|
| 123 |
def upload_file(requested_model_name, path_or_fileobj):
|
| 124 |
dest_repo_file = Path(EVAL_REQUESTS_PATH) / path_or_fileobj.name
|
|
|
|
| 144 |
return None
|
| 145 |
return latest[0]
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
def is_model_on_hub(model_name, revision="main") -> bool:
|
| 148 |
try:
|
| 149 |
model_name = model_name.replace(" ","")
|