From 047997d9b19edbf35655d713ca4858824b557586 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Thu, 2 May 2024 15:45:53 +0200 Subject: [PATCH 1/4] update pyproject.toml to full poetry --- pyproject.toml | 138 ++++++++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 64 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cb8148a..2eaf0e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,77 +1,82 @@ -[build-system] -requires = ["setuptools>=64"] -build-backend = "setuptools.build_meta" +[tool.poetry] -[project] name = "pedon" -dynamic = ["version"] -authors = [{ name = "Martin Vonk", email = "vonk.mart@gmail.com" }] +version = "0.0.7" description = "Python package for (unsaturated) soil properties including pedotransfer functions" +authors = ["martinvonk "] +license = "MIT" readme = "README.md" -license = { file = "LICENSE" } -requires-python = ">=3.10" -dependencies = ["numpy", "matplotlib", "pandas", "scipy"] +homepage = "https://pypi.org/project/pedon/" +repository = "https://github.com/martinvonk/pedon" classifiers = [ - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Topic :: Scientific/Engineering :: Hydrology', - 'Intended Audience :: Science/Research', - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Topic :: Scientific/Engineering :: Hydrology', + 'Intended Audience :: Science/Research', + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +include = [ + { path = "pedon/datasets/soilsamples.csv", format = [ + "sdist", + "wheel", + ] }, ] -[project.urls] -homepage = "https://github.com/martinvonk/pedon" -repository = "https://github.com/martinvonk/pedon" +[tool.poetry.dependencies] +python = ">=3.10" +numpy = "*" +pandas = "*" +matplotlib = "*" +scipy = "*" -[project.optional-dependencies] -linting = ["flake8", "ruff"] -formatting = ["black[jupyter]", "isort"] -typing = ["mypy", "pandas-stubs"] -pytesting = ["pytest>=7", "pytest-cov", "pytest-sugar"] -coveraging = ["coverage"] -dev = ["pedon[linting,formatting,typing,pytesting]", "tox"] +[tool.poetry.group.dev.dependencies] +tox = "^4.15.0" +ipykernel = "^6.29.4" -[tool.poetry] -name = "pedonenv" -version = "0.0.0" -description = "Development Virtual Environment" -authors = ["poetry"] +[tool.poetry.group.linting] +optional = true -[tool.poetry.dependencies] -python = "^3.10" -numpy = "^1.3" -scipy = "^1.6" -pandas = "^2.0" -matplotlib = "^3.6" -openpyxl = "^3.0" -flake8 = "^6.1.0" -ruff = "^0.1.9" -black = { extras = ["jupyter"], version = "^23.12.1" } -isort = "^5.13.2" -mypy = "^1.8.0" -pandas-stubs = "^2.1.4.231218" -pytest = "^7.4.3" -pytest-cov = "^4.1.0" -pytest-sugar = "^0.9.7" -coverage = "^7.3.4" -tox = "^4.11.4" -setuptools = "^69.0.3" -ipykernel = "^6.28.0" - -[tool.setuptools] -include-package-data = true - -[tool.setuptools.dynamic] -version = { attr = "pedon._version.__version__" } - -[tool.setuptools.packages.find] -where = ["src"] - -[tool.setuptools.package-data] -"pedon.datasets" = ["*.csv"] +[tool.poetry.group.linting.dependencies] +flake8 = "*" +ruff = "*" + +[tool.poetry.group.formatting] +optional = true + +[tool.poetry.group.formatting.dependencies] +black = { extras = ["jupyter"], version = "*" } +isort = "*" + +[tool.poetry.group.typing] +optional = true + +[tool.poetry.group.typing.dependencies] +mypy = "*" +pandas-stubs = "*" + +[tool.poetry.group.pytesting] +optional = true + +[tool.poetry.group.pytesting.dependencies] +pytest = ">=7" +pytest-cov = "*" +pytest-sugar = "*" + +[tool.poetry.group.coveraging] +optional = true + +[tool.poetry.group.coveraging.dependencies] +coverage = "*" + +[tool.poetry-dynamic-versioning] +enable = true + +[tool.poetry-dynamic-versioning.from-file] +source = "src/pedon/_version.py" +pattern = '__version__ = "(\d(\.\d)+)"' [tool.black] line-length = 88 @@ -129,3 +134,8 @@ legacy_tox_ini = """ ruff check src """ + + +[build-system] +requires = ["poetry-core", "poetry-dynamic-versioning>=1.3.0"] +build-backend = "poetry.core.masonry.api" From 987d228f2863b774813be15e624e2599f554fa3c Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Mon, 13 May 2024 11:46:08 +0200 Subject: [PATCH 2/4] Update python-publish.yml --- .github/workflows/python-publish.yml | 36 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 9e20ee3..3596696 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,30 +1,42 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# https://github.com/pypa/gh-action-pypi-publish +# https://github.com/py-why/dowhy/blob/main/.github/workflows/python-publish.yml name: Upload Python Package on: release: types: [created] + workflow_dispatch: jobs: deploy: + name: Upload release to PyPI runs-on: ubuntu-latest - + permissions: + id-token: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.x" + + - name: Install Poetry + uses: abatilo/actions-poetry@v3.0.0 + + - name: Install Poetry Dynamic Versioning Plugin + run: pip install poetry-dynamic-versioning + - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install wheel twine build + run: poetry install + - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python3 -m build - python3 -m twine upload --repository pypi dist/* + poetry-dynamic-versioning + poetry build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From eb97fc51b3bf16a6b24f1e6110c824a6bb1ccf52 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Fri, 24 May 2024 16:27:23 +0200 Subject: [PATCH 3/4] add rosetta --- src/pedon/soil.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/pedon/soil.py b/src/pedon/soil.py index 4dbe45d..b12e12e 100644 --- a/src/pedon/soil.py +++ b/src/pedon/soil.py @@ -355,6 +355,29 @@ def cosby(self) -> Brooks: l=round(labda, 5), ) + def rosetta(self, rosetta_version: int = 3) -> Genuchten: + """Rosetta (Schaap et al., 2001) - Predicting soil water retention from soil""" + + soildata = [ + self.sand_p, + self.silt_p, + self.clay_p, + -9.9 if self.rho is None else self.rho, + -9.9 if self.th33 is None else self.th33, + -9.9 if self.th1500 is None else self.th1500, + ] + + data = {"soildata": [soildata]} + rjson = requests.post(f"http://www.handbook60.org/api/v1/rosetta/{rosetta_version}", json=data) + vgpar = rjson["van_genuchten_params"][0] + return Genuchten( + k_s=10**vgpar[4], + theta_r=vgpar[0], + theta_s=vgpar[1], + alpha=10**vgpar[2], + n=10**vgpar1[3], + ) + @dataclass class Soil: From baebd1a8bd1b86ab3b3e18747bd465c7f77fbccc Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Fri, 24 May 2024 16:30:22 +0200 Subject: [PATCH 4/4] add requests --- pyproject.toml | 1 + src/pedon/soil.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2eaf0e3..187978a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ numpy = "*" pandas = "*" matplotlib = "*" scipy = "*" +requests = "^2.32.2" [tool.poetry.group.dev.dependencies] tox = "^4.15.0" diff --git a/src/pedon/soil.py b/src/pedon/soil.py index b12e12e..ec4e373 100644 --- a/src/pedon/soil.py +++ b/src/pedon/soil.py @@ -368,14 +368,16 @@ def rosetta(self, rosetta_version: int = 3) -> Genuchten: ] data = {"soildata": [soildata]} - rjson = requests.post(f"http://www.handbook60.org/api/v1/rosetta/{rosetta_version}", json=data) + rjson = requests.post( + f"http://www.handbook60.org/api/v1/rosetta/{rosetta_version}", json=data + ) vgpar = rjson["van_genuchten_params"][0] return Genuchten( - k_s=10**vgpar[4], + k_s=10 ** vgpar[4], theta_r=vgpar[0], theta_s=vgpar[1], - alpha=10**vgpar[2], - n=10**vgpar1[3], + alpha=10 ** vgpar[2], + n=10 ** vgpar1[3], )