From 303f67b05e23812c4ad817a06f341cbf7edfbfb3 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 18 Apr 2024 23:56:05 +0200 Subject: [PATCH 1/7] Fix. --- pyproject.toml | 87 +++++++++++++++++++++++++++++++++++++++----------- setup.cfg | 45 -------------------------- tox.ini | 8 ++--- 3 files changed, 73 insertions(+), 67 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index 922ea07..56ae471 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,62 @@ +[project] +name = "pytask_r" +description = "Run R scripts with pytask." +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: R", +] +requires-python = ">=3.8" +dependencies = ["click", "pluggy>=1.0.0", "pytask>=0.4.0"] +dynamic = ["version"] + +[[project.authors]] +name = "Tobias Raabe" +email = "raabe@posteo.de" + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.license] +text = "MIT" + +[project.urls] +Homepage = "https://github.com/pytask-dev/pytask-r" +Changelog = "https://github.com/pytask-dev/pytask-r/blob/main/CHANGES.md" +Documentation = "https://github.com/pytask-dev/pytask-r" +Github = "https://github.com/pytask-dev/pytask-r" +Tracker = "https://github.com/pytask-dev/pytask-r/issues" + +[project.entry-points.pytask] +pytask_r = "pytask_r.plugin" + +[tool.rye] +managed = true + [build-system] -requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[tool.hatch.build.hooks.vcs] +version-file = "src/pytask_r/_version.py" +[tool.hatch.build.targets.sdist] +exclude = ["tests"] +only-packages = true -[tool.setuptools_scm] -write_to = "src/pytask_r/_version.py" +[tool.hatch.build.targets.wheel] +exclude = ["tests"] +only-packages = true + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.metadata] +allow-direct-references = true [tool.mypy] @@ -42,18 +94,18 @@ extend-ignore = [ "D416", "D417", # Others. - "D404", # Do not start module docstring with "This". - "RET504", # unnecessary variable assignment before return. - "S101", # raise errors for asserts. - "B905", # strict parameter for zip that was implemented in py310. - "I", # ignore isort - "ANN101", # type annotating self - "ANN102", # type annotating cls - "FBT", # flake8-boolean-trap - "EM", # flake8-errmsg - "ANN401", # flake8-annotate typing.Any - "PD", # pandas-vet - "COM812", # trailing comma missing, but black takes care of that + "D404", # Do not start module docstring with "This". + "RET504", # unnecessary variable assignment before return. + "S101", # raise errors for asserts. + "B905", # strict parameter for zip that was implemented in py310. + "I", # ignore isort + "ANN101", # type annotating self + "ANN102", # type annotating cls + "FBT", # flake8-boolean-trap + "EM", # flake8-errmsg + "ANN401", # flake8-annotate typing.Any + "PD", # pandas-vet + "COM812", # trailing comma missing, but black takes care of that ] @@ -64,9 +116,8 @@ extend-ignore = [ [tool.ruff.pydocstyle] convention = "numpy" - [tool.pytest.ini_options] -# Do not add src since it messes with the loading of pytask-parallel as a plugin. +# Do not add src since it messes with the loading of pytask-r as a plugin. testpaths = ["tests"] markers = [ "wip: Tests that are work-in-progress.", diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d2ba86c..0000000 --- a/setup.cfg +++ /dev/null @@ -1,45 +0,0 @@ -[metadata] -name = pytask_r -description = Run R scripts with pytask. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/pytask-dev/pytask-r -author = Tobias Raabe -author_email = raabe@posteo.de -license = MIT -license_files = LICENSE -platforms = any -classifiers = - Development Status :: 4 - Beta - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: R -project_urls = - Changelog = https://github.com/pytask-dev/pytask-r/blob/main/CHANGES.md - Documentation = https://github.com/pytask-dev/pytask-r - Github = https://github.com/pytask-dev/pytask-r - Tracker = https://github.com/pytask-dev/pytask-r/issues - -[options] -packages = find: -install_requires = - click - pluggy>=1.0.0 - pytask>=0.4.0 -python_requires = >=3.8 -include_package_data = True -package_dir = =src -zip_safe = False - -[options.packages.find] -where = src - -[options.entry_points] -pytask = - pytask_r = pytask_r.plugin - -[check-manifest] -ignore = - src/pytask_r/_version.py diff --git a/tox.ini b/tox.ini index 1504f2f..f5716ba 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,14 @@ [tox] +requires = tox>=4 envlist = pytest [testenv] -usedevelop = true +package = editable -[testenv:pytest] +[testenv:test] +extras = test conda_channels = conda-forge - conda-forge/label/pytask_rc - conda-forge/label/pytask_parallel_rc nodefaults conda_deps = pytask >=0.4.0 From 0c52cd5409b07fabd01c31b83ad77a0157fbde74 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 19 Apr 2024 00:32:45 +0200 Subject: [PATCH 2/7] allow more checks. --- .pre-commit-config.yaml | 10 ---------- pyproject.toml | 9 ++------- src/pytask_r/execute.py | 8 ++++---- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fef43a0..9de1e23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,10 +17,6 @@ repos: - id: python-no-log-warn - id: python-use-type-annotations - id: text-unicode-replacement-char -- repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.5.0 - hooks: - - id: setup-cfg-fmt - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.3.7 hooks: @@ -55,12 +51,6 @@ repos: types-setuptools ] pass_filenames: false -- repo: https://github.com/mgedmin/check-manifest - rev: "0.49" - hooks: - - id: check-manifest - args: [--no-build-isolation] - additional_dependencies: [setuptools-scm, wheel, toml] - repo: meta hooks: - id: check-hooks-apply diff --git a/pyproject.toml b/pyproject.toml index 3bc35b9..778d805 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,21 +80,16 @@ unsafe-fixes = true [tool.ruff.lint] extend-ignore = [ - "S101", # raise errors for asserts. - "B905", # strict parameter for zip that was implemented in py310. "ANN101", # type annotating self "ANN102", # type annotating cls - "FBT", # flake8-boolean-trap - "EM", # flake8-errmsg - "ANN401", # flake8-annotate typing.Any - "PD", # pandas-vet + "ANN401", "COM812", # Comply with ruff-format "ISC001", # Comply with ruff-format ] select = ["ALL"] [tool.ruff.lint.per-file-ignores] -"tests/*" = ["D", "ANN"] +"tests/*" = ["D", "ANN", "S101"] [tool.ruff.lint.pydocstyle] convention = "numpy" diff --git a/src/pytask_r/execute.py b/src/pytask_r/execute.py index fabb9f9..dd80881 100644 --- a/src/pytask_r/execute.py +++ b/src/pytask_r/execute.py @@ -27,11 +27,11 @@ def pytask_execute_task_setup(task: PTask) -> None: ) raise RuntimeError(msg) - assert len(marks) == 1 + if len(marks) > 1: + msg = "Only one R marker is allowed per task." + raise ValueError(msg) - _, _, serializer, suffix = r(**marks[0].kwargs) - assert serializer - assert suffix + _, _, serializer, _ = r(**marks[0].kwargs) serialized_node: PythonNode = task.depends_on["_serialized"] # type: ignore[assignment] serialized_node.value.parent.mkdir(parents=True, exist_ok=True) # type: ignore[union-attr] From 26e971bf5d9b72e0d5f927fad1e1a111a358c37f Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 19 Apr 2024 00:38:51 +0200 Subject: [PATCH 3/7] try. --- .github/workflows/main.yml | 9 ++------- pyproject.toml | 11 +++++++---- tox.ini | 9 --------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa324dc..1ecc636 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ concurrency: cancel-in-progress: true env: - CONDA_EXE: mamba + CONDA_EXE: micromamba on: push: @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 @@ -40,14 +40,9 @@ jobs: - conda-forge create-args: >- python=${{ matrix.python-version }} - mamba tox-conda cache-environment: true - - name: Install core dependencies. - shell: bash -l {0} - run: mamba install -c conda-forge tox-conda coverage mamba - # Unit, integration, and end-to-end tests. - name: Run unit tests and doctests. diff --git a/pyproject.toml b/pyproject.toml index 778d805..4e6fd96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,9 @@ Tracker = "https://github.com/pytask-dev/pytask-r/issues" [project.entry-points.pytask] pytask_r = "pytask_r.plugin" +[project.optional-dependencies] +test = ["pytask-parallel", "pytest", "pytest-cov", "pytest-xdist", "pyyaml"] + [tool.rye] managed = true @@ -80,11 +83,11 @@ unsafe-fixes = true [tool.ruff.lint] extend-ignore = [ - "ANN101", # type annotating self - "ANN102", # type annotating cls + "ANN101", # type annotating self + "ANN102", # type annotating cls "ANN401", - "COM812", # Comply with ruff-format - "ISC001", # Comply with ruff-format + "COM812", # Comply with ruff-format + "ISC001", # Comply with ruff-format ] select = ["ALL"] diff --git a/tox.ini b/tox.ini index f5716ba..a8d7d98 100644 --- a/tox.ini +++ b/tox.ini @@ -11,17 +11,8 @@ conda_channels = conda-forge nodefaults conda_deps = - pytask >=0.4.0 - pytask-parallel >=0.4.0 - - # Optional dependencies. - pyyaml r-base >=4 r-jsonlite r-yaml - - pytest - pytest-cov - pytest-xdist commands = pytest {posargs} From cbc9b669b5c96512fb921462adf75275d5171baf Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 19 Apr 2024 00:45:46 +0200 Subject: [PATCH 4/7] Fix. --- CHANGES.md | 4 ++++ tox.ini | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 19cba35..592d045 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,10 @@ chronological order. Releases follow [semantic versioning](https://semver.org/) releases are available on [PyPI](https://pypi.org/project/pytask-r) and [Anaconda.org](https://anaconda.org/conda-forge/pytask-r). +## 0.4.1 - 2024-xx-xx + +- {pull}`46` modernizes the package. + ## 0.4.0 - 2023-10-08 - {pull}`42` makes the package compatible with pytask v0.4.0. diff --git a/tox.ini b/tox.ini index a8d7d98..3a75075 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,4 @@ [tox] -requires = tox>=4 envlist = pytest [testenv] From 37e2e27f1618299f5b4051a22b8ef89162994029 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 19 Apr 2024 00:51:53 +0200 Subject: [PATCH 5/7] fix. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 3a75075..9dad26c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] envlist = pytest +isolated_build = true [testenv] package = editable From f067f1c8fe400f9b90cc2d5d363cbd4f2d1a847b Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 19 Apr 2024 09:22:26 +0200 Subject: [PATCH 6/7] fix. --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 9dad26c..1721656 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,9 @@ [tox] envlist = pytest -isolated_build = true [testenv] -package = editable +# Cannot use package = editable, because tox-conda does not support tox v4. +usedevelop = true [testenv:test] extras = test From 9a07aef3f2e140cba61a5c67bcbac7769706f229 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 19 Apr 2024 09:31:47 +0200 Subject: [PATCH 7/7] fix. --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1ecc636..5221551 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ concurrency: cancel-in-progress: true env: - CONDA_EXE: micromamba + CONDA_EXE: mamba on: push: @@ -40,6 +40,7 @@ jobs: - conda-forge create-args: >- python=${{ matrix.python-version }} + mamba tox-conda cache-environment: true