Skip to content

Commit ef42e6e

Browse files
committed
Fix.
1 parent ebabd84 commit ef42e6e

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

src/_pytask/delayed.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
"""Contains hook implementations for provisional nodes and task generators."""
2+
23
from __future__ import annotations
34

45
import inspect
56
import sys
7+
from typing import TYPE_CHECKING
68
from typing import Any
79
from typing import Callable
810
from typing import Mapping
9-
from typing import TYPE_CHECKING
11+
12+
from pytask import TaskOutcome
1013

1114
from _pytask.config import hookimpl
15+
from _pytask.delayed_utils import TASKS_WITH_PROVISIONAL_NODES
1216
from _pytask.delayed_utils import collect_provisional_nodes
1317
from _pytask.delayed_utils import recreate_dag
14-
from _pytask.delayed_utils import TASKS_WITH_PROVISIONAL_NODES
1518
from _pytask.exceptions import NodeLoadError
1619
from _pytask.node_protocols import PNode
1720
from _pytask.node_protocols import PProvisionalNode
@@ -24,7 +27,6 @@
2427
from _pytask.tree_util import tree_map
2528
from _pytask.tree_util import tree_map_with_path
2629
from _pytask.typing import is_task_generator
27-
from pytask import TaskOutcome
2830

2931
if TYPE_CHECKING:
3032
from _pytask.session import Session

src/_pytask/delayed_utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
import sys
44
from pathlib import Path
5-
from typing import Any
65
from typing import TYPE_CHECKING
6+
from typing import Any
77

88
from _pytask.collect_utils import collect_dependency
9+
from _pytask.dag import _check_if_dag_has_cycles
10+
from _pytask.dag import _check_if_tasks_have_the_same_products
11+
from _pytask.dag import _create_dag
12+
from _pytask.dag import _modify_dag
913
from _pytask.dag_utils import TopologicalSorter
14+
from _pytask.mark import select_tasks_by_marks_and_expressions
1015
from _pytask.models import NodeInfo
1116
from _pytask.node_protocols import PNode
1217
from _pytask.node_protocols import PProvisionalNode
@@ -69,10 +74,12 @@ def collect_provisional_nodes(
6974
def recreate_dag(session: Session, task: PTask) -> None:
7075
"""Recreate the DAG."""
7176
try:
72-
session.dag = session.hook.pytask_dag_create_dag(
73-
session=session, tasks=session.tasks
74-
)
75-
session.hook.pytask_dag_modify_dag(session=session, dag=session.dag)
77+
dag = _create_dag(tasks=session.tasks)
78+
_check_if_dag_has_cycles(dag)
79+
_check_if_tasks_have_the_same_products(dag, session.config["paths"])
80+
_modify_dag(session=session, dag=dag)
81+
select_tasks_by_marks_and_expressions(session=session, dag=dag)
82+
session.dag = dag
7683
session.scheduler = TopologicalSorter.from_dag_and_sorter(
7784
session.dag, session.scheduler
7885
)

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _remove_variable_info_from_output(data: str, path: Any) -> str: # noqa: ARG
2929

3030
# Remove dynamic versions.
3131
index_root = next(i for i, line in enumerate(lines) if line.startswith("Root:"))
32-
new_info_line = "".join(lines[1:index_root])
32+
new_info_line = " ".join(lines[1:index_root])
3333
for platform in ("linux", "win32", "darwin"):
3434
new_info_line = new_info_line.replace(platform, "<platform>")
3535
pattern = re.compile(version.VERSION_PATTERN, flags=re.IGNORECASE | re.VERBOSE)

tests/test_jupyter/test_task_generator.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"cell_type": "code",
55
"execution_count": null,
6-
"id": "12bc75b1",
6+
"id": "0",
77
"metadata": {},
88
"outputs": [],
99
"source": [
@@ -20,7 +20,7 @@
2020
{
2121
"cell_type": "code",
2222
"execution_count": null,
23-
"id": "29ac7311",
23+
"id": "1",
2424
"metadata": {},
2525
"outputs": [],
2626
"source": [
@@ -46,7 +46,7 @@
4646
{
4747
"cell_type": "code",
4848
"execution_count": null,
49-
"id": "738c9418",
49+
"id": "2",
5050
"metadata": {},
5151
"outputs": [],
5252
"source": [

tests/test_task_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from typing import NamedTuple
77

88
import pytest
9+
from _pytask.task_utils import COLLECTED_TASKS
910
from _pytask.task_utils import _arg_value_to_id_component
1011
from _pytask.task_utils import _parse_name
1112
from _pytask.task_utils import _parse_task_kwargs
12-
from _pytask.task_utils import COLLECTED_TASKS
1313
from attrs import define
1414
from pytask import Mark
1515
from pytask import task
@@ -67,8 +67,7 @@ def test_parse_task_kwargs(kwargs, expectation, expected):
6767
@pytest.mark.integration()
6868
def test_default_values_of_pytask_meta():
6969
@task()
70-
def task_example():
71-
...
70+
def task_example(): ...
7271

7372
assert task_example.pytask_meta.after == []
7473
assert not task_example.pytask_meta.is_generator

0 commit comments

Comments
 (0)