PWA-hydro-conditioning-tools
Python module for hydro conditioning Prairie watersheds. Part of the Prairie Watershed Analytics (PWA) - a broader IISD-ELA GIS and modeling project for watershed analysis.
For developers
This package is built for use in the PWA-modeling product repository and the PWA developer repository. Updates to functions in this package must be tested for backwards compatibility with PWA-modeling before being merged.
Branches
- main : branch used only for tested publishable code
- dev : branch used for development and testing
Versioning Note
Versions follow the Semver convention:
- Patch x.x.Y. - bug fix, no interface change (Not currently tracked)
- Minor x.Y.x. - new feature added, fully backward compatible
- Major Y.x.x. - breaking change to the public interface
Process note: Major or minor commits to this repo should be tested for compatibility with PWA dependencies
State Management System
The package includes a robust state management system for efficient development workflows:
- Global State Object:
state- tracks project paths, filenames, and workflow progress - Save Function:
save_state()- persists state to.pklfile in interim directory - Recovery Function:
recover_state()- restores state from.pklfile for resumed sessions - Last Function Tracking:
state.LAST_FUNCTION_RUN- enables workflow continuation from specific points
This system allows developers to avoid rerunning entire workflows during development and testing phases.
Key Features
- Setup Functions: Automated project directory structure creation and file organization
- State Management: Save and recover workflow state using
.pklfiles for efficient development and testing - GIS Processing: Comprehensive hydro conditioning workflow including:
- LiDAR DEM processing and merging
- Watershed delineation and stream conditioning
- Depression analysis and wetland polygon generation
- Coordinate reference system management
- WhiteBox Integration: Seamless integration with WhiteboxTools for advanced spatial analysis
Developer Steps
- Make sure local versions of PWA, -main and -tools repos are up to date and dev branch is up to date with main.
- Use setup functions (
project_setup(),set_directory_structure()) andstate.save_state()for developing major adjustments to main workflow (to avoid rerunning entire workflow during dev & testing). Patches can be developed directly in a debugging mode. - Leverage the state recovery system (
recover_state()) to resume work from saved.pklfiles when testing iteratively. - If making several different improvements, run steps below in separate series:
- Using dev branch, add functions to package (-tools) and insert them in the workflow (-main). Best practice is to do this separately for each repository using your IDE.
- Re-install the package (-tools) using
pip install -e .and test the hydro_condition.py file - If successful, update version info in pyproject.toml and merge dev branch to main
Repository Structure
PWA-hydro-conditioning-tools/
├── pwa_tools/ # Main Python module
│ ├── __init__.py # Initializes the package and defines key functions and classes
│ └── WBT # Contains all WhiteBox tools used in the package
│ ├── __init__.py # Marks WhiteBox as a package (it's just an empty Python file)
│ └── ...WhiteBox related files...
├── .gitignore # Git ignore rules (e.g., __pycache__, *.egg-info)
├── README.md # This file
├── requirements.txt # Python dependencies (except GDAL, which is installed separately using conda)
└── pyproject.toml # Install configuration (used for pip install -e .)
Running tests
This project uses pytest. From the repo root with the conda env activated:
python -m pytest -q
Useful flags during development:
-q— quiet output (one dot per test, summary at the end)-k <pattern>— run only tests whose name matches the pattern-x— stop on the first failure (fast feedback while iterating)--tb=short— concise tracebacks-p no:cacheprovider— skip the.pytest_cache/write (useful in read-only checkouts)
Tests live in tests/unit/ and (where applicable) tests/regression/. All tests should pass before opening a pull request.
Contributing
Workflow for adding a feature or fixing a bug:
- Create a feature branch off the default branch. Use
feat/<short-name>for features andfix/<short-name>for bug fixes — never commit directly to the default branch. - Write a failing test first that describes the desired behavior. Run
python -m pytest -qto confirm the new test fails. For bug fixes, the test should reproduce the bug. - Write code to make the test pass. Run the suite again and confirm green.
- Commit incrementally with focused commit messages that explain why (the motivation, the problem, the trade-off) rather than just what (the diff is the what).
- Open a pull request against the default branch. Tag the relevant reviewer. The PR description should include a short summary, a test plan, and links to any related issues.
Practical notes:
- New features should ship with corresponding tests. If a unit test is hard to write, that's often a signal the design needs refactoring.
- Avoid disabling, skipping, or commenting out tests to make builds pass — investigate the root cause and fix it properly.
- Keep commits small and atomic. If you find yourself making unrelated changes in the same commit, split them.
- Don't add features beyond what the issue/PR scope requires. YAGNI — build for the current need, refactor later when a second use case emerges.
Metadata
Release files for pwa-tools 1.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pwa_tools-1.1.8.tar.gz | 91.6 kB | Without provenance | Details for pwa_tools-1.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pwa_tools-1.1.8-py3-none-any.whl | Python 3 | none | any | Details for pwa_tools-1.1.8-py3-none-any.whl |
Total release size: 186.6 kB
Release files / pwa_tools-1.1.8.tar.gz
| Download URL | pwa_tools-1.1.8.tar.gz |
|---|---|
| Size | 91.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cda42d2d63e32eb764db0bbb9e681e55dec76104620f07fd090aed36926fd9fe
|
|
BLAKE2b-256 checksum How to use checksums |
99b552a09cf4a19cedb974b28cadc6db9304c13367c09b6c0c10dccb4f54713f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / pwa_tools-1.1.8-py3-none-any.whl
| Download URL | pwa_tools-1.1.8-py3-none-any.whl |
|---|---|
| Size | 95.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
56a7d66661078d842c2b372170104b46003f4dcf0bbca7e4309875370fedf6f2
|
|
BLAKE2b-256 checksum How to use checksums |
6711f697c897130c1a5f8189feba8482c8a40eae61f2f896421aa85d1cf91d88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for pwa-tools 1.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.