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
674611e9
Commit
674611e9
authored
Jul 05, 2025
by
Baber
Browse files
serialize better
parent
57adbd35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
17 deletions
+8
-17
lm_eval/config/task.py
lm_eval/config/task.py
+8
-17
No files found.
lm_eval/config/task.py
View file @
674611e9
...
...
@@ -357,20 +357,11 @@ class TaskConfig(dict):
return
setattr
(
self
,
item
,
value
)
def
to_dict
(
self
,
keep_callable
:
bool
=
False
)
->
dict
:
"""Return a printable dict with Nones stripped and callables serialised.
:return: dict
A printable dictionary version of the TaskConfig object.
"""
cfg
=
asdict
(
self
)
return
{
k
:
[
{
mk
:
maybe_serialize
(
mv
,
keep_callable
)
for
mk
,
mv
in
md
.
items
()}
for
md
in
v
]
if
k
==
"metric_list"
else
maybe_serialize
(
v
)
for
k
,
v
in
cfg
.
items
()
if
v
is
not
None
}
def
_ser
(
x
):
if
isinstance
(
x
,
dict
):
return
{
k
:
_ser
(
v
)
for
k
,
v
in
x
.
items
()}
if
isinstance
(
x
,
(
list
,
tuple
,
set
)):
return
type
(
x
)(
_ser
(
i
)
for
i
in
x
)
return
maybe_serialize
(
x
,
keep_callable
)
return
{
k
:
_ser
(
v
)
for
k
,
v
in
asdict
(
self
).
items
()
if
v
is
not
None
}
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