New RunLLM response generated: >>>*# Question* Hi...
# runllm-flyte-trial
a
New RunLLM response generated: >>>*# Question* Hi all! I have this workflow where I need to check gcs for a file, if exists: do a subworkflow, otherwise just do nothing and succeed the wf. I have a task called noop that does nothing. However: when I register this, i get this error:
Copy code
failed to compile workflow for [resource_type:WORKFLOW project:"projectneame" domain:"development" name:"<http://flyte.workflows.wf.wf|flyte.workflows.wf.wf>" version:"test"] with err failed to compile workflow with err Collected Errors: 1
        Error 0: Code: ValueRequired, Node Id: n1, Description: Value required [RightValue.Val].
my code looks something like this
Copy code
csv_file = get_file(dir: FlyteDirectory ...) -> Optional[FlyteFile]

    resulsts = (
        conditional("con")
        .if_(csv_file == None) # or if_(csv_file.is_none())
        .then(noop())
        .else_()
        .then(subwf(csv_file))
    )
# Answer The error you're encountering is due to the requirement that all branches of a conditional in Flyte must return a
Promise
object. This ensures that the workflow has a well-defined execution path for every possible input. Your
noop
task should return a
Promise
to avoid the compilation error. Here's how you can structure your workflow to ensure it compiles correctly:
Copy code
from flytekit import task, workflow, conditional
from flytekit.types.file import FlyteFile, FlyteDirectory
from typing import Optional

@task
def get_file(dir: FlyteDirectory) -> Optional[FlyteFile]:
    # Implementation to check for file in GCS
    pass

@task
def noop() -> str:
    return "noop"

@workflow
def subwf(file: FlyteFile) -> str:
    # Subworkflow implementation
    pass

@workflow
def my_workflow() -> str:
    csv_file = get_file(dir=FlyteDirectory(...))
    return (
        conditional("con")
        .if_(csv_file.is_none())
        .then(noop())
        .else_()
        .then(subwf(file=csv_file))
    )
This ensures that both branches of the conditional return a
Promise
, which is required for the workflow to compile successfully. Would you like more details on any specific part of this solution? Sources: - Flyte Conditional Workflow Example - Flyte Issue #5044 Slack Link https://flyte-org.slack.com/archives/CP2HDHKE1/p1723389120.174249 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.