Skip to content

Refactor/package structure - #1

Merged
WagnerJ-Dev merged 13 commits into
masterfrom
refactor/package-structure
Jul 4, 2026
Merged

WagnerJ-Dev merged 13 commits into
masterfrom
refactor/package-structure

Conversation

@WagnerJ-Dev

Copy link
Copy Markdown
Owner

No description provided.

Restructure the flat scripts into a proper, open-source-ready Python package
with a clean separation between pure numerical functions and the few pieces
that hold genuine state.

Structure (light-touch OOP per CLAUDE.md — classes only for state/interfaces):
- config.py    Config dataclass — every tunable in one place, secrets via env
- models.py    dataclasses: Building, RoofPlane, SystemResult, ScoredHome
- geometry/roof/solar/grading — pure functions (trivially testable)
- sources/     tiles, buildings, irradiance, regions (all free sources)
- storage.py   ResultStore — owns the single DuckDB connection + resume ledgers
- pipeline.py  streaming, parallel, resumable orchestration
- cli.py       `solargrader run|enrich|map|regrade` subcommands

Key improvements:
- test_pipeline.py was the de-facto core library; its scoring math moves into
  the package and its main() becomes examples/validate_single_tile.py.
- Removes the setup_db/score_building duplication across files.
- Config is passed explicitly into worker processes (picklable), fixing the
  spawn-time global-override gap.
- Heavy optional deps (PDAL, Open3D, pvlib) imported lazily, so the pure
  modules and tests run with only numpy/shapely/pyproj.

Packaging: pyproject.toml (+ setup.py shim for old pip), console entry point,
pytest suite for the pure functions, ruff config, GitHub Actions CI, README.
Backward-compatible shims keep `python pipeline.py …` etc. working.
@WagnerJ-Dev
WagnerJ-Dev merged commit 1ac7e53 into master Jul 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant