Skip to content

Commit

Permalink
Merge pull request #3 from ihmeuw/chore/auto-update-project-from-temp…
Browse files Browse the repository at this point in the history
…late

[Actions] Auto-Update cookiecutter template
  • Loading branch information
collijk authored Feb 26, 2025
2 parents bb13fb1 + 743d891 commit d8bcc1b
Show file tree
Hide file tree
Showing 9 changed files with 807 additions and 759 deletions.
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/collijk/python-package-cookiecutter",
"commit": "cd59edc69d51f9485bca69eb940e0706bc65e9ba",
"commit": "6a159105838fc80cba178d2fbcc6185fd3ef8df2",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -12,7 +12,7 @@
"package_name": "rra_building_density",
"project_short_description": "Extraction and processing pipelines for a variety of building density products.",
"_template": "https://github.com/collijk/python-package-cookiecutter",
"_commit": "cd59edc69d51f9485bca69eb940e0706bc65e9ba"
"_commit": "6a159105838fc80cba178d2fbcc6185fd3ef8df2"
}
},
"directory": null
Expand Down
1,406 changes: 734 additions & 672 deletions poetry.lock

Large diffs are not rendered by default.

100 changes: 46 additions & 54 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,80 +1,78 @@
[tool.poetry]
[project]
name = "rra-building-density"
version = "0.0.1"
description = "Extraction and processing pipelines for a variety of building density products."
authors = [
"James Collins <[email protected]>",
{name = "James Collins", email = "[email protected]"},
]
license = "BSD-3-Clause"
readme = "README.md"

documentation = "https://collijk.github.io/rra-building-density"
homepage = "https://collijk.github.io/rra-building-density"
repository = "https://github.com/collijk/rra-building-density"

classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
requires-python = ">=3.12"
dependencies = [
"click>=8.1.8",
"requests>=2.32.3",
"tqdm>=4.67.1",
"rra-tools>=1.0.25",
"geopandas>=1.0.1",
"shapely>=2.0.6",
"contextily>=1.6.2",
"matplotlib>=3.10.0",
"rasterio>=1.4.3",
"scipy>=1.14.1",
"seaborn>=0.13.2",
"rasterra>=0.6.2",
"pydantic>=2.10.4",
"pyarrow>=18.1.0",
]

[project.urls]
homepage = "https://ihmeuw.github.io/rra-building-density"
repository = "https://github.com/ihmeuw/rra-building-density"
documentation = "https://ihmeuw.github.io/rra-building-density"

[project.scripts]
bdrun = "rra_building_density.cli:bdrun"
bdtask = "rra_building_density.cli:bdtask"

[tool.poetry]
packages = [
{ include = "rra_building_density", from = "src" }
]
requires-poetry = ">=2.0"

[tool.poetry.dependencies]
python = ">=3.10, <3.13"
click = "^8.1.8"
requests = "^2.32.3"
tqdm = "^4.67.1"
rra-tools = "^1.0.23"
geopandas = "^1.0.1"
shapely = "^2.0.6"
contextily = "^1.6.2"
matplotlib = "^3.10.0"
rasterio = "^1.4.3"
scipy = "^1.14.1"
seaborn = "^0.13.2"
rasterra = "^0.6.1"
pydantic = "^2.10.4"
pyarrow = "^18.1.0"
python = ">=3.12, <4.0"

# We keep the dev dependencies here instead of in the project optional dependencies
# so they're still installed by default with `poetry install`.
# They won't be installed or shipped with the package.
[tool.poetry.group.dev.dependencies]
mkdocstrings = {version = "*", extras = ["python"]}
mkdocs-material = "*"
# Things we want to put a lower bound on
mypy = "^1.15.0"
mkdocs-material = "^9.6.0"
pre-commit = "^4.0.0"
pytest = "^8.3.0"
ruff = "^0.9.7"
# Things we don't care about the version
mkdocstrings = {extras = ["python"], version = "*"}
mkdocs-table-reader-plugin = "*"
mkdocs-gen-files = "*"
mkdocs-literate-nav = "*"
mkdocs-section-index = "*"
mypy = "*"
pre-commit = "*"
pymdown-extensions = "*"
pytest = "*"
pytest-github-actions-annotate-failures = "*"
pytest-cov = "*"
python-kacl = "*"
ruff = "*"
types-pyyaml = "^6.0.12.20241230"
types-requests = "^2.32.0.20241016"
types-tqdm = "^4.67.0.20241221"
types-pyyaml = "*"
types-requests = "*"
types-tqdm = "*"

