Skip to content
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

ENH: Remove processed depends_on and produces markers from task function. #216

Closed
tobiasraabe opened this issue Feb 9, 2022 · 0 comments · Fixed by #218
Closed

ENH: Remove processed depends_on and produces markers from task function. #216

tobiasraabe opened this issue Feb 9, 2022 · 0 comments · Fixed by #218
Labels
enhancement New feature or request

Comments

@tobiasraabe
Copy link
Member

Is your feature request related to a problem?

When a generator is used to provide arguments in a single run of a parametrization and the build is parallelized, the following issue occurs: pytask-dev/pytask-parallel#35.

A small reproducible example is:

import pytask

@pytask.mark.parametrize("produces", [
    ((x for x in ["out.txt", "out_2.txt"]),),
    ["in.txt"],
])
def task_example(produces):
    for p in produces:
        p.write_text("hihi")

When pytask-parallel attempts to pickle the task function, the generator is empty but still there and cannot be pickled.

(Pdb) session.tasks[0].function.pytaskmark
[Mark(name='produces', args=(<generator object <genexpr> at 0x0000021C7D05A9E0>,), kwargs={})]
(Pdb) session.tasks[0].function.pytaskmark[0].args
(<generator object <genexpr> at 0x0000021C7D05A9E0>,)
(Pdb) session.tasks[0].function.pytaskmark[0].args[0]
<generator object <genexpr> at 0x0000021C7D05A9E0>
(Pdb) !list(session.tasks[0].function.pytaskmark[0].args[0])
[]

Describe the solution you'd like

For other markers we already remove them from the function after they are processed. For example, @pytask.mark.parametrize is removed.

API breaking implications

Good question! Don't expect issues.

Describe alternatives you've considered

None

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
None yet
Development

Successfully merging a pull request may close this issue.

1 participant