Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
1de882c2
Commit
1de882c2
authored
Jul 27, 2025
by
Baber
Browse files
fix test
parent
b58e5556
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
17 deletions
+17
-17
lm_eval/tasks/_config_loader.py
lm_eval/tasks/_config_loader.py
+6
-6
lm_eval/tasks/factory.py
lm_eval/tasks/factory.py
+1
-1
lm_eval/tasks/index.py
lm_eval/tasks/index.py
+2
-2
tests/test_config_loader.py
tests/test_config_loader.py
+5
-5
tests/utils.py
tests/utils.py
+3
-3
No files found.
lm_eval/tasks/_config_loader.py
View file @
1de882c2
...
...
@@ -146,8 +146,8 @@ def _import_fun_from_str(path_str: str) -> Any:
def
load_yaml
(
path
:
str
|
Path
,
*
,
resolve_func
tions
:
bool
=
True
,
re
solve_includes
:
bool
=
True
,
resolve_func
:
bool
=
True
,
re
cursive
:
bool
=
True
,
_seen
:
set
[
Path
]
|
None
=
None
,
)
->
dict
[
str
,
Any
]:
"""Pure data-loading helper.
...
...
@@ -161,11 +161,11 @@ def load_yaml(
raise
ValueError
(
f
"Include cycle at
{
path
}
"
)
_seen
.
add
(
path
)
loader_cls
=
_make_loader
(
path
.
parent
,
resolve_funcs
=
resolve_func
tions
)
loader_cls
=
_make_loader
(
path
.
parent
,
resolve_funcs
=
resolve_func
)
with
path
.
open
(
"rb"
)
as
fh
:
cfg
=
yaml
.
load
(
fh
,
Loader
=
loader_cls
)
if
not
re
solve_includes
or
"include"
not
in
cfg
:
if
not
re
cursive
or
"include"
not
in
cfg
:
return
cfg
else
:
includes
=
cfg
.
pop
(
"include"
)
...
...
@@ -176,8 +176,8 @@ def load_yaml(
merged
.
update
(
load_yaml
(
inc_path
,
resolve_func
tions
=
resolve_func
tions
,
re
solve_includes
=
True
,
resolve_func
=
resolve_func
,
re
cursive
=
True
,
_seen
=
_seen
,
),
)
...
...
lm_eval/tasks/factory.py
View file @
1de882c2
...
...
@@ -106,7 +106,7 @@ class TaskFactory:
self
,
entry
:
Entry
,
overrides
:
dict
[
str
,
Any
]
|
None
)
->
dict
[
str
,
Any
]:
if
entry
.
yaml_path
:
cfg
=
deepcopy
(
load_cfg_cached
(
entry
.
yaml_path
,
resolve_func
tions
=
True
))
cfg
=
deepcopy
(
load_cfg_cached
(
entry
.
yaml_path
,
resolve_func
=
True
))
else
:
cfg
=
{
"metadata"
:
{
"config"
:
"unknown"
}}
# python task without YAML
...
...
lm_eval/tasks/index.py
View file @
1de882c2
...
...
@@ -56,8 +56,8 @@ class TaskIndex:
try
:
cfg
=
load_cfg
(
yaml_path
,
resolve_func
tions
=
False
,
re
solve_includes
=
resolve_includes
,
resolve_func
=
False
,
re
cursive
=
resolve_includes
,
)
self
.
process_cfg
(
cfg
,
yaml_path
,
index
)
except
Exception
as
err
:
...
...
tests/test_config_loader.py
View file @
1de882c2
...
...
@@ -308,7 +308,7 @@ doc_to_text: !function utils.process_doc
"""
file_path
=
yaml_file
(
content
)
result
=
load_yaml
(
file_path
,
resolve_func
tions
=
True
)
result
=
load_yaml
(
file_path
,
resolve_func
=
True
)
assert
callable
(
result
[
"doc_to_text"
])
assert
result
[
"doc_to_text"
](
"hello"
)
==
"HELLO"
...
...
@@ -320,7 +320,7 @@ doc_to_text: !function utils.process_doc
"""
file_path
=
yaml_file
(
content
)
result
=
load_yaml
(
file_path
,
resolve_func
tions
=
False
)
result
=
load_yaml
(
file_path
,
resolve_func
=
False
)
assert
isinstance
(
result
[
"doc_to_text"
],
str
)
# When resolve_functions=False, it returns the full path + function spec
...
...
@@ -345,7 +345,7 @@ shared_value: 100
"""
main_path
=
yaml_file
(
main_content
,
"main.yaml"
)
result
=
load_yaml
(
main_path
,
re
solve_includes
=
True
)
result
=
load_yaml
(
main_path
,
re
cursive
=
True
)
assert
result
[
"task"
]
==
"main_task"
assert
result
[
"shared_metric"
]
==
"f1_score"
...
...
@@ -368,7 +368,7 @@ main_key: main_value
"""
main_path
=
yaml_file
(
main_content
)
result
=
load_yaml
(
main_path
,
re
solve_includes
=
True
)
result
=
load_yaml
(
main_path
,
re
cursive
=
True
)
assert
result
[
"main_key"
]
==
"main_value"
assert
result
[
"included_key"
]
==
"included_value"
...
...
@@ -381,7 +381,7 @@ task: test_task
"""
file_path
=
yaml_file
(
content
)
result
=
load_yaml
(
file_path
,
re
solve_includes
=
False
)
result
=
load_yaml
(
file_path
,
re
cursive
=
False
)
assert
result
[
"include"
]
==
[
"other.yaml"
]
assert
result
[
"task"
]
==
"test_task"
...
...
tests/utils.py
View file @
1de882c2
import
os
from
typing
import
List
,
Union
from
lm_eval.tasks
import
load_yaml
_config
from
lm_eval.tasks
._config_loader
import
load_yaml
# {{{CI}}}
...
...
@@ -12,7 +12,7 @@ from lm_eval.tasks import load_yaml_config
# reads a text file and returns a list of words
# used to read the output of the changed txt from tj-actions/changed-files
def
load_changed_files
(
file_path
:
str
)
->
List
[
str
]:
with
open
(
file_path
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
with
open
(
file_path
,
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
words_list
=
list
(
content
.
split
())
return
words_list
...
...
@@ -26,7 +26,7 @@ def parser(full_path: List[str]) -> List[str]:
_output
=
set
()
for
x
in
full_path
:
if
x
.
endswith
(
".yaml"
)
and
os
.
path
.
exists
(
x
):
config
=
load_yaml
_config
(
x
,
mode
=
"simple"
)
config
=
load_yaml
(
x
,
recursive
=
True
,
resolve_func
=
True
)
if
isinstance
(
config
[
"task"
],
str
):
_output
.
add
(
config
[
"task"
])
elif
isinstance
(
config
[
"task"
],
list
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment