white-teacher-47376
06/12/2023, 2:34 PM@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.2freezing-airport-6809
white-teacher-47376
06/12/2023, 3:02 PMfreezing-airport-6809
shy-evening-51366
07/11/2023, 7:59 AM@dataclass_json
@dataclass
class WorkflowConfig:
workflow: dict = field(default_factory=dict)
env: Optional[dict] = field(default_factory=dict)
model: Optional[dict] = field(default_factory=dict)
Changing the workflow
field name to anything else fixed the issue for me.