Skip to content

Add test for pytask-dev/pytask#216. #36

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

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ chronological order. Releases follow `semantic versioning <https://semver.org/>`
all releases are available on `PyPI <https://pypi.org/project/pytask-parallel>`_ and
`Anaconda.org <https://anaconda.org/conda-forge/pytask-parallel>`_.

0.1.2 - 2022-xx-xx
------------------

- :gh:`36` adds a test for https://github.com./pytask-dev/pytask/issues/216.


0.1.1 - 2022-02-08
------------------
Expand Down
1 change: 1 addition & 0 deletions src/pytask_parallel/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def _unserialize_and_execute_task(bytes_, show_locals, console_options):
def _process_exception(
exc_info: tuple[Any], show_locals: bool, console_options: ConsoleOptions
) -> tuple[Any]:
"""Process the exception and convert the traceback to a string."""
exc_info = remove_internal_traceback_frames_from_exc_info(exc_info)
traceback = Traceback.from_exception(*exc_info, show_locals=show_locals)
segments = console.render(traceback, options=console_options)
Expand Down
26 changes: 26 additions & 0 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,29 @@ def task_raising_error():
assert "───── Traceback" in result.output
assert ("───── locals" in result.output) is show_locals
assert ("[0, 1, 2, 3, 4]" in result.output) is show_locals


@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", PARALLEL_BACKENDS)
def test_generators_are_removed_from_depends_on_produces(tmp_path, parallel_backend):
"""Only works with pytask >=0.1.9."""
source = """
from pathlib import Path
import pytask

@pytask.mark.parametrize("produces", [
((x for x in ["out.txt", "out_2.txt"]),),
["in.txt"],
])
def task_example(produces):
produces = {0: produces} if isinstance(produces, Path) else produces
for p in produces.values():
p.write_text("hihi")
"""
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))

session = main(
{"paths": tmp_path, "parallel_backend": parallel_backend, "n_workers": 2}
)

assert session.exit_code == 0