diff --git a/clearml/backend_config/converters.py b/clearml/backend_config/converters.py index 64aee770..0f2ee21e 100644 --- a/clearml/backend_config/converters.py +++ b/clearml/backend_config/converters.py @@ -1,5 +1,4 @@ import base64 -from distutils.util import strtobool from typing import Union, Optional, Any, TypeVar, Callable, Tuple import six @@ -14,6 +13,22 @@ except ImportError: ConverterType = TypeVar("ConverterType", bound=Callable[[Any], Any]) +def strtobool(val): + """Convert a string representation of truth to true (1) or false (0). + + True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values + are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if + 'val' is anything else. + """ + val = val.lower() + if val in ('y', 'yes', 't', 'true', 'on', '1'): + return 1 + elif val in ('n', 'no', 'f', 'false', 'off', '0'): + return 0 + else: + raise ValueError("invalid truth value %r" % (val,)) + + def base64_to_text(value): # type: (Any) -> Text return base64.b64decode(value).decode("utf-8")