Skip to content

Commit

Permalink
Modernize build system (#46) and drop 3.7 support (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
aazuspan committed Jun 29, 2023
1 parent 42ac9f2 commit 83e503f
Show file tree
Hide file tree
Showing 20 changed files with 153 additions and 563 deletions.
9 changes: 0 additions & 9 deletions .bumpversion.cfg

This file was deleted.

9 changes: 0 additions & 9 deletions .git-hooks/pre-commit

This file was deleted.

25 changes: 8 additions & 17 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
name: coverage
name: tests-coverage

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
paths-ignore:
- '.pre-commit-config.yaml'
- 'docs/**'
- '**.md'
- '**.rst'
on: pull_request

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
pip install hatch
- name: Store EE token
run: |
python ./.github/scripts/make_ee_token.py
env:
EE_TOKEN: ${{ secrets.EE_TOKEN }}
- name: Test with pytest
run: |
pytest --cov=./sankee/ --cov-report=xml
hatch run test:coverage --cov-report=xml
- name: Upload to Codecov
run: |
bash <(curl -s https://codecov.io/bash)
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
name: tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
on: push

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
python-version: [ '3.8', '3.9', '3.10', '3.11' ]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
pip install hatch
- name: Store EE token
run: |
python ./.github/scripts/make_ee_token.py
env:
EE_TOKEN: ${{ secrets.EE_TOKEN }}
- name: Test with pytest
run: |
pytest .
hatch run test:all
20 changes: 14 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/psf/black
rev: 21.7b0
rev: 23.3.0
hooks:
- id: black
args: [--line-length=100]

- repo: https://github.com/pycqa/isort
rev: 5.8.0
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black]

- repo: https://github.com/pycqa/flake8
rev: 4.0.0
rev: 6.0.0
hooks:
- id: flake8
args: [--max-line-length=100]
exclude: docs|tests|setup.py
- id: flake8
args: [--max-line-length, '100']
exclude: docs|tests|setup.py
additional_dependencies:
- flake8-bugbear
54 changes: 0 additions & 54 deletions Makefile

This file was deleted.

21 changes: 0 additions & 21 deletions Pipfile

This file was deleted.

3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@

sys.path.insert(0, os.path.abspath(".."))

from sankee import __version__

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

project = "sankee"
copyright = "2021, Aaron Zuspan"
author = "Aaron Zuspan"
version = "v0.2.4"
version = __version__


# -- General configuration ---------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx==7.0.1
nbsphinx
sphinx_rtd_theme
76 changes: 76 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "sankee"
dynamic = ["version"]
description = "Visualize classified time series data with interactive Sankey plots in Google Earth Engine."
readme = "README.md"
license = "MIT"
requires-python = ">=3.8"
authors = [
{ name = "Aaron Zuspan", email = "aazuspan@gmail.com" },
]
keywords = [
"earth-engine",
"sankey",
"land-cover",
"visualization",
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: GIS",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"earthengine-api>=0.1.230",
"numpy",
"pandas",
"plotly>=5.2.2",
"ipywidgets"
]

[project.urls]
Homepage = "https://github.com/aazuspan/sankee"
Source = "https://github.com/aazuspan/sankee"

[tool.hatch.version]
path = "sankee/__init__.py"

[tool.hatch.build.targets.sdist]
include = ["sankee"]

[tool.hatch.envs.default]
dependencies = [
"pre-commit"
]

[tool.hatch.envs.docs]
dependences = [
"nbsphinx",
"sphinx",
"sphinx_rtd_theme",
]

[tool.hatch.envs.docs.scripts]
build = "sphinx-build -b html docs docs/_build/html"
view = "python -m webbrowser -t docs/_build/html/index.html"


[tool.hatch.envs.test]
dependencies = [
"pytest",
"pytest-cov",
]

[tool.hatch.envs.test.scripts]
all = "pytest . {args}"
coverage = "pytest . --cov=sankee {args}"
view-coverage = "python -m webbrowser -t htmlcov/index.html"
3 changes: 1 addition & 2 deletions readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ python:
install:
- method: pip
path: .
extra_requirements:
- doc
- requirements: docs/requirements.txt
build:
os: ubuntu-22.04
tools:
Expand Down
22 changes: 11 additions & 11 deletions sankee/datasets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, Union
from __future__ import annotations

import ee
import pandas as pd
Expand All @@ -14,10 +14,10 @@ def __init__(
name: str,
id: str,
band: str,
labels: Dict[int, str],
palette: Dict[int, str],
years: List[int],
nodata: Union[None, int] = None,
labels: dict[int, str],
palette: dict[int, str],
years: list[int],
nodata: None | int = None,
):
"""
Parameters
Expand Down Expand Up @@ -52,7 +52,7 @@ def __repr__(self) -> str:
return f"<Dataset: {self.name}>"

@property
def keys(self) -> List[int]:
def keys(self) -> list[int]:
"""Return the label keys of the dataset."""
return list(self.labels.keys())

Expand Down Expand Up @@ -103,16 +103,16 @@ def list_years(self) -> ee.List:

def sankify(
self,
years: List[int],
years: list[int],
region: ee.Geometry,
max_classes: Union[None, int] = None,
max_classes: None | int = None,
n: int = 500,
title: Union[str, None] = None,
scale: Union[int, None] = None,
title: str | None = None,
scale: int | None = None,
seed: int = 0,
exclude: None = None,
label_type: str = "class",
theme: Union[str, themes.Theme] = themes.DEFAULT,
theme: str | themes.Theme = themes.DEFAULT,
) -> go.Figure:
"""
Generate an interactive Sankey plot showing land cover change over time from a series of
Expand Down
Loading

0 comments on commit 83e503f

Please sign in to comment.