We have a conditional branch that takes the output of two tasks, and, whether they are true or false...
f

Fredrik Lyford

over 2 years ago
We have a conditional branch that takes the output of two tasks, and, whether they are true or false, takes the output of two different tasks to process in a final task. Once in a while, the inputs from the boolean checks are being bound to the branch instead of the other tasks (once or twice out of a couple hundred). This makes flyte’s input converter fail. Does anyone else have the case where the variable being conditionally evaluated is not the same variable being passed into the nested tasks? Happy to share more logging as needed. Running on GKE.
Traceback (most recent call last):

      File "/root/.varner_dp/venv/3.7.1/lib/python3.9/site-packages/flytekit/exceptions/scopes.py", line 165, in system_entry_point
        return wrapped(*args, **kwargs)
      File "/root/.varner_dp/venv/3.7.1/lib/python3.9/site-packages/flytekit/core/base_task.py", line 472, in dispatch_execute
        native_inputs = TypeEngine.literal_map_to_kwargs(exec_ctx, input_literal_map, self.python_interface.inputs)
      File "/root/.varner_dp/venv/3.7.1/lib/python3.9/site-packages/flytekit/core/type_engine.py", line 800, in literal_map_to_kwargs
        return {k: TypeEngine.to_python_value(ctx, lm.literals[k], python_types[k]) for k, v in lm.literals.items()}
      File "/root/.varner_dp/venv/3.7.1/lib/python3.9/site-packages/flytekit/core/type_engine.py", line 800, in <dictcomp>
        return {k: TypeEngine.to_python_value(ctx, lm.literals[k], python_types[k]) for k, v in lm.literals.items()}

Message:

    'n2.o0'

SYSTEM ERROR! Contact platform administrators.
Optional FlyteFile in dataclass In the following code example, my test_task_2 returns a dataclass w...
k

Klemens Kasseroller

almost 3 years ago
Optional FlyteFile in dataclass In the following code example, my test_task_2 returns a dataclass with an Optional[FlyteFile] type. In test_task_1 I am directly returning an Optional[FlyteFile], which works fine, however in test_task_2 only the first non-optional file shows up on the remote. If the first example works, I would also expect, that my TaskOutput.file2 is uploaded correctly. Is this expected behavior / are optional types in dataclasses not supported? I am using flytekit 1.2.7 locally. Thanks for help
from dataclasses import dataclass
from typing import Optional

from dataclasses_json import dataclass_json
from flytekit import workflow, task
from flytekit.types.file import FlyteFile


@dataclass_json
@dataclass
class TaskOutput:
    file1: FlyteFile
    file2: Optional[FlyteFile]


@task
def test_task_1() -> Optional[FlyteFile]:
    with open("file11.txt", "w+") as f:
        f.write("")
    return FlyteFile("file11.txt", remote_path="<s3://test-bucket/tmp/file11.txt>")


@task
def test_task_2() -> TaskOutput:
    with open("file21.txt", "w+") as f:
        f.write("")
    with open("file22.txt", "w+") as f:
        f.write("")

    return TaskOutput(
        FlyteFile("file21.txt", remote_path="<s3://test-bucket/tmp/file21.txt>"),
        FlyteFile("file22.txt", remote_path="<s3://test-bucket/tmp/file22.txt>")
    )


@workflow
def test_workflow():
    test_task_1()
    test_task_2()


if __name__ == '__main__':
    test_workflow()