Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Apply Ruff
Browse files
yourbench_space/config.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
from ruamel.yaml import YAML
|
2 |
from loguru import logger
|
|
|
3 |
|
4 |
from yourbench_space import PATH
|
5 |
from yourbench_space.utils import to_commentable_yaml
|
@@ -92,11 +92,15 @@ def save_yaml_file(config: dict, path: str):
|
|
92 |
|
93 |
# Now we can add inline comments
|
94 |
ingestion = config_cm["pipeline"]["ingestion"]
|
95 |
-
ingestion.yaml_set_comment_before_after_key(
|
|
|
|
|
96 |
ingestion.yaml_set_comment_before_after_key("output_dir", before="⚠️ This is where ingested data will be saved")
|
97 |
|
98 |
upload = config_cm["pipeline"]["upload_ingest_to_hub"]
|
99 |
-
upload.yaml_set_comment_before_after_key(
|
|
|
|
|
100 |
|
101 |
with open(path, "w") as file:
|
102 |
yaml.dump(config_cm, file)
|
|
|
|
|
1 |
from loguru import logger
|
2 |
+
from ruamel.yaml import YAML
|
3 |
|
4 |
from yourbench_space import PATH
|
5 |
from yourbench_space.utils import to_commentable_yaml
|
|
|
92 |
|
93 |
# Now we can add inline comments
|
94 |
ingestion = config_cm["pipeline"]["ingestion"]
|
95 |
+
ingestion.yaml_set_comment_before_after_key(
|
96 |
+
"source_documents_dir", before="⚠️ Change this path to match your local directory"
|
97 |
+
)
|
98 |
ingestion.yaml_set_comment_before_after_key("output_dir", before="⚠️ This is where ingested data will be saved")
|
99 |
|
100 |
upload = config_cm["pipeline"]["upload_ingest_to_hub"]
|
101 |
+
upload.yaml_set_comment_before_after_key(
|
102 |
+
"source_documents_dir", before="⚠️ Same as output_dir from ingestion — adjust as needed"
|
103 |
+
)
|
104 |
|
105 |
with open(path, "w") as file:
|
106 |
yaml.dump(config_cm, file)
|
yourbench_space/evaluation.py
CHANGED
@@ -18,7 +18,7 @@ def create_eval_file(eval_ds_name: str):
|
|
18 |
if os.environ.get("SYSTEM") == "spaces":
|
19 |
template_path = Path("/home/user/app/yourbench_space/lighteval_task/yourbench_task.py")
|
20 |
else:
|
21 |
-
|
22 |
|
23 |
subprocess.run(["lighteval", "tasks", "create", str(template_path), task_name, eval_ds_name])
|
24 |
|
|
|
18 |
if os.environ.get("SYSTEM") == "spaces":
|
19 |
template_path = Path("/home/user/app/yourbench_space/lighteval_task/yourbench_task.py")
|
20 |
else:
|
21 |
+
template_path = Path("yourbench_space/lighteval_task/yourbench_task.py")
|
22 |
|
23 |
subprocess.run(["lighteval", "tasks", "create", str(template_path), task_name, eval_ds_name])
|
24 |
|
yourbench_space/leaderboard_space/env.py
CHANGED
@@ -12,4 +12,4 @@ MODELS = [m[0] for m in INIT_MODELS]
|
|
12 |
TASK = os.getenv("TASK")
|
13 |
# With storage
|
14 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
15 |
-
ORG_NAME = os.getenv("ORG_NAME")
|
|
|
12 |
TASK = os.getenv("TASK")
|
13 |
# With storage
|
14 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
15 |
+
ORG_NAME = os.getenv("ORG_NAME")
|
yourbench_space/utils.py
CHANGED
@@ -5,10 +5,10 @@ import shutil
|
|
5 |
import pathlib
|
6 |
import subprocess
|
7 |
from typing import List, Union, Optional
|
8 |
-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
|
9 |
|
10 |
import pandas as pd
|
11 |
from loguru import logger
|
|
|
12 |
|
13 |
import gradio as gr
|
14 |
from datasets import load_dataset
|
@@ -35,6 +35,7 @@ STAGE_DISPLAY_MAP = {
|
|
35 |
"lighteval": "Generate Lighteval Subset",
|
36 |
}
|
37 |
|
|
|
38 |
def to_commentable_yaml(obj):
|
39 |
"""
|
40 |
Recursively converts standard Python dicts and lists into
|
@@ -44,14 +45,15 @@ def to_commentable_yaml(obj):
|
|
44 |
# Convert dict to CommentedMap with recursively processed values
|
45 |
if isinstance(obj, dict):
|
46 |
return CommentedMap({k: to_commentable_yaml(v) for k, v in obj.items()})
|
47 |
-
|
48 |
# Convert list to CommentedSeq with recursively processed elements
|
49 |
elif isinstance(obj, list):
|
50 |
return CommentedSeq([to_commentable_yaml(i) for i in obj])
|
51 |
-
|
52 |
# Return non-container values as-is
|
53 |
return obj
|
54 |
|
|
|
55 |
def map_stage_names(stages: list[str]) -> list[str]:
|
56 |
return [STAGE_DISPLAY_MAP.get(stage, stage) for stage in stages]
|
57 |
|
|
|
5 |
import pathlib
|
6 |
import subprocess
|
7 |
from typing import List, Union, Optional
|
|
|
8 |
|
9 |
import pandas as pd
|
10 |
from loguru import logger
|
11 |
+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
|
12 |
|
13 |
import gradio as gr
|
14 |
from datasets import load_dataset
|
|
|
35 |
"lighteval": "Generate Lighteval Subset",
|
36 |
}
|
37 |
|
38 |
+
|
39 |
def to_commentable_yaml(obj):
|
40 |
"""
|
41 |
Recursively converts standard Python dicts and lists into
|
|
|
45 |
# Convert dict to CommentedMap with recursively processed values
|
46 |
if isinstance(obj, dict):
|
47 |
return CommentedMap({k: to_commentable_yaml(v) for k, v in obj.items()})
|
48 |
+
|
49 |
# Convert list to CommentedSeq with recursively processed elements
|
50 |
elif isinstance(obj, list):
|
51 |
return CommentedSeq([to_commentable_yaml(i) for i in obj])
|
52 |
+
|
53 |
# Return non-container values as-is
|
54 |
return obj
|
55 |
|
56 |
+
|
57 |
def map_stage_names(stages: list[str]) -> list[str]:
|
58 |
return [STAGE_DISPLAY_MAP.get(stage, stage) for stage in stages]
|
59 |
|