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

Chandrashekhar Kotekar

03/07/2024, 10:45 AM
Hi, I am trying to use
conditional
in Flyte workflow. My code looks like below:
Copy code
@task
def file_exists_on_s3(bucket:str, path: str) -> Optional[str]:
    # this is not actual code
    full_path = bucket + path
    if S3.exists(full_path):
        return full_path
    else:
        return None

@task
def process_file(file_path:str) -> str:
    # process given file
    # write new file on s3
    return new_file_path

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

@workflow
def my_awesome_workflow() -> str:
    file_path = file_exists_on_s3(bucket="my_bucket", path: "path/inside/bucket/file.txt")
    return conditional("file_exists_condition")
    .if_(file_path.is_none())
    .then(process_file(file_path=file_path))
    .else_()
    .then(noop_task())
question: I had to introduce
noop_task()
because it seems like
.then()
needs something which returns
Promise
. Is there any way I can avoid writing
noop_task()
and just return a string from
.then()
?
s

Samhita Alla

03/07/2024, 4:50 PM
we have an issue to track this effort: https://github.com/flyteorg/flyte/issues/3533