Hi, I am struggling on using a DataclassTransformer on a dataclass of the following shape: ```@data...
k

Klemens Kasseroller

over 2 years ago
Hi, I am struggling on using a DataclassTransformer on a dataclass of the following shape:
@dataclass_json
@dataclass
class WFConfig:
    some_key: Dict[int, List[int]] = field(default_factory=lambda: {1: [2, 3, 4]})
This works on a remote execution, but not locally using the flytekit TypeEngine as in the following example, which raises the error ValueError: Only generic univariate typing.List[T] type is supported.
from dataclasses import dataclass, field
from typing import List, Dict

import flytekit
from dataclasses_json import dataclass_json
from flytekit.core.type_engine import TypeEngine


@dataclass_json
@dataclass
class WFConfig:
    some_key: Dict[int, List[int]] = field(default_factory=lambda: {1: [2, 3, 4]})


config = WFConfig()
transformer = TypeEngine.get_transformer(type(config))
flyte_context = flytekit.FlyteContextManager.current_context()

literal_type = transformer.get_literal_type(type(config))
literal = transformer.to_literal(flyte_context, config, type(config), literal_type)

python_type = transformer.guess_python_type(literal_type)
TypeEngine.to_python_value(flytekit.FlyteContextManager.current_context(), literal, python_type)
To me it seems like the python type could not be guessed correctly from the literal type. Does anyone have an Idea how I could fix this, or is this special composition of dict/list not supported? Thanks! I am working with flytekit 1.6.2