mirror of
https://github.com/clearml/clearml
synced 2025-02-14 16:46:12 +00:00
Fix when using Task.set_parameters() dict parameters are not dumped as JSON, causing the SDK to load them incorrectly
This commit is contained in:
parent
e40b37ef53
commit
961a41231e
@ -1158,24 +1158,11 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
|
|
||||||
str_value = str(value)
|
str_value = str(value)
|
||||||
if isinstance(value, (tuple, list, dict)):
|
if isinstance(value, (tuple, list, dict)):
|
||||||
if 'None' in re.split(r'[ ,\[\]{}()]', str_value):
|
try:
|
||||||
# If we have None in the string we have to use json to replace it with null,
|
str_json = json.dumps(value)
|
||||||
# otherwise we end up with None as string when running remotely
|
return str_json
|
||||||
try:
|
except TypeError:
|
||||||
str_json = json.dumps(value)
|
pass
|
||||||
# verify we actually have a null in the string, otherwise prefer the str cast
|
|
||||||
# This is because we prefer to have \' as in str and not \" used in json
|
|
||||||
if 'null' in re.split(r'[ ,\[\]{}()]', str_json):
|
|
||||||
return str_json
|
|
||||||
except TypeError:
|
|
||||||
# if we somehow failed to json serialize, revert to previous std casting
|
|
||||||
pass
|
|
||||||
elif any('\\' in str(v) for v in value):
|
|
||||||
try:
|
|
||||||
str_json = json.dumps(value)
|
|
||||||
return str_json
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if isinstance(value, Enum):
|
if isinstance(value, Enum):
|
||||||
# remove the class name
|
# remove the class name
|
||||||
|
Loading…
Reference in New Issue
Block a user