Fix connect list of dicts parsed incorrectly in remote

This commit is contained in:
allegroai 2022-12-29 13:17:25 +02:00
parent 2e11f152f8
commit a3d44aa81f
2 changed files with 19 additions and 1 deletions

View File

@ -10,6 +10,7 @@ from typing import Tuple, Type, Union
from ...backend_api import Session
from ...binding.args import call_original_argparser
from ...utilities.proxy_object import get_type_from_basic_type_str
class _Arguments(object):
@ -517,7 +518,7 @@ class _Arguments(object):
v_type = type(v)
elif parameters_type.get(k):
v_type_str = parameters_type.get(k)
v_type = next((t for t in (bool, int, float, str, list, tuple) if t.__name__ == v_type_str), str)
v_type = get_type_from_basic_type_str(v_type_str)
else:
# this will be type(None), we deal with it later
v_type = type(v)

View File

@ -148,6 +148,23 @@ def cast_basic_type(value, type_str):
return value
def get_type_from_basic_type_str(type_str):
# default to str
if not type_str:
return str
if str(type_str).startswith("list/"):
v_type = list
elif str(type_str).startswith("tuple/"):
v_type = tuple
elif str(type_str).startswith("dict/"):
v_type = dict
else:
v_type = next((t for t in (bool, int, float, str, list, tuple, dict) if t.__name__ == type_str), str)
return v_type
def get_basic_type(value):
basic_types = (float, int, bool, six.string_types, list, tuple, dict)