Skip to content

Commit 59a874a

Browse files
authored
Fix the test CI workflow (#7)
* Bring bmi-example-c to v2.0.3 * Match file structure from pymt_heatf * Move bmi module to _bmi * Use absolute imports * Convert rst documents to markdown * Update syntax for calling bmi-tester * Don't use an editable install There's some trickiness where Meson puts files and model_metadata expects to find them. * Set minimum pymt at v1.3.2 * Raise minimum Python to 3.11 * Separate dev and lint optional project dependencies * Update project urls * Don't try to clean C source files * Make pretty * Fix the test workflow on unix
1 parent d4138e7 commit 59a874a

File tree

17 files changed

+95
-97
lines changed

17 files changed

+95
-97
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ name: Test
33
on: [push, pull_request]
44

55
jobs:
6-
build-and-test:
7-
# We want to run on external PRs, but not on our own internal PRs as they'll be run
8-
# by the push to the branch. Without this if check, checks are duplicated since
9-
# internal PRs match both the push and pull_request events.
6+
build-test-unix:
107
if:
11-
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
12-
github.repository
8+
github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
139

1410
runs-on: ${{ matrix.os }}
1511

@@ -20,33 +16,37 @@ jobs:
2016
strategy:
2117
matrix:
2218
os: [ubuntu-latest, macos-latest]
23-
python-version: ["3.9", "3.10", "3.11"]
2419

2520
steps:
2621
- uses: actions/checkout@v4
2722
with:
2823
submodules: true
2924

30-
- uses: mamba-org/setup-micromamba@v1
25+
- uses: mamba-org/setup-micromamba@v2
3126
with:
3227
micromamba-version: latest
3328
environment-file: environment.yml
3429

35-
- name: Build and install model
30+
- name: Build and install HeatModelC
3631
run: |
3732
mkdir build && pushd build
3833
cmake ../external/bmi-example-c -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
3934
make install
4035
popd
4136
42-
- name: Build and install package
37+
- name: Build and install project
4338
run: |
44-
pip install --no-build-isolation --editable .
39+
make install
4540
46-
- name: Test BMI
41+
- name: Test imports
42+
working-directory: ${{ github.workspace }}/examples
4743
run: |
4844
python -c 'import pymt_heatc'
49-
bmi-test pymt_heatc.bmi:HeatModelC --config-file=examples/config.txt --root-dir=examples -vvv
45+
python -c 'from pymt.models import HeatModelC'
46+
47+
- name: Test BMI
48+
run: |
49+
make test
5050
5151
- name: Run examples
5252
working-directory: ${{ github.workspace }}/examples
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
1-
Changelog for pymt_heatc
2-
========================
1+
# Changelog for pymt_heatc
32

4-
0.5 (unreleased)
5-
----------------
3+
## 0.5 (unreleased)
64

75
- Nothing changed yet.
86

97

10-
0.4 (2023-11-02)
11-
----------------
8+
## 0.4 (2023-11-02)
129

1310
- Rebuild project with Meson (#6)
1411

1512

16-
0.3 (2021-09-01)
17-
----------------
13+
## 0.3 (2021-09-01)
1814

1915
- Standardize BMI and pymt examples (#2)
2016
- Rename component from HeatModel to HeatModelC (#3)
2117
- Show total temperature in BMI example (#5)
2218

2319

24-
0.2 (2021-08-20)
25-
----------------
20+
## 0.2 (2021-08-20)
2621

2722
- Add metadata files from babelizer C example
2823
- Add examples of running BMI and through pymt
2924
- Rerender with babelizer v0.3.8
3025

3126

32-
0.1.0 (2020-03-10)
33-
------------------
27+
## 0.1.0 (2020-03-10)
3428

3529
- Initial version with output from bmi-render

CREDITS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Credits
2+
3+
- Mark Piper

CREDITS.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ clean-build: ## remove build artifacts
3838
find . -name '*.egg' -exec rm -f {} +
3939

4040
clean-compile: ## remove compilation artifacts
41-
find . -name '*.c' -exec rm -f {} +
4241
find . -name '*.mod' -exec rm -f {} +
4342
find . -name '*.o' -exec rm -f {} +
4443
find . -name '*.so' -exec rm -f {} +
@@ -64,7 +63,11 @@ pretty:
6463
black . --check
6564

6665
test: ## run tests quickly with the default Python
67-
bmi-test pymt_heatc.bmi:HeatModelC -vvv
66+
bmi-test pymt_heatc._bmi:HeatModelC \
67+
--config-file=${PWD}/examples/config.txt \
68+
--root-dir=examples \
69+
--bmi-version="2.0" \
70+
-vvv
6871

6972
test-all: ## run tests on every Python version with tox
7073
tox
@@ -83,4 +86,4 @@ dist: clean ## builds source and wheel package
8386
ls -l dist
8487

8588
install: clean ## install the package to the active Python's site-packages
86-
pip install --no-build-isolation --editable .
89+
python -m pip install . -v --no-build-isolation

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# pymt_heatc
2+
3+
This is an example of building a model, written in C and wrapped in
4+
Python with the [babelizer](https://github.com/csdms/babelizer), with
5+
the [meson-python](https://meson-python.readthedocs.io/en/latest/) build
6+
system using a `pyproject.toml` file to describe the build.
7+
8+
## Build/Install
9+
10+
This is a sketch of how to build and install this project.
11+
12+
1. Create the conda environment from [environment.yml](./environment.yml) and activate it.
13+
2. Build/install the [C BMI example](https://github.com/csdms/bmi-example-c/#buildinstall)
14+
3. Build/install this project with `make install`
15+
16+
## Use
17+
18+
Import the standalone project into a Python session:
19+
20+
``` python
21+
>>> import pymt_heatc
22+
```
23+
24+
Import the *pymt* component:
25+
26+
``` python
27+
>>> from pymt.MODELS import HeatModelC
28+
```
29+
30+
Try the examples in the [examples](./examples/) directory.

README.rst

Lines changed: 0 additions & 34 deletions
This file was deleted.

environment.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# An env for re/building a C pymt-lab component with Meson.
1+
# A conda environment for re/building a C pymt-lab component with Meson.
22
name: cbld
33
channels:
44
- conda-forge
55
dependencies:
66
- python =3
77
- pip
88
- make
9-
- cmake
9+
- cmake # [bmi-example-c]
1010
- pkg-config
1111
- bmi-c
1212
- c-compiler
13+
- cxx-compiler # [win]
1314
- cython
1415
- meson-python
16+
- python-build
1517
- numpy
1618
- bmi-tester >=0.5.5
17-
- pymt >=1.3
19+
- pymt >=1.3.2

examples/heatc_ex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Run the heatc model through its BMI in Python."""
2+
23
import numpy as np
34
from pymt_heatc import HeatModelC
45

examples/pymt_heatc_ex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Run the heatc model in pymt."""
2+
23
import numpy as np
34
from pymt.models import HeatModelC
45

0 commit comments

Comments
 (0)