Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get tests running and enable PR/branch testing on GHA #27

Merged
merged 47 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3dbc3f1
Running black to fix formatting
blnicho Oct 23, 2024
b856551
Enable GHA branch testing and fix GHA PR testing
blnicho Oct 23, 2024
add9e87
Fixing typos
blnicho Oct 23, 2024
c6fd77e
Setting "fail-fast" to False in GHA workflows
blnicho Oct 23, 2024
e8d2769
Update Action versions to address Node.js deprecation
blnicho Oct 23, 2024
4315327
Update Action versions to address Node.js deprecation
blnicho Oct 23, 2024
8151e52
Debugging tests
blnicho Oct 24, 2024
a058f90
Try relaxing anyio version requirement
blnicho Oct 24, 2024
3e7d822
Forgot to run black
blnicho Oct 24, 2024
2bd95fe
Try changing version of pyomo used for testing
blnicho Oct 24, 2024
6a3cb0a
Debugging GHA environment setup
blnicho Oct 24, 2024
e0f9297
Manually install scipy in GHA test environment
blnicho Oct 24, 2024
e7958e5
Debugging GHA Python environment
blnicho Oct 24, 2024
5cf4668
More debugging
blnicho Oct 24, 2024
01fbafa
More debugging
blnicho Oct 24, 2024
567a6db
Merge pull request #25 from IDAES/main
rundxdi Oct 28, 2024
b85b7a2
Merge branch 'IDAES:main' into fix-tests
blnicho Oct 30, 2024
a8e7a28
More edits to GHA branch testing workflow
blnicho Oct 30, 2024
86d47d2
Renaming driver_config_test.py to fix error in pytest
blnicho Oct 30, 2024
1c421db
Updating paths in validation tests
blnicho Nov 6, 2024
b8495c2
Minor change the GHA workflow for testing branches
blnicho Nov 6, 2024
9562f46
Fixing bug in validation.py
blnicho Nov 6, 2024
1ed36ca
Running black
blnicho Nov 6, 2024
d654f5c
Cleaning up file paths in validation.py
blnicho Nov 20, 2024
9f991f0
Fixing black formatting
blnicho Nov 20, 2024
505710e
fixing units in model and objective value in test_gtep_model
rundxdi Nov 25, 2024
53b6525
unbreaking unit test autosearch...
rundxdi Nov 25, 2024
30f38bd
Merge branch 'dev' into fix-tests
blnicho Nov 25, 2024
4cfa765
Ran black
blnicho Nov 25, 2024
71e39f9
Removing unnecessary pass statement
blnicho Nov 25, 2024
b459b03
fixing rng setting for deterministic results with multiple model crea…
rundxdi Nov 25, 2024
adf3b41
Merge branch 'dev' into fix-tests
blnicho Nov 25, 2024
85626a1
Running black
blnicho Nov 25, 2024
8de4ae8
minor config additions; running Black
rundxdi Dec 3, 2024
e4afb0c
Merge branch 'dev' into fix-tests
blnicho Dec 11, 2024
181b64c
Ran black
blnicho Dec 11, 2024
35265fd
Debugging validation test
blnicho Dec 11, 2024
80806c8
Fixing typo
blnicho Dec 11, 2024
3440691
Fixing typo
blnicho Dec 11, 2024
5fc4223
Cleaning up test_validation.py
blnicho Dec 12, 2024
d4a04ec
Updating GHA workflows to be consistent and adding Python 3.12 testing
blnicho Dec 12, 2024
927a404
switch to raw string to silence deprecation warning
blnicho Dec 12, 2024
cb2ac37
Use raw strings to silence deprecation warnings
blnicho Dec 12, 2024
c3240d4
Removing commented debugging code from tests
blnicho Jan 15, 2025
150fb25
Run black
blnicho Jan 15, 2025
5f1c711
Removing incorrect comments in the GHA workflows
blnicho Jan 15, 2025
d7a014f
NFC: Fixing typo in the GHA workflows
blnicho Jan 15, 2025
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
89 changes: 89 additions & 0 deletions .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: GitHub Branch CI

on:
push:
branches-ignore:
- main
workflow_dispatch:
inputs:
git-ref:
description: Git Hash (Optional)
required: false

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
# -l: login shell, needed when using Conda run:
shell: bash -l {0}

jobs:
code-formatting:
name: Check code formatting (Black)
# OS and/or Python version don't make a difference, so we choose ubuntu and 3.10 for performance
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Black
run: |
pip install black
- name: Run Black to verify that the committed code is formatted
run: |
black --check --diff .

spell-check:
name: Check Spelling
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Run Spell Checker
uses: crate-ci/typos@master
with:
config: ./.github/workflows/typos.toml

build:
name: ${{ matrix.os }}/${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python: [3.9, '3.10', '3.11', '3.12']
steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Set up Miniconda Python
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python }}

- name: Install Python packages (conda)
run: |
# Set up environment
conda config --set always_yes yes
conda config --set auto_update_conda false
conda config --remove channels defaults
conda config --append channels nodefaults
conda config --append channels conda-forge

echo "Install Python packages"
conda install --yes --quiet pip setuptools wheel
conda install --yes --quiet scipy pyomo pytest highspy

echo "Final conda environment:"
conda list | sed 's/^/ /'

- name: Install idaes-gtep
run: |
pip install -e .

