Collecting tasks#

If you want to inspect your project and see a summary of all the tasks, you can use the pytask collect command.

Let us take the following task.

# Content of task_module.py

import pytask


@pytask.mark.depends_on("in.txt")
@pytask.mark.produces("out.txt")
def task_write_file(depends_on, produces):
    produces.write_text(depends_on.read_text())

Now, running pytask collect will produce the following output.

$ pytask
──────────────────────────── Start pytask session ────────────────────────────
Platform: win32 -- Python <span style="color: var(--termynal-blue)">3.10.0</span>, pytask <span style="color: var(--termynal-blue)">0.3.0</span>, pluggy <span style="color: var(--termynal-blue)">1.0.0</span>
Root: C:\Users\pytask-dev\git\my_project
Collected <span style="color: var(--termynal-blue)">1</span> task.

Collected tasks:
└── 🐍 &lt;Module task_module.py&gt;
    └── 📝 &lt;Function <span class="termynal-dim">task_module.py::</span>task_write_file&gt;

──────────────────────────────────────────────────────────────────────────────

If you want to have more information regarding the dependencies and products of the task, append the pytask collect --nodes flag.

$ pytask
──────────────────────────── Start pytask session ────────────────────────────
Platform: win32 -- Python <span style="color: var(--termynal-blue)">3.10.0</span>, pytask <span style="color: var(--termynal-blue)">0.3.0</span>, pluggy <span style="color: var(--termynal-blue)">1.0.0</span>
Root: C:\Users\pytask-dev\git\my_project
Collected <span style="color: var(--termynal-blue)">1</span> task.

Collected tasks:
└── 🐍 &lt;Module task_module.py&gt;
    └── 📝 &lt;Function <span class="termynal-dim">task_module.py::</span>task_write_file&gt;
        ├── 📄 &lt;Dependency my_project/in.txt&gt;
        └── 📄 &lt;Product my_project/out.txt&gt;

──────────────────────────────────────────────────────────────────────────────

To restrict the set of tasks you are looking at, use markers, expressions and ignore patterns as usual.

Further reading#

  • The documentation on the command line interface of pytask collect can be found here.

  • Read here about selecting tasks.

  • Paths can be ignored with ignore.