Skip to content

How to detect failure to create a file? #105

@tesujimath

Description

@tesujimath

There seems to be no way to trigger a re-run after failing to create a file.

As I develop my workflow, I find I may have a bug which causes an expected file not to be created at all. I am surprised this is not an error, since I have a File as output which doesn't exist in the filesystem.

Upon fixing my bug, subsequent runs of redun have no effect, as it seems to have happily cached the file as missing, and there is no changed state in the filesystem to trigger rerunning the task.

I think it should be an error if an output File from a task doesn't exist when the task completes?

Example workflow:

from redun import task, File
from typing import List

redun_namespace = "redun.examples.missing_after_error"


@task()
def create(path: str, content: str) -> File:
    if ok():
        with open(path, "w") as f:
            f.write(content)
    return File(path)


def ok() -> bool:
    # flipping this to True and rerunning doesn't trigger redun to generate the missing files
    return False


@task()
def main() -> List[File]:
    f1 = create("out/freddy1", "Hello Freddy 1\n")
    f2 = create("out/freddy2", "Hello Freddy 2\n")
    return [f1, f2]

I understand that the ok function is not hashed as part of the task. That's not my concern. This is about missing files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions