Skip to content

Provide wrapper for functions that modify inputs #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
effigies opened this issue Mar 7, 2023 · 5 comments
Open

Provide wrapper for functions that modify inputs #625

effigies opened this issue Mar 7, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@effigies
Copy link
Contributor

effigies commented Mar 7, 2023

In #623, @tclose added a function that modifies its input as a reliable reproducer of a task whose input hash changes after execution, resulting in a deadlocked workflow as the task is complete but its results are no longer findable in the cache directory.

In a comment I proposed an addition to the pydra.mark module:


If someone has an unsafe function, they're going to need to either rewrite or wrap it themselves, or we can provide a standard tool with straightforward semantics:

def wrap_unsafe(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        return func(*deepcopy(args), **deepcopy(kwargs))
    return wrapper

So we could write:

safe_task = task(wrap_unsafe(unsafe_func))

And if somebody has control over the function but is lazy or (more charitably) finds an explicit copy cluttering, they could write:

@task
@wrap_unsafe
def f(x):
    x.a = 2
    return x
@tclose
Copy link
Contributor

tclose commented Mar 8, 2023

In #623 you mentioned a check at the end of the task to see whether the task has altered its input hash. I think this is a good idea. Should that be included in this issue or in a separate one?

@effigies
Copy link
Contributor Author

effigies commented Mar 8, 2023

I think it makes sense as part of this issue. Good catch.

@tclose tclose added the to consider suggesting changes that require more discussion label Apr 1, 2025
@tclose
Copy link
Contributor

tclose commented Apr 29, 2025

#791 is related to this issue I think

@tclose
Copy link
Contributor

tclose commented Apr 29, 2025

#784 would also help mitigate this problem by preventing the workflow execution to break and allowing us to raise a warning about future false-negative cache misses

@tclose tclose removed the to consider suggesting changes that require more discussion label Apr 29, 2025
@github-project-automation github-project-automation bot moved this to To do (v1.0) in Pydra Roadmap Apr 29, 2025
@tclose
Copy link
Contributor

tclose commented Jun 10, 2025

Probably should be addressed at the same time as #791

@tclose tclose moved this from Triage to v1.0 in Pydra Roadmap Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: v1.0
Development

No branches or pull requests

2 participants