ancient-wolf-19325
08/11/2024, 3:12 PMfailed 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
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:
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.