[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core>=2.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
bdrun = "rra_building_density.cli:bdrun"
bdtask = "rra_building_density.cli:bdtask"

[tool.ruff]
target-version = "py310" # The lowest supported version
target-version = "py312" # The lowest supported version

[tool.ruff.lint]
# By default, enable all the lint rules.
Expand Down Expand Up @@ -153,9 +151,3 @@ module = [
"shapely.*",
]
ignore_missing_imports = true

# [[tool.mypy.overrides]]
# module = [
# "tests/my_thing/test_my_thing",
# ]
# disallow_untyped_defs = false
34 changes: 14 additions & 20 deletions src/rra_building_density/cli_options.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from collections.abc import Collection
from typing import ParamSpec, TypeVar
from collections.abc import Callable, Collection

import click
from rra_tools.cli_tools import (
RUN_ALL,
ClickOption,
convert_choice,
with_choice,
with_debugger,
Expand All @@ -18,15 +16,12 @@
with_verbose,
)

_T = TypeVar("_T")
_P = ParamSpec("_P")


def with_crs(
def with_crs[**P, T](
choices: Collection[str],
*,
allow_all: bool = False,
) -> ClickOption[_P, _T]:
) -> Callable[[Callable[P, T]], Callable[P, T]]:
return with_choice(
"crs",
allow_all=allow_all,
Expand All @@ -37,11 +32,11 @@ def with_crs(
)


def with_measure(
def with_measure[**P, T](
choices: Collection[str],
*,
allow_all: bool = False,
) -> ClickOption[_P, _T]:
) -> Callable[[Callable[P, T]], Callable[P, T]]:
return with_choice(
"measure",
"m",
Expand All @@ -52,11 +47,11 @@ def with_measure(
)


def with_time_point(
def with_time_point[**P, T](
choices: Collection[str] | None = None,
*,
allow_all: bool = False,
) -> ClickOption[_P, _T]:
) -> Callable[[Callable[P, T]], Callable[P, T]]:
return with_choice(
"time_point",
"t",
Expand All @@ -67,11 +62,11 @@ def with_time_point(
)


def with_version(
def with_version[**P, T](
choices: Collection[str],
*,
allow_all: bool = False,
) -> ClickOption[_P, _T]:
) -> Callable[[Callable[P, T]], Callable[P, T]]:
return with_choice(
"version",
allow_all=allow_all,
Expand All @@ -81,7 +76,7 @@ def with_version(
)


def with_tile_size() -> ClickOption[_P, _T]:
def with_tile_size[**P, T]() -> Callable[[Callable[P, T]], Callable[P, T]]:
return click.option(
"--tile-size",
type=int,
Expand All @@ -91,7 +86,7 @@ def with_tile_size() -> ClickOption[_P, _T]:
)


def with_block_size() -> ClickOption[_P, _T]:
def with_block_size[**P, T]() -> Callable[[Callable[P, T]], Callable[P, T]]:
return click.option(
"--block-size",
type=int,
Expand All @@ -101,7 +96,7 @@ def with_block_size() -> ClickOption[_P, _T]:
)


def with_block_key() -> ClickOption[_P, _T]:
def with_block_key[**P, T]() -> Callable[[Callable[P, T]], Callable[P, T]]:
return click.option(
"--block-key",
"-b",
Expand All @@ -111,11 +106,11 @@ def with_block_key() -> ClickOption[_P, _T]:
)


def with_resolution(
def with_resolution[**P, T](
choices: Collection[str],
*,
allow_all: bool = False,
) -> ClickOption[_P, _T]:
) -> Callable[[Callable[P, T]], Callable[P, T]]:
return with_choice(
"resolution",
allow_all=allow_all,
Expand All @@ -126,7 +121,6 @@ def with_resolution(

__all__ = [
"RUN_ALL",
"ClickOption",
"convert_choice",
"with_block_key",
"with_block_size",
Expand Down
4 changes: 2 additions & 2 deletions src/rra_building_density/extract/ghsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def extract_ghsl_main(
out_zipfile.unlink()


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_measure(bdc.GHSLVersion.measure_map)
@clio.with_time_point()
@clio.with_output_directory(bdc.MODEL_ROOT)
Expand All @@ -80,7 +80,7 @@ def extract_ghsl_task(
extract_ghsl_main(measure, time_point, output_dir, progress_bar=progress_bar)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_measure(bdc.GHSLVersion.measure_map, allow_all=True)
@clio.with_time_point(allow_all=True)
@clio.with_output_directory(bdc.MODEL_ROOT)
Expand Down
6 changes: 3 additions & 3 deletions src/rra_building_density/extract/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def extract_microsoft_indices_main(
bd_data.cache_provider_index(index, msft_version, index_type)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_version(bdc.MICROSOFT_VERSIONS)
@clio.with_output_directory(bdc.MODEL_ROOT)
@clio.with_overwrite()
Expand Down Expand Up @@ -137,7 +137,7 @@ def _run_azcopy_subprocess(azcopy_command_str: str, *, verbose: bool = False) ->
subprocess.run(shlex.split(azcopy_command_str), check=True) # noqa: S603


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_time_point()
@clio.with_version(bdc.MICROSOFT_VERSIONS)
@clio.with_output_directory(bdc.MODEL_ROOT)
Expand All @@ -156,7 +156,7 @@ def extract_microsoft_tiles_task(
)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_time_point(allow_all=True)
@clio.with_version(bdc.MICROSOFT_VERSIONS)
@clio.with_output_directory(bdc.MODEL_ROOT)
Expand Down
4 changes: 2 additions & 2 deletions src/rra_building_density/process/ghsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def format_ghsl_main(
)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_measure(bdc.GHSLVersion.measure_map)
@clio.with_block_key()
@clio.with_time_point()
Expand All @@ -79,7 +79,7 @@ def format_ghsl_task(
format_ghsl_main(block_key, measure, time_point, resolution, output_dir)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_measure(bdc.GHSLVersion.measure_map, allow_all=True)
@clio.with_time_point(allow_all=True)
@clio.with_resolution(bdc.RESOLUTIONS)
Expand Down
4 changes: 2 additions & 2 deletions src/rra_building_density/process/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def format_microsoft_main(
)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_block_key()
@clio.with_time_point()
@clio.with_version(bdc.MICROSOFT_VERSIONS)
Expand All @@ -128,7 +128,7 @@ def format_microsoft_task(
format_microsoft_main(block_key, time_point, version, resolution, output_dir)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_time_point(allow_all=True)
@clio.with_version(bdc.MICROSOFT_VERSIONS)
@clio.with_resolution(bdc.RESOLUTIONS)
Expand Down
4 changes: 2 additions & 2 deletions src/rra_building_density/process/tile_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def tile_index_main(
bd_data.save_tile_index(modeling_frame, modeling_frame_info)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_tile_size()
@clio.with_block_size()
@clio.with_resolution(bdc.RESOLUTIONS)
Expand All @@ -95,7 +95,7 @@ def tile_index_task(
)


@click.command() # type: ignore[arg-type]
@click.command()
@clio.with_tile_size()
@clio.with_block_size()
@clio.with_resolution(bdc.RESOLUTIONS.to_list(), allow_all=True)
Expand Down

0 comments on commit d8bcc1b

Please sign in to comment.