diff --git a/docs/source/changes.md b/docs/source/changes.md index 6fd4a1de..2a8eba68 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -29,6 +29,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and - {pull}`409` make `.from_annot` an optional feature of nodes. - {pull}`410` allows to pass functions to `PythonNode(hash=...)`. - {pull}`412` adds protocols for tasks. +- {pull}`413` removes scripts to generate `.svg`s. ## 0.3.2 - 2023-06-07 diff --git a/scripts/svgs/README.md b/scripts/svgs/README.md deleted file mode 100644 index e1bcf302..00000000 --- a/scripts/svgs/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# SVGs - -This folder contains scripts to create svgs for the documentation and other publicly -available material. - -## Setup - -Before creating the SVGs, you need to adjust the version of pytask from a dirty version -to the desired one. - -Set `SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTASK` to the desired version. - -```console -# Command for Powershell -$ $env:SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTASK = "v0.2.0" - -# Command for Bash -$ export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTASK = "v0.2.0" -``` - -## Post-processing of SVGs - -- [ ] Remove flickering left-overs. -- [ ] Set Python version to 3.10.0. -- [ ] Set pluggy version to 1.0.0. -- [ ] Set root path to C:\\Users\\tobias\\git\\pytask-examples. - -## Store - -Store image in docs/source/\_static/images/. diff --git a/scripts/svgs/help_page.py b/scripts/svgs/help_page.py deleted file mode 100644 index cf362c98..00000000 --- a/scripts/svgs/help_page.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import annotations - -import pytask -from click.testing import CliRunner - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke(pytask.cli, ["--help"]) - pytask.console.save_svg("help_page.svg", title="pytask") diff --git a/scripts/svgs/markers.py b/scripts/svgs/markers.py deleted file mode 100644 index 87112b46..00000000 --- a/scripts/svgs/markers.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import annotations - -import pytask -from click.testing import CliRunner - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke(pytask.cli, ["markers"]) - pytask.console.save_svg("markers.svg", title="pytask") diff --git a/scripts/svgs/profile.py b/scripts/svgs/profile.py deleted file mode 100644 index 79a3496c..00000000 --- a/scripts/svgs/profile.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import annotations - -import pytask -from click.testing import CliRunner - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke(pytask.cli, ["profile"]) - pytask.console.save_svg("profile.svg", title="pytask") diff --git a/scripts/svgs/task_capture.py b/scripts/svgs/task_capture.py deleted file mode 100644 index 04d3b0bf..00000000 --- a/scripts/svgs/task_capture.py +++ /dev/null @@ -1,22 +0,0 @@ -# content of task_capture.py -from __future__ import annotations - -import pytask -from click.testing import CliRunner - - -def task_func1() -> None: - assert True - - -def task_func2() -> None: - print("Debug statement") # noqa: T201 - raise AssertionError - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke(pytask.cli, [__file__]) - pytask.console.save_svg("capture.svg", title="pytask") diff --git a/scripts/svgs/task_clean.py b/scripts/svgs/task_clean.py deleted file mode 100644 index 41f69357..00000000 --- a/scripts/svgs/task_clean.py +++ /dev/null @@ -1,34 +0,0 @@ -# Content of task_module.py -from __future__ import annotations - -import shutil -from pathlib import Path - -import pytask -from click.testing import CliRunner - - -def task_example() -> None: - pass - - -if __name__ == "__main__": - runner = CliRunner() - path = Path(__file__).parent - - path.joinpath("obsolete_file_1.md").touch() - - path.joinpath("obsolete_folder").mkdir() - path.joinpath("obsolete_folder", "obsolete_file_2.md").touch() - path.joinpath("obsolete_folder", "obsolete_file_3.md").touch() - - pytask.console.record = True - rs = runner.invoke(pytask.cli, ["clean", "-e", "__pycache__", path.as_posix()]) - pytask.console.save_svg("clean-dry-run.svg", title="pytask") - - pytask.console.record = True - runner.invoke(pytask.cli, ["clean", "-e", "__pycache__", "-d", path.as_posix()]) - pytask.console.save_svg("clean-dry-run-directories.svg", title="pytask") - - path.joinpath("obsolete_file_1.md").unlink() - shutil.rmtree(path / "obsolete_folder") diff --git a/scripts/svgs/task_collecting_tasks.py b/scripts/svgs/task_collecting_tasks.py deleted file mode 100644 index 70e35294..00000000 --- a/scripts/svgs/task_collecting_tasks.py +++ /dev/null @@ -1,28 +0,0 @@ -# Content of task_module.py -from __future__ import annotations - -from pathlib import Path - -import pytask -from click.testing import CliRunner - - -@pytask.mark.depends_on("in.txt") -@pytask.mark.produces("out.txt") -def task_write_file(depends_on: Path, produces: Path) -> None: - produces.write_text(depends_on.read_text()) - - -if __name__ == "__main__": - runner = CliRunner() - path = Path(__file__) - path.parent.joinpath("in.txt").touch() - - pytask.console.record = True - runner.invoke(pytask.cli, ["collect", path.as_posix()]) - pytask.console.save_svg("collect.svg", title="pytask") - - runner.invoke(pytask.cli, ["collect", "--nodes", path.as_posix()]) - pytask.console.save_svg("collect-nodes.svg", title="pytask") - - path.parent.joinpath("in.txt").unlink() diff --git a/scripts/svgs/task_dry_run.py b/scripts/svgs/task_dry_run.py deleted file mode 100644 index 1e9e3a60..00000000 --- a/scripts/svgs/task_dry_run.py +++ /dev/null @@ -1,16 +0,0 @@ -from __future__ import annotations - -from pathlib import Path - -import pytask - - -@pytask.mark.produces("out.txt") -def task_dry_run(produces: Path) -> None: - produces.write_text("This text file won't be produced in a dry-run.") - - -if __name__ == "__main__": - pytask.console.record = True - pytask.main({"paths": __file__, "dry_run": True}) - pytask.console.save_svg("dry-run.svg", title="pytask") diff --git a/scripts/svgs/task_hello.py b/scripts/svgs/task_hello.py deleted file mode 100644 index 7e35cb2c..00000000 --- a/scripts/svgs/task_hello.py +++ /dev/null @@ -1,16 +0,0 @@ -from __future__ import annotations - -from pathlib import Path - -import pytask - - -@pytask.mark.produces("hello_earth.txt") -def task_hello_earth(produces: Path) -> None: - produces.write_text("Hello, earth!") - - -if __name__ == "__main__": - pytask.console.record = True - pytask.main({"paths": __file__}) - pytask.console.save_svg("readme.svg", title="pytask") diff --git a/scripts/svgs/task_pdb.py b/scripts/svgs/task_pdb.py deleted file mode 100644 index ef92fa70..00000000 --- a/scripts/svgs/task_pdb.py +++ /dev/null @@ -1,37 +0,0 @@ -# Content of task_data_preparation.py. -from __future__ import annotations - -from pathlib import Path - -import numpy as np -import pandas as pd -import pytask -from click.testing import CliRunner - - -@pytask.mark.produces("data.pkl") -def task_create_random_data(produces: Path) -> None: - rng = np.random.default_rng(0) - beta = 2 - - x = rng.normal(loc=5, scale=10, size=5) - epsilon = rng.standard_normal(5) - - y = beta * x + epsilon - - df = pd.DataFrame({"x": x, "y": y}) - - raise Exception - - df.to_pickle(produces) - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke( - pytask.cli, - [__file__, "--pdb"], - input="pytask.console.save_svg('pdb.svg', title='pytask')", - ) diff --git a/scripts/svgs/task_persist_executed.py b/scripts/svgs/task_persist_executed.py deleted file mode 100644 index dbba8acb..00000000 --- a/scripts/svgs/task_persist_executed.py +++ /dev/null @@ -1,28 +0,0 @@ -# Content of task_module.py -from __future__ import annotations - -from pathlib import Path - -import pytask -from click.testing import CliRunner - - -@pytask.mark.persist -@pytask.mark.depends_on("input.md") -@pytask.mark.produces("output.md") -def task_make_input_bold(depends_on: Path, produces: Path) -> None: - produces.write_text("**" + depends_on.read_text() + "**") - - -if __name__ == "__main__": - runner = CliRunner() - path = Path(__file__) - - path.parent.joinpath("input.md").touch() - - pytask.console.record = True - runner.invoke(pytask.cli, [path.as_posix()]) - pytask.console.save_svg("persist-executed.svg", title="pytask") - - path.parent.joinpath("input.md").unlink() - path.parent.joinpath("output.md").unlink() diff --git a/scripts/svgs/task_persist_persisted.py b/scripts/svgs/task_persist_persisted.py deleted file mode 100644 index 967971e1..00000000 --- a/scripts/svgs/task_persist_persisted.py +++ /dev/null @@ -1,29 +0,0 @@ -# Content of task_module.py -from __future__ import annotations - -from pathlib import Path - -import pytask -from click.testing import CliRunner - - -@pytask.mark.persist -@pytask.mark.depends_on("input.md") -@pytask.mark.produces("output.md") -def task_make_input_bold(depends_on: Path, produces: Path) -> None: - produces.write_text("**" + depends_on.read_text() + "**") - - -if __name__ == "__main__": - runner = CliRunner() - path = Path(__file__) - - path.parent.joinpath("input.md").touch() - runner.invoke(pytask.cli, [path.as_posix()]) - - pytask.console.record = True - runner.invoke(pytask.cli, [path.as_posix(), "--verbose", 2]) - pytask.console.save_svg("persist-persisted.svg", title="pytask") - - path.parent.joinpath("input.md").unlink() - path.parent.joinpath("output.md").unlink() diff --git a/scripts/svgs/task_persist_skipped.py b/scripts/svgs/task_persist_skipped.py deleted file mode 100644 index b03eed40..00000000 --- a/scripts/svgs/task_persist_skipped.py +++ /dev/null @@ -1,30 +0,0 @@ -# Content of task_module.py -from __future__ import annotations - -from pathlib import Path - -import pytask -from click.testing import CliRunner - - -@pytask.mark.persist -@pytask.mark.depends_on("input.md") -@pytask.mark.produces("output.md") -def task_make_input_bold(depends_on: Path, produces: Path) -> None: - produces.write_text("**" + depends_on.read_text() + "**") - - -if __name__ == "__main__": - runner = CliRunner() - path = Path(__file__) - - path.parent.joinpath("input.md").touch() - runner.invoke(pytask.cli, [path.as_posix()]) - runner.invoke(pytask.cli, [path.as_posix()]) - - pytask.console.record = True - runner.invoke(pytask.cli, [path.as_posix(), "--verbose", 2]) - pytask.console.save_svg("persist-skipped.svg", title="pytask") - - path.parent.joinpath("input.md").unlink() - path.parent.joinpath("output.md").unlink() diff --git a/scripts/svgs/task_repeating.py b/scripts/svgs/task_repeating.py deleted file mode 100644 index b8b23045..00000000 --- a/scripts/svgs/task_repeating.py +++ /dev/null @@ -1,24 +0,0 @@ -from __future__ import annotations - -from pathlib import Path - -import pytask -from click.testing import CliRunner - - -for i in range(10): - - @pytask.mark.task - def task_create_random_data(produces: str = f"data_{i}.pkl", seed: int = i) -> None: - produces.write_text(seed) - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke(pytask.cli, [__file__]) - pytask.console.save_svg("repeating.svg", title="pytask") - - for i in range(10): - Path(__file__).parent.joinpath(f"data_{i}.pkl").unlink() diff --git a/scripts/svgs/task_show_locals.py b/scripts/svgs/task_show_locals.py deleted file mode 100644 index 4b7ad29e..00000000 --- a/scripts/svgs/task_show_locals.py +++ /dev/null @@ -1,34 +0,0 @@ -# Content of task_data_preparation.py. -from __future__ import annotations - -from pathlib import Path - -import numpy as np -import pandas as pd -import pytask -from click.testing import CliRunner - - -@pytask.mark.produces("data.pkl") -def task_create_random_data(produces: Path) -> None: - rng = np.random.default_rng(0) - beta = 2 - - x = rng.normal(loc=5, scale=10, size=5) - epsilon = rng.standard_normal(5) - - y = beta * x + epsilon - - df = pd.DataFrame({"x": x, "y": y}) - - raise Exception - - df.to_pickle(produces) - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke(pytask.cli, [__file__, "--show-locals"]) - pytask.console.save_svg("show-locals.svg", title="pytask") diff --git a/scripts/svgs/task_trace.py b/scripts/svgs/task_trace.py deleted file mode 100644 index bd8a3527..00000000 --- a/scripts/svgs/task_trace.py +++ /dev/null @@ -1,37 +0,0 @@ -# Content of task_data_preparation.py. -from __future__ import annotations - -from pathlib import Path - -import numpy as np -import pandas as pd -import pytask -from click.testing import CliRunner - - -@pytask.mark.produces("data.pkl") -def task_create_random_data(produces: Path) -> None: - rng = np.random.default_rng(0) - beta = 2 - - x = rng.normal(loc=5, scale=10, size=5) - epsilon = rng.standard_normal(5) - - y = beta * x + epsilon - - df = pd.DataFrame({"x": x, "y": y}) - - raise Exception - - df.to_pickle(produces) - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke( - pytask.cli, - [__file__, "--trace"], - input="pytask.console.save_svg('trace.svg', title='pytask')", - ) diff --git a/scripts/svgs/task_try_first.py b/scripts/svgs/task_try_first.py deleted file mode 100644 index 4f47935a..00000000 --- a/scripts/svgs/task_try_first.py +++ /dev/null @@ -1,21 +0,0 @@ -from __future__ import annotations - -import pytask -from click.testing import CliRunner - - -def task_first() -> None: - pytask.console.print("I'm second.") - - -@pytask.mark.try_first -def task_second() -> None: - pytask.console.print("I'm first.") - - -if __name__ == "__main__": - runner = CliRunner() - - pytask.console.record = True - runner.invoke(pytask.cli, [__file__, "--capture=no"]) - pytask.console.save_svg("try-first.svg", title="pytask") diff --git a/scripts/svgs/task_warning.py b/scripts/svgs/task_warning.py deleted file mode 100644 index f0924fa2..00000000 --- a/scripts/svgs/task_warning.py +++ /dev/null @@ -1,31 +0,0 @@ -from __future__ import annotations - -from pathlib import Path - -import pandas as pd -import pytask -from click.testing import CliRunner - - -def _create_df() -> pd.DataFrame: - df = pd.DataFrame({"a": range(10), "b": range(10, 20)}) - df[df["a"] < 5]["b"] = 1 # noqa: PLR2004 - return df - - -@pytask.mark.produces("df.pkl") -def task_warning(produces: Path) -> None: - df = _create_df() - df.to_pickle(produces) - - -if __name__ == "__main__": - runner = CliRunner() - - path = Path(__file__).parent - - pytask.console.record = True - runner.invoke(pytask.cli, [__file__]) - pytask.console.save_svg("warning.svg", title="pytask") - - path.joinpath("df.pkl").unlink() diff --git a/scripts/svgs/task_write_task.py b/scripts/svgs/task_write_task.py deleted file mode 100644 index ab60d224..00000000 --- a/scripts/svgs/task_write_task.py +++ /dev/null @@ -1,30 +0,0 @@ -# Content of task_data_preparation.py. -from __future__ import annotations - -from pathlib import Path - -import numpy as np -import pandas as pd -import pytask - - -@pytask.mark.produces("data.pkl") -def task_create_random_data(produces: Path) -> None: - rng = np.random.default_rng(0) - beta = 2 - - x = rng.normal(loc=5, scale=10, size=1_000) - epsilon = rng.standard_normal(1_000) - - y = beta * x + epsilon - - df = pd.DataFrame({"x": x, "y": y}) - df.to_pickle(produces) - - -if __name__ == "__main__": - pytask.console.record = True - pytask.main({"paths": __file__}) - pytask.console.save_svg("write-a-task.svg", title="pytask") - - Path(__file__).parent.joinpath("data.pkl").unlink()