From 15146283ef58734bc3345b14a19d32a82cdb4bba Mon Sep 17 00:00:00 2001 From: Amar Akram <263758252+amarakramali@users.noreply.github.com> Date: Mon, 27 Jul 2026 17:36:43 +0200 Subject: [PATCH] Package forecasting tools with CLI entry points --- .github/workflows/ci.yml | 19 +++++++++++--- .gitignore | 3 +++ README.md | 31 ++++++++++++---------- pyproject.toml | 56 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef6fcb2..cc27e00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,13 +30,12 @@ jobs: python-version: ${{ matrix.python-version }} cache: pip cache-dependency-path: | - requirements.txt - requirements-dev.txt + pyproject.toml - - name: Install dependencies + - name: Install project and development tools run: | python -m pip install --upgrade pip - python -m pip install -r requirements-dev.txt + python -m pip install --editable ".[dev]" - name: Lint Python sources run: python -m ruff check src tests streamlit_app.py @@ -46,3 +45,15 @@ jobs: - name: Compile Python sources run: python -m compileall -q src tests streamlit_app.py + + - name: Build wheel and source distribution + run: python -m build + + - name: Smoke-test installed console commands + run: | + aep-demo --help + aep-sample-data --help + aep-make-features --help + aep-baseline-eval --help + aep-xgb-eval --help + aep-forecast --help diff --git a/.gitignore b/.gitignore index 09a9f7e..d258739 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ data/ .pytest_cache/ __pycache__/ *.py[cod] +build/ +dist/ +*.egg-info/ diff --git a/README.md b/README.md index e5b011b..ca6b264 100644 --- a/README.md +++ b/README.md @@ -95,30 +95,32 @@ The data is **not** included in this repo. Download `AEP_hourly.csv` (columns `D Run the complete pipeline against a deterministic 90-day sample: ```powershell -python -m src.demo_pipeline +aep-demo ``` This single command creates the sample data, features, baseline and XGBoost metrics, evaluation plots, trained model, and next-24h forecast under the existing ignored `data/`, `reports/`, and `models/` directories. Use -`--output-dir` to keep every artifact below a different directory. +`--output-dir` to keep every artifact below a different directory. The module +form, `python -m src.demo_pipeline`, remains available when working directly +from a source checkout. -The equivalent individual commands are: +The equivalent installed console commands are: ```powershell -python -m src.sample_data -python -m src.make_features ` +aep-sample-data +aep-make-features ` --input data\sample_aep_hourly.csv ` --output data\sample_features_aep.csv -python -m src.baseline_eval ` +aep-baseline-eval ` --features data\sample_features_aep.csv ` --metrics reports\sample_baseline_metrics.csv ` --plot reports\figures\sample_baseline.png -python -m src.xgb_eval ` +aep-xgb-eval ` --features data\sample_features_aep.csv ` --metrics reports\sample_xgb_metrics.csv ` --plot reports\figures\sample_xgb_evaluation.png -python -m src.forecast_24h ` +aep-forecast ` --input data\sample_aep_hourly.csv ` --features data\sample_features_aep.csv ` --output reports\sample_forecast.csv ` @@ -136,11 +138,12 @@ must not be used to reproduce the reported benchmark metrics. python -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install --upgrade pip -pip install -r requirements.txt +python -m pip install --editable . ``` -The requirements include the Streamlit demo as well as the training and -evaluation dependencies. +This installs the training and evaluation dependencies, the Streamlit demo, +and the six `aep-*` console commands. Use `python -m pip install .` instead +when an editable source checkout is not needed. ## Usage (Windows / PowerShell) @@ -215,12 +218,14 @@ python -m src.make_features ` Run the synthetic validation tests with: ```powershell -pip install -r requirements-dev.txt +python -m pip install --editable ".[dev]" python -m ruff check src tests streamlit_app.py python -m pytest +python -m build ``` -GitHub Actions runs the same lint, test, and source-compilation checks on +GitHub Actions installs the project, runs the same lint, test, source-compilation +and distribution-build checks, and smoke-tests all six console commands on Python 3.10 and 3.12 for every pull request. ## Limitations diff --git a/pyproject.toml b/pyproject.toml index 112e4b8..f696abf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,59 @@ +[build-system] +requires = ["setuptools>=77"] +build-backend = "setuptools.build_meta" + +[project] +name = "aep-load-forecasting" +version = "0.1.0" +description = "Reproducible AEP electricity-load forecasting with XGBoost" +readme = "README.md" +requires-python = ">=3.10" +license = "MIT" +license-files = ["LICENSE"] +authors = [ + { name = "Amar Akram" }, +] +keywords = ["energy", "forecasting", "time-series", "xgboost"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering :: Artificial Intelligence", +] +dependencies = [ + "joblib>=1.3", + "matplotlib>=3.7", + "numpy>=1.24", + "pandas>=2.0", + "scikit-learn>=1.3", + "streamlit>=1.30", + "xgboost>=2.0", +] + +[project.optional-dependencies] +dev = [ + "build>=1.2", + "pytest>=8.0", + "ruff==0.16.0", +] + +[project.scripts] +aep-demo = "src.demo_pipeline:main" +aep-sample-data = "src.sample_data:main" +aep-make-features = "src.make_features:main" +aep-baseline-eval = "src.baseline_eval:main" +aep-xgb-eval = "src.xgb_eval:main" +aep-forecast = "src.forecast_24h:main" + +[project.urls] +Homepage = "https://github.com/amarakramali/load-forecasting-xgboost" +Issues = "https://github.com/amarakramali/load-forecasting-xgboost/issues" + +[tool.setuptools] +packages = ["src"] + [tool.ruff] target-version = "py310" line-length = 88