Skip to content

Commit e319203

Browse files
authored
Remove unnecessary hook. (#24)
1 parent 238e002 commit e319203

File tree

6 files changed

+11
-43
lines changed

6 files changed

+11
-43
lines changed

.github/workflows/continuous-integration-workflow.yml renamed to .github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Continuous Integration Workflow
1+
name: main
22

33
# Automatically cancel a previous run.
44
concurrency:

CHANGES.rst

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ all releases are available on `PyPI <https://pypi.org/project/pytask-r>`_ and
77
`Anaconda.org <https://anaconda.org/conda-forge/pytask-r>`_.
88

99

10+
0.2.0 - 2022-xx-xx
11+
------------------
12+
13+
- :gh:`24` removes an unnecessary hook implementation.
14+
15+
1016
0.1.1 - 2022-02-08
1117
------------------
1218

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
:alt: PyPI - License
1717
:target: https://pypi.org/project/pytask-r
1818

19-
.. image:: https://img.shields.io/github/workflow/status/pytask-dev/pytask-r/Continuous%20Integration%20Workflow/main
19+
.. image:: https://img.shields.io/github/workflow/status/pytask-dev/pytask-r/main/main
2020
:target: https://github.com/pytask-dev/pytask-r/actions?query=branch%3Amain
2121

2222
.. image:: https://codecov.io/gh/pytask-dev/pytask-r/branch/main/graph/badge.svg

src/pytask_r/collect.py

-19
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
from _pytask.config import hookimpl
1111
from _pytask.mark_utils import get_specific_markers_from_task
12-
from _pytask.mark_utils import has_marker
1312
from _pytask.nodes import FilePathNode
14-
from _pytask.nodes import PythonFunctionTask
1513
from _pytask.parametrize import _copy_func
1614

1715

@@ -35,23 +33,6 @@ def run_r_script(r):
3533
subprocess.run(r, check=True)
3634

3735

38-
@hookimpl
39-
def pytask_collect_task(session, path, name, obj):
40-
"""Collect a task which is a function.
41-
42-
There is some discussion on how to detect functions in this `thread
43-
<https://stackoverflow.com/q/624926/7523785>`_. :class:`types.FunctionType` does not
44-
detect built-ins which is not possible anyway.
45-
46-
"""
47-
if name.startswith("task_") and callable(obj) and has_marker(obj, "r"):
48-
task = PythonFunctionTask.from_path_name_function_session(
49-
path, name, obj, session
50-
)
51-
52-
return task
53-
54-
5536
@hookimpl
5637
def pytask_collect_task_teardown(session, task):
5738
"""Perform some checks."""

tests/test_collect.py

-19
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pytask_r.collect import _get_node_from_dictionary
1010
from pytask_r.collect import _merge_all_markers
1111
from pytask_r.collect import _prepare_cmd_options
12-
from pytask_r.collect import pytask_collect_task
1312
from pytask_r.collect import pytask_collect_task_teardown
1413
from pytask_r.collect import r
1514

@@ -57,24 +56,6 @@ def test_merge_all_markers(marks, expected):
5756
assert out == expected
5857

5958

60-
@pytest.mark.unit
61-
@pytest.mark.parametrize(
62-
"name, expected",
63-
[("task_dummy", True), ("invalid_name", None)],
64-
)
65-
def test_pytask_collect_task(name, expected):
66-
session = DummyClass()
67-
path = Path("some_path")
68-
task_dummy.pytaskmark = [Mark("r", (), {})]
69-
70-
task = pytask_collect_task(session, path, name, task_dummy)
71-
72-
if expected:
73-
assert task
74-
else:
75-
assert not task
76-
77-
7859
@pytest.mark.unit
7960
@pytest.mark.parametrize(
8061
"depends_on, produces, expectation",

tests/test_parallel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def task_execute_r_script():
4545
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
4646

4747
r_script = """
48-
Sys.sleep(2)
48+
Sys.sleep(4)
4949
saveRDS(1, file=paste0(1, ".rds"))
5050
"""
5151
tmp_path.joinpath("script_1.r").write_text(textwrap.dedent(r_script))
5252

5353
r_script = """
54-
Sys.sleep(2)
54+
Sys.sleep(4)
5555
saveRDS(2, file=paste0(2, ".rds"))
5656
"""
5757
tmp_path.joinpath("script_2.r").write_text(textwrap.dedent(r_script))
@@ -98,7 +98,7 @@ def task_execute_r_script():
9898
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
9999

100100
r_script = """
101-
Sys.sleep(2)
101+
Sys.sleep(4)
102102
args <- commandArgs(trailingOnly=TRUE)
103103
number <- args[1]
104104
produces <- args[2]

0 commit comments

Comments
 (0)