https://flyte.org logo
#ask-the-community
Title
# ask-the-community
p

Pavlina Mitsou

09/05/2023, 2:42 PM
Hello everyone 👋 I have a problem with my workflow. I try to run the following tasks.
Copy code
@dataclass_json
@dataclass
class Input:
    metric: str
    data: dict = field(default_factory=dict)

@task
def load_configs() -> List[Input]:
    folder_name = "metrics"
    config_files = extract_config_files(folder_name=folder_name)
    configs: List[Input] = []
    for config_file in config_files:
        with open(config_file, "r") as file:
            config = Input(config_file, yaml.safe_load(file))
            configs.append(config)
    return configs


@task
def check_type(configs: List[Input]):
    print(type(configs))
    print(type(configs[0]))
    return type(configs)

@workflow  # type: ignore
def start_workflow() -> str:
    configs: List[Input] = load_configs()

    check_type(configs=configs)
I see that my first task,
load_configs()
, finishes successfully and it returns correctly the list of objects but the next task,
check_type
, it complains about
only generic univariate typing.list[t] type is supported.
I found these similar cases [1], [2] but I do not think that it is applicable to my situation. Any help or idea why I am getting this error? Thank you in advance 🙏
s

Samhita Alla

09/06/2023, 7:20 AM
I don't think list of dataclasses type is supported yet. @Kevin Su, can you confirm?
p

Pavlina Mitsou

09/06/2023, 8:38 AM
I think that the problem is not with the dataclass. When I define the dataclass with simple types, it works correctly. Like below:
Copy code
@dataclass_json
@dataclass
class Input:
    metric: str
    data: str
The problem should be related to the dict most probably?
s

Samhita Alla

09/06/2023, 11:43 AM
Can you replace
dict
with
dict[your_key_type, your_value_type]
?
k

Kevin Su

09/06/2023, 5:14 PM
yes, could you try typing.Dict[str, typing.Any] instead
p

Pavlina Mitsou

09/07/2023, 7:27 AM
I also had tried that but still did not workout 😕
s

Samhita Alla

09/07/2023, 8:52 AM
If that's the case, could you create an issue? Please specify all the steps to reproduce the error. Are you seeing this error with the latest version of flytekit? [flyte-bug]
3 Views