Skip to content

Commit

Permalink
chore: update template version to 0.1.11 (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau authored Mar 4, 2024
2 parents cd557ac + 6c0040e commit 9e5aa12
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Changes here will be overwritten by Copier
_commit: 0.1.5
_commit: 0.1.11
_src_path: gh:12rambau/pypackage
author_email: pierrick.rambaud49@gmai.com
author_first_name: Pierrick
author_last_name: Rambaud
author_orcid: 0000-0001-8764-5749
creation_year: "2024"
github_repo_name: pygadm
github_user: 12rambau
project_name: pyGADM
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"ghcr.io/devcontainers-contrib/features/nox:2": {},
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {}
},
"postCreateCommand": "pre-commit install"
"postCreateCommand": "python -m pip install commitizen && pre-commit install"
}
9 changes: 5 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ on:
types: [created]

jobs:
tests:
uses: ./.github/workflows/unit.yaml

deploy:
needs: [tests]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -21,6 +24,4 @@ jobs:
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
twine upload dist/*
run: python -m build && twine upload dist/*
25 changes: 15 additions & 10 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Unit tests

on:
workflow_call:
push:
branches:
- main
Expand Down Expand Up @@ -66,24 +67,28 @@ jobs:
- name: Install nox
run: pip install nox
- name: test with pytest
run: nox -s test
run: nox -s ci-test
- name: assess dead fixtures
if: ${{ matrix.python-version == '3.10' }}
shell: bash
run: nox -s dead-fixtures
- uses: actions/upload-artifact@v4
if: ${{ matrix.python-version == '3.10' }}
with:
name: coverage
path: coverage.xml

coverage:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/download-artifact@v4
with:
python-version: "3.10"
- name: Install deps
run: pip install nox
- name: test with pytest
run: nox -s test
- name: assess dead fixtures
run: nox -s dead-fixtures
name: coverage
path: coverage.xml
- name: codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,7 @@ dmypy.json
.vscode/

# image tmp file
*Zone.Identifier
*Zone.Identifier

# debugging notebooks
test.ipynb
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ and then request area of interest from their name or GADM Id:
Credits
-------

This package was created with `Copier <https://copier.readthedocs.io/en/latest/>`__ and the `@12rambau/pypackage <https://github.com/12rambau/pypackage>`__ 0.1.5 project template .
This package was created with `Copier <https://copier.readthedocs.io/en/latest/>`__ and the `@12rambau/pypackage <https://github.com/12rambau/pypackage>`__ 0.1.11 project template.
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# disable the treemap comment and report in PRs
comment: false
2 changes: 1 addition & 1 deletion docs/_template/pypackage-credit.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p class="pypackage-credit">
From
<a href="https://github.com/12rambau/pypackage">@12rambau/pypackage</a>
0.1.1 Copier project.
0.1.11 Copier project.
</p>
11 changes: 4 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@
import ee
import httplib2

from pygadm import __author__, __version__

package_path = os.path.abspath("../..")
os.environ["PYTHONPATH"] = ":".join((package_path, os.environ.get("PYTHONPATH", "")))


# -- Project information -------------------------------------------------------

project = "PyGADM"
copyright = f"2022-{datetime.now().year}, {__author__}"
author = __author__
release = __version__
project = "pyGADM"
author = "Pierrick Rambaud"
copyright = f"2024-{datetime.now().year}, {author}"
release = "0.5.2"

# -- General configuration -----------------------------------------------------

Expand Down
12 changes: 10 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ def lint(session):

@nox.session(reuse_venv=True)
def test(session):
"""Run all the test using the environment variable of the running machine."""
"""Run the selected tests and report coverage in html."""
session.install(".[test]")
test_files = session.posargs or ["tests"]
session.run("pytest", "--color=yes", "--cov", "--cov-report=xml", *test_files)
session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files)


@nox.session(reuse_venv=True, name="ci-test")
def ci_test(session):
"""Run all the test and report coverage in xml."""
session.install(".[test]")
session.posargs[0] if session.posargs else "default"
session.run("pytest", "--color=yes", "--cov", "--cov-report=xml")


@nox.session(reuse_venv=True, name="dead-fixtures")
Expand Down
12 changes: 3 additions & 9 deletions pygadm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ def __init__(

if not is_in.any().any():
# find the 5 closest names/id
columns = [
df[column.format(i)].dropna().str.lower().values for i in range(6)
]
columns = [df[column.format(i)].dropna().str.lower().values for i in range(6)]
ids = np.unique(np.concatenate(columns))
close_ids = get_close_matches(id.lower(), ids, n=5)
if is_name is True:
Expand All @@ -102,9 +100,7 @@ def __init__(

# load the max_level available in the requested area
sub_df = df[df[column.format(level)].str.fullmatch(id, case=False)]
max_level = next(
i for i in reversed(range(6)) if (sub_df[f"GID_{i}"] != "").any()
)
max_level = next(i for i in reversed(range(6)) if (sub_df[f"GID_{i}"] != "").any())

# get the request level from user
content_level, level = int(content_level), int(level)
Expand Down Expand Up @@ -185,9 +181,7 @@ def __init__(

super().__init__(gdf)

def _items(
self, name: str = "", admin: str = "", content_level: int = -1
) -> gpd.GeoDataFrame:
def _items(self, name: str = "", admin: str = "", content_level: int = -1) -> gpd.GeoDataFrame:
"""
Return the requested administrative boundaries from the single name or administrative code.
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ version_files = [
[tool.pytest.ini_options]
testpaths = "tests"

[tool.black]
line-length = 100

[tool.ruff]
ignore-init-module-imports = true
fix = true
Expand Down

0 comments on commit 9e5aa12

Please sign in to comment.