mirror of
https://github.com/clearml/clearml
synced 2025-03-03 18:52:12 +00:00
Fix None type as default value in dictionary
This commit is contained in:
parent
b50bfd5b63
commit
d03311764e
@ -217,7 +217,7 @@ class _Arguments(object):
|
|||||||
# if we have an int, we should cast to float, because it is more generic
|
# if we have an int, we should cast to float, because it is more generic
|
||||||
if var_type == int:
|
if var_type == int:
|
||||||
var_type = float
|
var_type = float
|
||||||
elif var_type == type(None):
|
elif var_type == type(None): # do not change! because isinstance(var_type, type(None)) === False
|
||||||
var_type = str
|
var_type = str
|
||||||
# now we should try and cast the value if we can
|
# now we should try and cast the value if we can
|
||||||
try:
|
try:
|
||||||
@ -370,12 +370,14 @@ class _Arguments(object):
|
|||||||
except Exception:
|
except Exception:
|
||||||
self._task.log.warning('Failed parsing task parameter %s=%s keeping default %s=%s' %
|
self._task.log.warning('Failed parsing task parameter %s=%s keeping default %s=%s' %
|
||||||
(str(k), str(param), str(k), str(v)))
|
(str(k), str(param), str(k), str(v)))
|
||||||
elif isinstance(v_type, type(None)):
|
|
||||||
v_type = str
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dictionary[k] = v_type(param)
|
# do not change this comparison because isinstance(v_type, type(None)) === False
|
||||||
except ValueError:
|
if v_type == type(None):
|
||||||
|
dictionary[k] = str(param) if param else None
|
||||||
|
else:
|
||||||
|
dictionary[k] = v_type(param)
|
||||||
|
except Exception:
|
||||||
self._task.log.warning('Failed parsing task parameter %s=%s keeping default %s=%s' %
|
self._task.log.warning('Failed parsing task parameter %s=%s keeping default %s=%s' %
|
||||||
(str(k), str(param), str(k), str(v)))
|
(str(k), str(param), str(k), str(v)))
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user