Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration Workflow
name: main

# Automatically cancel a previous run.
concurrency:
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ all releases are available on `PyPI <https://pypi.org/project/pytask-r>`_ and
`Anaconda.org <https://anaconda.org/conda-forge/pytask-r>`_.


0.2.0 - 2022-xx-xx
------------------

- :gh:`24` removes an unnecessary hook implementation.


0.1.1 - 2022-02-08
------------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:alt: PyPI - License
:target: https://pypi.org/project/pytask-r

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

.. image:: https://codecov.io/gh/pytask-dev/pytask-r/branch/main/graph/badge.svg
Expand Down
19 changes: 0 additions & 19 deletions src/pytask_r/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

from _pytask.config import hookimpl
from _pytask.mark_utils import get_specific_markers_from_task
from _pytask.mark_utils import has_marker
from _pytask.nodes import FilePathNode
from _pytask.nodes import PythonFunctionTask
from _pytask.parametrize import _copy_func


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


@hookimpl
def pytask_collect_task(session, path, name, obj):
"""Collect a task which is a function.

There is some discussion on how to detect functions in this `thread
<https://stackoverflow.com/q/624926/7523785>`_. :class:`types.FunctionType` does not
detect built-ins which is not possible anyway.

"""
if name.startswith("task_") and callable(obj) and has_marker(obj, "r"):
task = PythonFunctionTask.from_path_name_function_session(
path, name, obj, session
)

return task


@hookimpl
def pytask_collect_task_teardown(session, task):
"""Perform some checks."""
Expand Down
19 changes: 0 additions & 19 deletions tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from pytask_r.collect import _get_node_from_dictionary
from pytask_r.collect import _merge_all_markers
from pytask_r.collect import _prepare_cmd_options
from pytask_r.collect import pytask_collect_task
from pytask_r.collect import pytask_collect_task_teardown
from pytask_r.collect import r

Expand Down Expand Up @@ -57,24 +56,6 @@ def test_merge_all_markers(marks, expected):
assert out == expected


@pytest.mark.unit
@pytest.mark.parametrize(
"name, expected",
[("task_dummy", True), ("invalid_name", None)],
)
def test_pytask_collect_task(name, expected):
session = DummyClass()
path = Path("some_path")
task_dummy.pytaskmark = [Mark("r", (), {})]

task = pytask_collect_task(session, path, name, task_dummy)

if expected:
assert task
else:
assert not task


@pytest.mark.unit
@pytest.mark.parametrize(
"depends_on, produces, expectation",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def task_execute_r_script():
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))

r_script = """
Sys.sleep(2)
Sys.sleep(4)
saveRDS(1, file=paste0(1, ".rds"))
"""
tmp_path.joinpath("script_1.r").write_text(textwrap.dedent(r_script))

r_script = """
Sys.sleep(2)
Sys.sleep(4)
saveRDS(2, file=paste0(2, ".rds"))
"""
tmp_path.joinpath("script_2.r").write_text(textwrap.dedent(r_script))
Expand Down Expand Up @@ -98,7 +98,7 @@ def task_execute_r_script():
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))

r_script = """
Sys.sleep(2)
Sys.sleep(4)
args <- commandArgs(trailingOnly=TRUE)
number <- args[1]
produces <- args[2]
Expand Down