- name: Run Tests
run: |
pytest -v gtep
44 changes: 30 additions & 14 deletions .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch:
inputs:
git-ref:
Expand All @@ -29,18 +34,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Black
# unlike the other jobs, we don't need to install IDAES and/or all the dev dependencies,
# but we still want to specify the Black version to use in requirements-dev.txt for local development
# so we extract the relevant line and pass it to a simple `pip install`
run: |
pip install black
- name: Run Black to verify that the committed code is formatted
run: |
black --check .
black --check --diff .

spell-check:
name: Check Spelling
Expand All @@ -58,25 +60,39 @@ jobs:
needs: [code-formatting, spell-check]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python: [3.9, '3.10', '3.11']
python: [3.9, '3.10', '3.11', '3.12']
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4

- name: Set up Miniconda Python
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python }}
- name: Install Pyomo

- name: Install Python packages (conda)
run: |
pip install git+https://github.com/Pyomo/pyomo.git
# Set up environment
conda config --set always_yes yes
conda config --set auto_update_conda false
conda config --remove channels defaults
conda config --append channels nodefaults
conda config --append channels conda-forge

echo "Install Python packages"
conda install --yes --quiet pip setuptools wheel
conda install --yes --quiet scipy pyomo pytest highspy

echo "Final conda environment:"
conda list | sed 's/^/ /'

- name: Install idaes-gtep
run: |
python setup.py develop
pip install -e .

- name: Run Tests
run: |
pip install pytest
pip install highspy
pytest -v gtep

5 changes: 5 additions & 0 deletions .github/workflows/typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ extend-exclude = ["*.eps"]
# Ignore IDAES
IDAES = "IDAES"
idaes = "idaes"
# Ignore ND
ND = "ND"
nd = "nd"
# Ignore opf
opf = "opf"
54 changes: 49 additions & 5 deletions gtep/config_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@

def _get_model_config():
CONFIG = ConfigBlock("GTEPModelConfig")

CONFIG.declare(
"include_planning",
ConfigValue(
default=True,
domain=Bool,
description="Enable inclusion of any investment options.",
),
)

CONFIG.declare(
"include_commitment",
ConfigValue(
default=True,
domain=Bool,
description="Include unit commitment formulation.",
),
)

CONFIG.declare(
"include_dispatch",
ConfigValue(
default=True,
domain=Bool,
description="Include economic dispatch formulation (i.e., OPF).",
),
)

CONFIG.declare(
"flow_model",
ConfigValue(
Expand All @@ -27,25 +55,42 @@ def _get_model_config():
description="Power flow approximation to use.",
),
)

CONFIG.declare(
"time_period_subsets",
ConfigList(
description="Time period counts for fixed-length and fixed-subset periods."
),
)

CONFIG.declare(
"time_period_dict",
ConfigDict(
description="Time period dict, specified as \{(investment period #, length): \{(commitment period #, length): \{dispatch period #: length\}\}\}"
description=r"Time period dict, specified as \{(investment period #, length): \{(commitment period #, length): \{dispatch period #: length\}\}\}"
),
)

CONFIG.declare(
"dispatch_randomizations",
"dispatch_randomization",
ConfigValue(
default=True,
domain=Bool,
description="Introduces random dispatch information rather than having fixed values per-commitment period.",
description="Introduces random dispatch information rather than having fixed values per commitment period.",
),
)
return CONFIG


def _add_common_configs(CONFIG):
pass

CONFIG.declare(
"scale_loads",
ConfigValue(
default=False,
domain=Bool,
description="Allow scaling of load values into future years; i.e., load scaling is represented in the model but not the data.",
),
)


def _add_investment_configs(CONFIG):
Expand Down Expand Up @@ -79,7 +124,6 @@ def _add_investment_configs(CONFIG):
description="Include transmission investment options",
),
)
pass


def _add_solver_configs(CONFIG):
Expand Down
7 changes: 1 addition & 6 deletions gtep/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
data_object.load_prescient(data_path)

mod_object = ExpansionPlanningModel(
stages=2,
data=data_object.md,
num_reps=2,
len_reps=1,
num_commit=6,
num_dispatch=4,
stages=2, data=data_object.md, num_reps=2, len_reps=1, num_commit=6, num_dispatch=4
)
mod_object.create_model()
TransformationFactory("gdp.bound_pretransformation").apply_to(mod_object.model)
Expand Down
15 changes: 5 additions & 10 deletions gtep/driver_config_test.py → gtep/driver_config_work.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@
data_object.load_prescient(data_path)



mod_object = ExpansionPlanningModel(
stages=1,
data=data_object.md,
num_reps=1,
len_reps=1,
num_commit=24,
num_dispatch=4,
stages=1, data=data_object.md, num_reps=1, len_reps=1, num_commit=24, num_dispatch=4
)

for k,v in mod_object.config.items():
ic(k,v)
for k, v in mod_object.config.items():
print(f"k: {k}", f"v: {v}")

quit()

exit()

mod_object.create_model()

Expand Down
6 changes: 2 additions & 4 deletions gtep/driver_jsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
opt = Highs()
# opt = SolverFactory("gurobi", solver_io="python")
# opt = Gurobi()
#mod_object.results = opt.solve(mod_object.model, tee=True)
# mod_object.results = opt.solve(mod_object.model, tee=True)
mod_object.results = opt.solve(mod_object.model)


Expand All @@ -48,9 +48,7 @@
if load_numerical_results:
sol_object.read_json("./gtep_solution_jscTest.json")
# sol_object.read_json("./gtep_solution.json")
#sol_object.read_json("./bigger_longer_wigglier_gtep_solution.json")
# sol_object.read_json("./bigger_longer_wigglier_gtep_solution.json")
plot_results = True
if plot_results:
sol_object.plot_levels(save_dir="./plots/")

pass
Loading
Loading