Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: 2

updates:
- package-ecosystem: "pip"
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "weekly"
Expand Down
22 changes: 8 additions & 14 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
version: "0.9.27"
- name: Build a binary wheel and a source tarball
run: python3 -m build
run: uv build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: python-package-distributions
path: dist/
Expand All @@ -40,13 +34,13 @@ jobs:
runs-on: ubuntu-latest
environment:
name: pypi_release
url: https://pypi.org/p/buildingid-nrel/
url: https://pypi.org/p/buildingid/
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v5
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
Expand Down
35 changes: 13 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,27 @@ name: Tests

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

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.13"]

python-version: ["3.11", "3.12", "3.13", "3.14"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
- uses: actions/checkout@v6
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: abatilo/actions-poetry@v4
with:
poetry-version: "latest"
- name: Install dependencies with Poetry
# poetry setuptools workaround sourced from https://github.com/python-poetry/poetry/issues/7611#issuecomment-1711443539
run: |
poetry --version
poetry self add setuptools
poetry install
version: "0.9.27"
- name: Install the project
run: uv sync --locked
- name: Run pre-commit
run: poetry run pre-commit run --show-diff-on-failure --color=always --all-files
# - name: Run mypy
# run: poetry run mypy --install-types --non-interactive --show-error-codes .
run: uv run pre-commit run --show-diff-on-failure --color=always --all-files
- name: Run tests with pytest
run: poetry run pytest tests/ --cov=buildingid --cov-report=xml --cov-report=term-missing
run: uv run pytest tests/ --cov-report=xml --cov-report=term-missing
51 changes: 31 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,45 @@ repos:
rev: v6.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=2000"]
args: ["--maxkb=5000"]
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-json
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-illegal-windows-names
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: pretty-format-json
args: ["--autofix", "--no-sort-keys", "--no-ensure-ascii"]
# - id: name-tests-test
# args: ["--pytest-test-first"]
- id: trailing-whitespace
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v4.0.0-alpha.8
# hooks:
# - id: prettier
# # for now ignoring html, javascript
# types_or: [yaml, markdown, css, scss]
# https://docs.astral.sh/ruff/integrations/#pre-commit
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.13.1
# hooks:
# - id: ruff-check
# args: [--fix, --exit-non-zero-on-fix, --output-format=full] #, --unsafe-fixes]
# exclude: buildingid/code_pattern.py
# - id: ruff-format
# exclude: buildingid/code_pattern.py
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
args: [--no-cache]
types_or: [json, markdown, toml, yaml]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
additional_dependencies:
- pandas-stubs
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
hooks:
# Run the linter
- id: ruff-check
args: [--fix, --verbose, --exit-non-zero-on-fix, --output-format=full]
# Run the formatter
- id: ruff-format
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

30 changes: 7 additions & 23 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Unique Building Identifier (UBID)
:target: https://github.com/SEED-platform/buildingid/actions/workflows/test.yml
:alt: Build Status

**Website:** https://buildingid.pnnl.gov/
**Website:** https://www.pnnl.gov/unique-building-identification

-------------
Documentation
Expand All @@ -18,34 +18,18 @@ Install
To complete this guide, `Git <https://git-scm.com/>`_ and `Python 3 <https://www.python.org/>`_ are required.
Dependencies are automatically installed using `pip <https://pypi.python.org/pypi/pip>`_.

Clone the repository, and then install the ``pnnl-buildingid`` package:
Clone the repository, and then install the ``buildingid`` package:

::

git clone https://github.com/pnnl/buildingid-py
cd buildingid-py
pip3 install -e .[dev]

Verify the location of the ``buildingid`` command:

::

which buildingid
#=> /usr/local/bin/buildingid

Uninstall
=========

Use `pip <https://pypi.python.org/pypi/pip>`_ to remove the ``pnnl-buildingid`` package:

::

pip3 uninstall pnnl-buildingid
git clone git@github.com:SEED-platform/buildingid.git
cd buildingid
uv sync

Test
====

Test the ``pnnl-buildingid`` package using the `pytest <https://docs.pytest.org/>`_ package:
Test the ``buildingid`` package using the `pytest <https://docs.pytest.org/>`_ package:

::

Expand All @@ -61,7 +45,7 @@ Coverage testing is enabled using the `pytest-cov <https://pytest-cov.readthedoc
Usage
=====

The ``pnnl-buildingid`` package supports two usages:
The ``buildingid`` package supports two usages:

* Application programming interface (API)
* Command-line interface (CLI; the ``buildingid`` command)
Expand Down
3 changes: 0 additions & 3 deletions buildingid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#
# pnnl-buildingid: buildingid/__init__.py
#
# Copyright (c) 2019, Battelle Memorial Institute
# All rights reserved.
#
Expand Down
20 changes: 12 additions & 8 deletions buildingid/code.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#
# pnnl-buildingid: buildingid/code.py
#
# Copyright (c) 2019, Battelle Memorial Institute
# All rights reserved.
#
Expand All @@ -10,7 +7,7 @@

from openlocationcode import openlocationcode

from .code_pattern import (
from buildingid.code_pattern import (
FORMAT_STRING_,
RE_GROUP_EAST_,
RE_GROUP_NORTH_,
Expand All @@ -19,7 +16,14 @@
RE_GROUP_WEST_,
RE_PATTERN_,
)
from .validators import isValidCodeArea, isValidCodeLength, isValidLatitude, isValidLatitudeCenter, isValidLongitude, isValidLongitudeCenter
from buildingid.validators import (
isValidCodeArea,
isValidCodeLength,
isValidLatitude,
isValidLatitudeCenter,
isValidLongitude,
isValidLongitudeCenter,
)

Code = typing.NewType("Code", str)

Expand Down Expand Up @@ -48,7 +52,7 @@ def encode(self) -> Code:
codeLength=self.codeLength,
)

def intersection(self, other: "CodeArea") -> typing.Optional[typing.Tuple[float, float, float, float]]:
def intersection(self, other: "CodeArea") -> tuple[float, float, float, float] | None:
if other is None:
return None

Expand All @@ -67,7 +71,7 @@ def intersection(self, other: "CodeArea") -> typing.Optional[typing.Tuple[float,
latitudeHi,
)

def jaccard(self, other: "CodeArea") -> typing.Optional[float]:
def jaccard(self, other: "CodeArea") -> float | None:
bbox = self.intersection(other)

if bbox is None:
Expand Down Expand Up @@ -167,7 +171,7 @@ def isValid(code: Code) -> bool:
return isValid_(code) is not None


def isValid_(code: Code) -> typing.Optional[typing.Match[str]]:
def isValid_(code: Code) -> typing.Match[str] | None:
if code is None:
return None

Expand Down
Loading