New RunLLM response generated: >>>*# Question* Hi...
# runllm-flyte-trial
a
New RunLLM response generated: >>>*# Question* Hi all! I have this workflow:
Copy code
@task
def generate_directory() -> FlyteDirectory:
    # do something
    return FlyteDirectory(path=".....")

@task
def consume_directories(dirs: List[FlyteDirectory]):
     # do something with a list of directories
    return

@workflow
def wf():
    dirs = map_task(generate_directory)()
    consume_directories(dirs=dirs)
I keep getting this error:
Copy code
Failed to convert inputs of task    
                         'wf.consume_directories':                         
                           'NoneType' object has no attribute 'uri'
is it not allowed to return a list of FlyteDirectory? # Answer The error occurs because the
map_task
might return
None
for some instances, causing the
consume_directories
task to fail when it encounters
None
values. You can handle this by changing the input type of
consume_directories
to
List[Optional[FlyteDirectory]]
.
Copy code
from typing import List, Optional
from flytekit import task, workflow, map_task
from flytekit.types.directory import FlyteDirectory

@task
def generate_directory() -> FlyteDirectory:
    # do something
    return FlyteDirectory(path="...")

@task
def consume_directories(dirs: List[Optional[FlyteDirectory]]):
    # do something with a list of directories
    return

@workflow
def wf():
    dirs = map_task(generate_directory)()
    consume_directories(dirs=dirs)
Would you like more details on this workaround or any other aspect of Flyte? Sources: - Flyte Community Discussion Slack Link https://flyte-org.slack.com/archives/CP2HDHKE1/p1724794566.004419 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.