From e98e6acae1c01d0de27ddfaeafd795fa02773959 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 3 Feb 2022 15:29:56 +0200 Subject: [PATCH] Fix nargs="?" without type does not properly cast the default value (#531) --- clearml/backend_interface/task/args.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clearml/backend_interface/task/args.py b/clearml/backend_interface/task/args.py index 1f2cc78b..053cd6ea 100644 --- a/clearml/backend_interface/task/args.py +++ b/clearml/backend_interface/task/args.py @@ -313,7 +313,13 @@ class _Arguments(object): # now we should try and cast the value if we can # noinspection PyBroadException try: - v = var_type(v) + # Since we have no actual var type here, we check if the string presentation of the original + # default value and the new value are the same, if they are, + # we should just use the original default value + if str(v) == str(current_action.default): + v = current_action.default + else: + v = var_type(v) # cast back to int if it's the same value if type(current_action.default) == int and int(v) == v: arg_parser_arguments[k] = v = int(v)