Skip to content

Commit 18a7ff5

Browse files
authored
Release 0.0.5 and better tasks ids and selection of tasks. (#15)
1 parent 5de64e3 commit 18a7ff5

31 files changed

+226
-120
lines changed

.conda/meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build:
1313
noarch: python
1414
number: 0
1515
entry_points:
16-
- pytask = pytask.cli:pytask
16+
- pytask = _pytask.cli:pytask
1717

1818
requirements:
1919
host:

docs/api.rst

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
API Reference
2+
=============
3+
4+
This page contains auto-generated API reference documentation [#f1]_.
5+
6+
.. toctree::
7+
:titlesonly:
8+
9+
/autoapi/pytask/index
10+
/autoapi/_pytask/index
11+
12+
.. [#f1] Created with `sphinx-autoapi <https://github.com/readthedocs/sphinx-autoapi>`_

docs/changes.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ chronological order. Releases follow `semantic versioning <https://semver.org/>`
66
all releases are available on `Anaconda.org <https://anaconda.org/pytask/pytask>`_.
77

88

9-
0.0.5 - 2020-xx-xx
9+
0.0.5 - 2020-08-12
1010
------------------
1111

1212
- :gh:`10` turns parametrization into a plugin.
1313
- :gh:`11` extends the documentation.
1414
- :gh:`12` replaces ``pytest.mark`` with ``pytask.mark``.
1515
- :gh:`13` implements selecting tasks via expressions or marker expressions.
16+
- :gh:`14` separates the namespace of pytask to ``pytask`` and ``_pytask``.
17+
- :gh:`15` implements better tasks ids which allow and releases 0.0.5.
1618

1719

1820
0.0.4 - 2020-07-22

docs/conf.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
author = "Tobias Raabe"
2020

2121
# The full version, including alpha/beta/rc tags
22-
release = "0.0.4"
22+
release = "0.0.5"
2323

2424

2525
# -- General configuration -------------------------------------------------------------
@@ -51,6 +51,8 @@
5151
# html_extra_path.
5252
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
5353

54+
suppress_warnings = ["ref.python"]
55+
5456
# -- Extensions configuration ----------------------------------------------------------
5557

5658
# Configuration for autodoc
@@ -74,8 +76,9 @@
7476

7577
# Configuration for autoapi
7678
autoapi_type = "python"
77-
autoapi_dirs = ["../src/pytask"]
79+
autoapi_dirs = ["../src"]
7880
autoapi_keep_files = False
81+
autoapi_add_toctree_entry = False
7982

8083

8184
# -- Options for HTML output -----------------------------------------------------------

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,4 @@ The documentation has currently one of four planned parts.
119119

120120
glossary
121121
changes
122+
api

docs/reference_guides/hookspecs.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Hook Specifications
22
===================
33

4-
.. currentmodule:: pytask.hookspecs
4+
.. currentmodule:: _pytask.hookspecs
55

66
Hook specifications are the :term:`entry-points <entry-point>` provided by pytask to
77
change the behavior of the program.

docs/reference_guides/marks.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ in the host or in plugins. The following marks are available by default.
88
pytask.mark.depends_on
99
----------------------
1010

11-
.. autofunction:: pytask.nodes.depends_on
11+
.. autofunction:: _pytask.nodes.depends_on
1212
:noindex:
1313

1414

1515
pytask.mark.produces
1616
--------------------
1717

18-
.. autofunction:: pytask.nodes.produces
18+
.. autofunction:: _pytask.nodes.produces
1919
:noindex:
2020

2121

2222
pytask.mark.parametrize
2323
-----------------------
2424

25-
.. autofunction:: pytask.parametrize.parametrize
25+
.. autofunction:: _pytask.parametrize.parametrize
2626
:noindex:

docs/tutorials/how_to_configure_pytask.rst

+26
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,29 @@ configuration file.
4747
4848
markers =
4949
wip: Work-in-progress. These are tasks which I am currently working on.
50+
51+
52+
ignore
53+
------
54+
55+
pytask can ignore files and directories and exclude some tasks or reduce the duration of
56+
the collection.
57+
58+
To ignore some file/folder via the command line, use the ``--ignore`` flag multiple
59+
times.
60+
61+
.. code-block:: bash
62+
63+
$ pytask --ignore */some_file.py --ignore */some_directory/*
64+
65+
Or, use the configuration file:
66+
67+
.. code-block:: ini
68+
69+
# For single entries only.
70+
ignore = */some_file.py
71+
72+
# Or single and multiple entries.
73+
ignore =
74+
*/some_directory/*
75+
*/some_file.py

docs/tutorials/how_to_select_tasks.rst

+6
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ will execute the first and third task and
7979
$ pytask -k "1 and not 2"
8080
8181
executes only the first task.
82+
83+
To execute a single task, say ``task_run_this_one``, in ``task_example.py``, use
84+
85+
.. code-block:: bash
86+
87+
$ pytask -k task_example.py::task_run_this_one

setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[bumpversion]
2-
current_version = 0.0.4
2+
current_version = 0.0.5
33
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))(\-?((dev)?(?P<dev>\d+))?)
4-
serialize =
4+
serialize =
55
{major}.{minor}.{patch}dev{dev}
66
{major}.{minor}.{patch}
77

setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515

1616
setup(
1717
name="pytask",
18-
version="0.0.4",
18+
version="0.0.5",
1919
description=DESCRIPTION,
2020
long_description=DESCRIPTION + "\n\n" + README,
2121
long_description_content_type="text/x-rst",
2222
author="Tobias Raabe",
2323
author_email="[email protected]",
24-
python_requires=">=3.6.0",
24+
python_requires=">=3.6",
2525
url=PROJECT_URLS["Documentation"],
2626
project_urls=PROJECT_URLS,
2727
license="None",
28-
keywords=["Economics", " Discrete Choice Dynamic Programming Model"],
28+
keywords=["Build System"],
2929
classifiers=[
3030
"Development Status :: 2 - Pre-Alpha",
3131
"Framework :: pytask",
@@ -36,7 +36,7 @@
3636
"Programming Language :: Python :: 3.8",
3737
],
3838
platforms="any",
39-
entry_points={"console_scripts": ["pytask=pytask:pytask"]},
39+
entry_points={"console_scripts": ["pytask=_pytask.cli:pytask"]},
4040
packages=find_packages(where="src"),
4141
package_dir={"": "src"},
4242
)

src/_pytask/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.4"
1+
__version__ = "0.0.5"

src/_pytask/cli.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
1010

1111

12-
def add_parameters(func):
12+
def add_parameters(command):
1313
"""Add parameters from plugins to the commandline interface."""
1414
pm = _prepare_plugin_manager()
15-
pm.hook.pytask_add_parameters_to_cli(command=func)
15+
pm.hook.pytask_add_parameters_to_cli(command=command)
1616
# Hack to pass the plugin manager via a hidden option to the ``config_from_cli``.
17-
func.params.append(click.Option(["--pm"], default=pm, hidden=True))
17+
command.params.append(click.Option(["--pm"], default=pm, hidden=True))
1818

19-
return func
19+
return command
2020

2121

2222
def _prepare_plugin_manager():

src/_pytask/collect.py

+2-20
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
import glob
33
import importlib
44
import inspect
5-
import pprint
65
import sys
76
import traceback
87
from pathlib import Path
98

109
import click
1110
from _pytask.config import hookimpl
1211
from _pytask.exceptions import CollectionError
13-
from _pytask.exceptions import TaskDuplicatedError
1412
from _pytask.mark import has_marker
1513
from _pytask.nodes import FilePathNode
1614
from _pytask.nodes import PythonFunctionTask
@@ -132,22 +130,6 @@ def pytask_collect_task_protocol(session, reports, path, name, obj):
132130
return CollectionReportTask.from_exception(path, name, exc_info)
133131

134132

135-
@hookimpl(trylast=True)
136-
def pytask_collect_task_setup(session, reports, path, name):
137-
paths_to_tasks_w_ident_name = [
138-
i.path.as_posix()
139-
for i in reports
140-
if not isinstance(i, CollectionReportFile) and i.name == name
141-
]
142-
if paths_to_tasks_w_ident_name:
143-
formatted = pprint.pformat(
144-
paths_to_tasks_w_ident_name, width=session.config["terminal_width"]
145-
)
146-
raise TaskDuplicatedError(
147-
f"Task '{name}' in '{path}' has the same name as task(s):\n {formatted}"
148-
)
149-
150-
151133
@hookimpl(trylast=True)
152134
def pytask_collect_task(session, path, name, obj):
153135
"""Collect a task which is a function.
@@ -187,7 +169,7 @@ def pytask_collect_node(path, node):
187169
node = Path(node)
188170
if isinstance(node, Path):
189171
if not node.is_absolute():
190-
node = path.parent.joinpath(node).resolve()
172+
node = path.parent.joinpath(node)
191173
return FilePathNode.from_path(node)
192174

193175

@@ -202,7 +184,7 @@ def valid_paths(paths, session):
202184
----------
203185
paths : List[pathlib.Path]
204186
List of paths from which tasks are collected.
205-
session : pytask.main.Session
187+
session : _pytask.session.Session
206188
The session.
207189
208190
"""

src/_pytask/config.py

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import click
1010
import pluggy
1111
from _pytask.shared import get_first_not_none_value
12+
from _pytask.shared import parse_value_or_multiline_option
1213
from _pytask.shared import to_list
1314

1415

@@ -54,6 +55,9 @@ def pytask_configure(pm, config_from_cli):
5455

5556
@hookimpl
5657
def pytask_parse_config(config, config_from_cli, config_from_file):
58+
config_from_file["ignore"] = parse_value_or_multiline_option(
59+
config_from_file.get("ignore")
60+
)
5761
config["ignore"] = (
5862
get_first_not_none_value(
5963
config_from_cli,

src/_pytask/enums.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@
44
class ExitCode(enum.IntEnum):
55
"""Exit codes for pytask."""
66

7-
# Tasks were executed successfully.
87
OK = 0
8+
"""Tasks were executed successfully."""
99

10-
# Failed while executing tasks.
1110
FAILED = 1
11+
"""Failed while executing tasks."""
1212

13-
# Failed while collecting tasks.
1413
COLLECTION_FAILED = 2
14+
"""Failed while collecting tasks."""
1515

16-
# Failed while resolving dependencies.
1716
RESOLVING_DEPENDENCIES_FAILED = 3
17+
"""Failed while resolving dependencies."""
18+
19+
20+
class ColorCode(enum.Enum):
21+
"""Color codes for pytask."""
22+
23+
SUCCESS = "green"
24+
25+
FAILED = "red"
26+
27+
SKIPPED = "yellow"

src/_pytask/exceptions.py

-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,3 @@ class ResolvingDependenciesError(PytaskError):
2020

2121
class ExecutionError(PytaskError):
2222
"""Exception during execution."""
23-
24-
25-
class TaskDuplicatedError(PytaskError):
26-
"""Exception for duplicated task during collection."""

src/_pytask/execute.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from _pytask.dag import node_and_neigbors
1010
from _pytask.dag import sort_tasks_topologically
1111
from _pytask.database import create_or_update_state
12+
from _pytask.enums import ColorCode
1213
from _pytask.exceptions import ExecutionError
1314
from _pytask.exceptions import NodeNotFoundError
1415
from _pytask.mark import Mark
@@ -131,9 +132,9 @@ def pytask_execute_task_process_report(session, report):
131132
@hookimpl(trylast=True)
132133
def pytask_execute_task_log_end(report):
133134
if report.success:
134-
click.secho(".", fg="green", nl=False)
135+
click.secho(".", fg=ColorCode.SUCCESS.value, nl=False)
135136
else:
136-
click.secho("F", fg="red", nl=False)
137+
click.secho("F", fg=ColorCode.FAILED.value, nl=False)
137138

138139
return True
139140

src/_pytask/mark/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def from_task(cls, task) -> "KeywordMatcher":
141141
mapped_names = {task.name}
142142

143143
# Add the names attached to the current function through direct assignment.
144-
function_obj = getattr(task, "function", None)
144+
function_obj = task.function
145145
if function_obj:
146146
mapped_names.update(function_obj.__dict__)
147147

0 commit comments

Comments
 (0)