From 499a76db63eee405f2791d4e60fcca533dd3f8fe Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 10 Mar 2022 13:07:40 +0100 Subject: [PATCH 1/3] Remove unnecessary hook. --- CHANGES.rst | 6 ++++++ src/pytask_r/collect.py | 19 ------------------- tests/test_collect.py | 19 ------------------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f49d290..fc937c2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,12 @@ all releases are available on `PyPI `_ and `Anaconda.org `_. +0.2.0 - 2022-xx-xx +------------------ + +- :gh:`24` removes an unnecessary hook implementation. + + 0.1.1 - 2022-02-08 ------------------ diff --git a/src/pytask_r/collect.py b/src/pytask_r/collect.py index c2f5474..fe0daaa 100644 --- a/src/pytask_r/collect.py +++ b/src/pytask_r/collect.py @@ -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 @@ -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 - `_. :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.""" diff --git a/tests/test_collect.py b/tests/test_collect.py index d5e1521..4f9a0fd 100644 --- a/tests/test_collect.py +++ b/tests/test_collect.py @@ -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 @@ -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", From 9b53704c158ac8dd64f1d6a5f6c23ab484c16113 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 10 Mar 2022 13:48:59 +0100 Subject: [PATCH 2/3] Rename pipeline. --- .github/workflows/continuous-integration-workflow.yml | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index c9ab6b5..6e6bff1 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -1,4 +1,4 @@ -name: Continuous Integration Workflow +name: main # Automatically cancel a previous run. concurrency: diff --git a/README.rst b/README.rst index fca181d..7719994 100644 --- a/README.rst +++ b/README.rst @@ -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 From be8eef42eed5b045b0a92cefde33b1d16f43ce17 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 10 Mar 2022 13:55:16 +0100 Subject: [PATCH 3/3] Rename yml and prolong parallel tests. --- .../{continuous-integration-workflow.yml => main.yml} | 0 tests/test_parallel.py | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{continuous-integration-workflow.yml => main.yml} (100%) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/main.yml similarity index 100% rename from .github/workflows/continuous-integration-workflow.yml rename to .github/workflows/main.yml diff --git a/tests/test_parallel.py b/tests/test_parallel.py index 9348b7c..8a04fb3 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -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)) @@ -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]