Skip to content

Commit c7df337

Browse files
authored
Merge pull request #27 from BuildingSync/task/uv-python-3.14
Modernization updates
2 parents d382b73 + 9fc7f56 commit c7df337

22 files changed

+1231
-1214
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,19 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
os: [ubuntu-latest]
13-
python-version: ["3.9", "3.13"]
12+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
13+
os: [ubuntu-latest, macos-latest, windows-latest]
1414
runs-on: ${{ matrix.os }}
1515
steps:
16-
- uses: actions/checkout@v4
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v5
16+
- uses: actions/checkout@v6
17+
- name: Install uv and set the Python version
18+
uses: astral-sh/setup-uv@v7
1919
with:
2020
python-version: ${{ matrix.python-version }}
21-
- name: Install poetry
22-
uses: abatilo/actions-poetry@v3
23-
with:
24-
poetry-version: 1.8.4
25-
- name: Install dependencies with Poetry
26-
run: |
27-
pip install --upgrade pip
28-
poetry install
21+
version: "0.9.27"
22+
- name: Install the project
23+
run: uv sync --locked
2924
- name: Run pytest
30-
run: |
31-
poetry run pytest
32-
pre-commit:
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v4
36-
- uses: actions/setup-python@v5
37-
with:
38-
python-version: "3.13"
25+
run: uv run pytest -v
3926
- name: Run pre-commit
40-
uses: pre-commit/action@v3.0.1
41-
with:
42-
extra_args: --all-files
27+
run: uv run pre-commit run -a

.github/workflows/pypi_release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: PyPIRelease
2+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
3+
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
build:
10+
name: Build distribution 📦
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v6
15+
with:
16+
persist-credentials: false
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v7
19+
with:
20+
version: "0.9.27"
21+
- name: Build a binary wheel and a source tarball
22+
run: uv build
23+
- name: Store the distribution packages
24+
uses: actions/upload-artifact@v6
25+
with:
26+
name: python-package-distributions
27+
path: dist/
28+
29+
publish-to-pypi:
30+
name: >-
31+
Publish Python 🐍 distribution 📦 to PyPI
32+
needs:
33+
- build
34+
runs-on: ubuntu-latest
35+
environment:
36+
name: pypi_release
37+
url: https://pypi.org/p/buildingid/
38+
permissions:
39+
id-token: write # IMPORTANT: mandatory for trusted publishing
40+
41+
steps:
42+
- name: Download all the dists
43+
uses: actions/download-artifact@v7
44+
with:
45+
name: python-package-distributions
46+
path: dist/
47+
- name: Publish distribution 📦 to PyPI
48+
uses: pypa/gh-action-pypi-publish@release/v1

.pre-commit-config.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v6.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: check-added-large-files
@@ -15,20 +15,27 @@ repos:
1515
- id: mixed-line-ending
1616
- id: pretty-format-json
1717
args: ["--autofix", "--no-sort-keys"]
18+
- repo: https://github.com/asottile/pyupgrade
19+
rev: v3.21.2
20+
hooks:
21+
- id: pyupgrade
1822
- repo: https://github.com/pre-commit/mirrors-prettier
1923
rev: v4.0.0-alpha.8
2024
hooks:
2125
- id: prettier
26+
args: [--no-cache]
2227
types_or: [markdown, yaml]
2328
- repo: https://github.com/pre-commit/mirrors-mypy
24-
rev: v1.12.1
29+
rev: v1.19.1
2530
hooks:
2631
- id: mypy
32+
additional_dependencies:
33+
- pandas-stubs
2734
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: v0.7.0
35+
rev: v0.14.14
2936
hooks:
3037
# Run the linter
31-
- id: ruff
38+
- id: ruff-check
3239
args: [--fix, --exit-non-zero-on-fix, --output-format=full]
3340
# Run the formatter
3441
- id: ruff-format

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BuildingSync®, Copyright (c) 2015, 2024 Alliance for Sustainable Energy, LLC, and other contributors.
1+
BuildingSync®, Copyright (c) 2015-2026 Alliance for Energy Innovation, LLC, and other contributors.
22

33
All rights reserved.
44

@@ -17,7 +17,7 @@ respective party.
1717

1818
(4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other
1919
derivative works may not use the "BuildingSync" trademark or any other confusingly similar designation
20-
without specific prior written permission from Alliance for Sustainable Energy, LLC.
20+
without specific prior written permission from Alliance for Energy Innovation, LLC.
2121

2222
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
2323
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND

README.md

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ pip install buildingsync-asset-extractor
1212

1313
### Install from source
1414

15-
[Poetry](https://python-poetry.org/) is required to install buildingsync-asset-extractor.
15+
[uv](https://docs.astral.sh/uv/) is required to install buildingsync-asset-extractor.
1616

1717
```bash
1818
# Copy repo
19-
git clone https://github.com/BuildingSync/BuildingSync-asset-extractor.git
19+
git clone git@github.com:BuildingSync/BuildingSync-asset-extractor.git
2020

2121
# install the package
2222
cd BuildingSync-asset-extractor
23-
poetry install
24-
25-
# Test that it works, you should see a message describing the usage
26-
poetry run buildingsync_asset_extractor
23+
uv sync
2724
```
2825

2926
## Usage
@@ -60,7 +57,7 @@ asset will be named the same as the original asset, with ' Units' appended at th
6057
To test usage:
6158

6259
```bash
63-
python buildingsync_asset_extractor/main.py
60+
uv run buildingsync_asset_extractor/main.py
6461
```
6562

6663
This will extract assets from `tests/files/testfile.xml` and save the results to `assets_output.json`
@@ -179,41 +176,36 @@ To enable pre-commit on every commit run the following from the command line fro
179176
BuildingSync-asset-extractor
180177

181178
```bash
182-
pre-commit install
179+
uv run pre-commit install
183180
```
184181

185182
To run pre-commit against the files without calling git commit, then run the following. This is useful when cleaning up
186183
the repo before committing.
187184

188185
```bash
189-
pre-commit run --all-files
186+
uv run pre-commit run --all-files
190187
```
191188

192189
### Testing
193190

194-
poetry run pytest
191+
```bash
192+
uv run pytest -v
193+
```
195194

196195
## Releasing
197196

198197
```bash
199-
poetry build
198+
uv build
200199

201-
# config and push to testpypi
202-
poetry config repositories.testpypi https://test.pypi.org/legacy/
203-
poetry publish -r testpypi
200+
# push to testpypi
201+
uv publish --publish-url https://test.pypi.org/legacy/
204202

205203
# install from testpypi
206204
pip install --index-url https://test.pypi.org/simple/ buildingsync-asset-extractor
207205
```
208206

209-
If everything looks good, publish to pypi:
210-
211-
```bash
212-
poetry publish
213-
```
214-
215-
If you have environment variables setup for PYPI token username and password:
207+
If everything looks good, publish to PyPI:
216208

217209
```bash
218-
poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD
210+
uv publish
219211
```

buildingsync_asset_extractor/bae_types.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from dataclasses import dataclass
2-
from typing import Any, Optional
2+
from typing import Any
33

44

55
@dataclass
66
class Section:
7-
type: Optional[str]
7+
type: str | None
88
areas: dict
99

1010

@@ -27,13 +27,13 @@ class AssetDef:
2727
parent_path: str
2828
key: str
2929
export_units: bool
30-
units: Optional[str] = None
30+
units: str | None = None
3131

3232

3333
@dataclass
3434
class SystemData:
3535
value: Any
36-
sqft: Optional[float] = None
37-
cap: Optional[str] = None
38-
cap_units: Optional[str] = None
39-
units: Optional[str] = None
36+
sqft: float | None = None
37+
cap: str | None = None
38+
cap_units: str | None = None
39+
units: str | None = None

buildingsync_asset_extractor/converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Literal, Optional, get_args
1+
from typing import Literal, get_args
22

33
from buildingsync_asset_extractor.bae_types import SystemData
44
from buildingsync_asset_extractor.errors import BSyncProcessorError
@@ -22,7 +22,7 @@
2222

2323
def unify_units(
2424
system_datas: list[SystemData],
25-
to_units: Optional[str] = None,
25+
to_units: str | None = None,
2626
) -> list[SystemData]:
2727
if to_units is None:
2828
to_units = system_datas[0].cap_units

buildingsync_asset_extractor/cts/classes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import functools
22
import logging
3+
from collections.abc import Iterable
34
from dataclasses import dataclass, field
45
from pathlib import Path
5-
from typing import Iterable, Optional
66

77
from lxml import etree as ETree # noqa: N812
88

@@ -36,7 +36,7 @@ class FacilityAppearance:
3636
path: Path
3737

3838
@functools.cached_property
39-
def cheapest_package_of_measures_scenario(self) -> Optional[PackageOfMeasuresScenario]:
39+
def cheapest_package_of_measures_scenario(self) -> PackageOfMeasuresScenario | None:
4040
# get the measures for reference
4141
measures_by_id = {m.get("ID"): Measure(m) for m in self.etree.findall("./Measures/Measure", self.etree.nsmap)}
4242

buildingsync_asset_extractor/cts/cts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def aggregate_facilities(files: list[Path]) -> dict[str, Facility]:
4242

4343
# for each file, get the facilities in the file
4444
for f in files:
45-
file_etree = etree.parse(f) # noqa: S320
45+
file_etree = etree.parse(f)
4646
facility_etrees = file_etree.findall("/Facilities/Facility", namespaces=file_etree.getroot().nsmap)
4747

4848
# for each facility in the file, add it to facility_by_id

buildingsync_asset_extractor/cts/parsers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def get_aggregated_findings_of_comprehensive_evaluations_estimated_life_cycle_da
8888

8989

9090
def get_potential_conservation_measures_per_technology_category(facility: Facility) -> pd.Series:
91-
results = {k: 0 for k in ENERGY_AND_WATER_CONSERVATION_MEASURES}
92-
results.update({k: 0 for k in technology_category_to_cts_field.values()})
91+
results = dict.fromkeys(ENERGY_AND_WATER_CONSERVATION_MEASURES, 0)
92+
results.update(dict.fromkeys(technology_category_to_cts_field.values(), 0))
9393

9494
# for each measure
9595
measures = [

0 commit comments

Comments
 (0)