Skip to content

BUG: Functional Interface generates two sessions #651

Open
@noppelmax

Description

@noppelmax
  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pytask.
  • (optional) I have confirmed this bug exists on the main branch of pytask.

Hey,

I again tried to use the functional interface. Actually, I wanted to use pytask for the very same task as last time when I failed to get it working with pytask (#625). I tested the latest version from pip (5.1.0) and today's main branch (https://github.com/pytask-dev/pytask/tree/5804f526e01ed1d7a262a43a0dbff8d9aed06e15) with the following code from https://pytask-dev.readthedocs.io/en/stable/how_to_guides/functional_interface.html:

from pathlib import Path
from typing import Annotated

import pytask
from pytask import task


def task_create_first_file() -> Annotated[str, Path("first.txt")]:
    return "Hello, "


task_create_second_file = task(
    name="task_create_second_file", produces=Path("second.txt")
)(lambda *x: "World!")


def task_merge_files(
    first: Path = Path("first.txt"), second: Path = Path("second.txt")
) -> Annotated[str, Path("hello_world.txt")]:
    return first.read_text() + second.read_text()

session = pytask.build(
    tasks=[task_create_first_file, task_merge_files, task_create_second_file]
)

And I got the following result:

(bestofbothworlds) mnoppel@gpu08:~/bestofbothworlds$ python demo.py 
───────────────────────────────────────────── Start pytask session ─────────────────────────────────────────────
Platform: linux -- Python 3.11.7, pytask 0.5.2.dev13+g5804f52, pluggy 1.5.0
Root: /home/i56/mnoppel/bestofbothworlds
Configuration: /home/i56/mnoppel/bestofbothworlds/pyproject.toml
Plugins: pytask_parallel-0.5.0
/home/i56/mnoppel/bestofbothworlds
───────────────────────────────────────────── Start pytask session ─────────────────────────────────────────────
Platform: linux -- Python 3.11.7, pytask 0.5.2.dev13+g5804f52, pluggy 1.5.0
Root: /home/i56/mnoppel/bestofbothworlds
Configuration: /home/i56/mnoppel/bestofbothworlds/pyproject.toml
Plugins: pytask_parallel-0.5.0
Exit: pytask tried to launch a second live display which is impossible. the issue occurs when you use pytask on 
the command line on a task module that uses the programmatic interface of pytask at the same time. Use either 
the command line or the programmatic interface.
Collected 3 tasks.


────────────────────────────────────────────────────────────────────────────────────────────────────────────────
╭──────────────── Summary ─────────────────╮
│  3  Collected tasks                      │
│  3  Skipped because unchanged  (100.0%)  │
╰──────────────────────────────────────────╯
────────────────────────────────────────── Succeeded in 0.07 seconds ───────────────────────────────────────────

So, for some reason it starts two sessions. But my code only starts one and is equivalent to the example.

Problem description

Mainly, it is a display bug again, similar to #621.

Expected Output

I was expecting only one pytask session to show up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions