Skip to content

Commit

Permalink
dump_to_json no longer converts numeric values to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mdw771 committed May 22, 2024
1 parent 384e2b4 commit 166a732
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion generic_trainer/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def string_to_object(self, key, value):
value = getattr(importlib.import_module('.'.join(class_import_path[:-1])), class_import_path[-1])
elif value in ['True', 'False']:
value = True if value == 'True' else False
elif isinstance(value, (int, float, bool, dict)):
value = value
else:
for caster in (int, float):
try:
Expand All @@ -104,7 +106,7 @@ def object_to_string(self, key, value):
"""
if isinstance(value, OptionContainer):
value = value.get_serializable_dict()
elif isinstance(value, dict):
elif isinstance(value, (dict, int, float, bool)):
value = value
elif isinstance(value, (tuple, list)):
value = [self.object_to_string(key, x) for x in value]
Expand Down

0 comments on commit 166a732

Please sign in to comment.