How should I handle json serialization of ListConfig objects? #618
-
I've run into an issue with configs that contain lists if they get serialized to json. The process throws an error because the list remains a ListConfig, which doesn't json serialize. Here's a minimum example: from hydra_zen import builds, instantiate
import json
def json_serialize_func(list_obj):
return json.dumps(list_obj)
json_config = builds(json_serialize_func, ['test', 'item'])
instantiate(json_config) raises the following:
I've gotten around it by manually converting the ListConfig to a list using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Ah, this one gets me too. Unfortunately Hydra converts lists to a
|
Beta Was this translation helpful? Give feedback.
Ah, this one gets me too. Unfortunately Hydra converts lists to a
omegaconf.ListConfig
object and does not convert it to list on instantiation. There are two options for you:json.dumps(list(list_obj))
json_config = builds(json_serialize_func, ['test', 'item'], hydra_convert="all")