Skip to content

Remove unnecessary hook. #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2022
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-stata>`_ an
`Anaconda.org <https://anaconda.org/conda-forge/pytask-stata>`_.


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

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


0.1.2 - 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-stata

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

.. image:: https://codecov.io/gh/pytask-dev/pytask-stata/branch/main/graph/badge.svg
Expand Down
19 changes: 0 additions & 19 deletions src/pytask_stata/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
from pytask_stata.shared import convert_task_id_to_name_of_log_file
from pytask_stata.shared import get_node_from_dictionary
Expand All @@ -37,23 +35,6 @@ def run_stata_script(stata, cwd):
subprocess.run(stata, cwd=cwd, 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, "stata"):
task = PythonFunctionTask.from_path_name_function_session(
path, name, obj, session
)

return task


@hookimpl
def pytask_collect_task_teardown(session, task):
"""Perform some checks and prepare the task function."""
Expand Down
20 changes: 0 additions & 20 deletions tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from _pytask.nodes import FilePathNode
from pytask_stata.collect import _merge_all_markers
from pytask_stata.collect import _prepare_cmd_options
from pytask_stata.collect import pytask_collect_task
from pytask_stata.collect import pytask_collect_task_teardown
from pytask_stata.collect import stata
from pytask_stata.shared import get_node_from_dictionary
Expand Down Expand Up @@ -97,25 +96,6 @@ def test_prepare_cmd_options(args, stata_source_key, platform):
assert result == expected


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

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 @@ -37,14 +37,14 @@ def task_execute_do_file():
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))

do_file = """
sleep 2000
sleep 4000
sysuse auto, clear
save 1
"""
tmp_path.joinpath("script_1.do").write_text(textwrap.dedent(do_file))

do_file = """
sleep 2000
sleep 4000
sysuse auto, clear
save 2
"""
Expand Down Expand Up @@ -83,7 +83,7 @@ def task_execute_do_file():
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))

do_file = """
sleep 2000
sleep 4000
sysuse auto, clear
args produces
save "`produces'"
Expand Down