Skip to content

Commit 4cdeb7d

Browse files
authored
Merge pull request #22 from BuildingEnergySimulationTools/ompython_fixes
Require OMPython>=3.5.2, rework CI
2 parents 4757d46 + 382fd99 commit 4cdeb7d

14 files changed

Lines changed: 86 additions & 66 deletions

.github/workflows/build.yaml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ on:
55
tags: [ "*" ]
66
pull_request:
77
jobs:
8-
lint:
9-
name: lint
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-python@v4
14-
with:
15-
python-version: 3.11
16-
- run: python -m pip install --upgrade pip wheel
17-
- run: pip install tox
18-
- run: tox -elint
198
tests:
209
name: ${{ matrix.name }}
2110
runs-on: ubuntu-latest
@@ -24,7 +13,7 @@ jobs:
2413
matrix:
2514
include:
2615
- { name: '3.10', python: '3.10', tox: py310 }
27-
- { name: '3.12', python: '3.12', tox: py312 }
16+
- { name: '3.11', python: '3.11', tox: py311 }
2817
- { name: 'min', python: '3.10', tox: min }
2918
steps:
3019
- name: "Set up OpenModelica Compiler"
@@ -63,8 +52,20 @@ jobs:
6352
with:
6453
token: ${{ secrets.CODECOV_TOKEN }}
6554
files: ./coverage.xml
55+
# this duplicates pre-commit.ci, so only run it on tags
56+
# it guarantees that linting is passing prior to a release
57+
lint-pre-release:
58+
if: startsWith(github.ref, 'refs/tags')
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4.0.0
62+
- uses: actions/setup-python@v5
63+
with:
64+
python-version: "3.11"
65+
- run: python -m pip install tox
66+
- run: python -m tox -e lint
6667
release:
67-
needs: [ lint, tests ]
68+
needs: [ tests, lint-pre-release ]
6869
name: PyPI release
6970
if: startsWith(github.ref, 'refs/tags')
7071
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
ci:
2-
skip: [pip-compile]
3-
41
repos:
5-
- repo: https://github.com/asottile/pyupgrade
6-
rev: v3.3.1
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.4.2
74
hooks:
8-
- id: pyupgrade
9-
args: [--py310-plus]
10-
- repo: https://github.com/psf/black
11-
rev: 23.3.0
5+
- id: ruff
6+
- id: ruff-format
7+
- repo: https://github.com/python-jsonschema/check-jsonschema
8+
rev: 0.28.2
129
hooks:
13-
- id: black
14-
language_version: python3
15-
- repo: https://github.com/pycqa/flake8
16-
rev: 6.0.0
17-
hooks:
18-
- id: flake8
19-
additional_dependencies: [flake8-bugbear==23.1.14]
10+
- id: check-github-workflows

.ruff.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
fix = true
2+
show-fixes = true
3+
output-format = "full"
4+
5+
[format]
6+
docstring-code-format = true
7+
8+
[lint]
9+
ignore = []
10+
select = [
11+
"B", # flake8-bugbear
12+
"E", # pycodestyle error
13+
"F", # pyflakes
14+
"I", # isort
15+
"UP", # pyupgrade
16+
"W", # pycodestyle warning
17+
]
18+
19+
[lint.isort]
20+
section-order = ["future", "standard-library", "testing", "science", "corrai", "third-party", "first-party", "local-folder"]
21+
22+
[lint.isort.sections]
23+
testing = ["pytest"]
24+
science = ["numpy", "pandas", "OMPython"]
25+
corrai = ["corrai"]

modelitool/combitabconvert.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime as dt
2+
23
import pandas as pd
34

45

modelitool/corrai_connector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import pandas as pd
21
import numpy as np
2+
import pandas as pd
3+
34
from corrai.base.parameter import Parameter
5+
46
from modelitool.simulate import OMModel
57

68

modelitool/simulate.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
from pathlib import Path
44

55
import pandas as pd
6-
from OMPython import ModelicaSystem
7-
from OMPython import OMCSessionZMQ
6+
from OMPython import ModelicaSystem, OMCSessionZMQ
7+
88
from corrai.base.model import Model
99

10-
from modelitool.combitabconvert import df_to_combitimetable
11-
from modelitool.combitabconvert import seconds_to_datetime
10+
from modelitool.combitabconvert import df_to_combitimetable, seconds_to_datetime
1211

1312

1413
class OMModel(Model):

modelitool/weather.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import requests
21
import json
2+
33
import pandas as pd
4+
5+
import requests
6+
47
from .combitabconvert import get_dymo_time_index
58

69
# TODO

requirements/install-min.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pandas>=1.5.0
22
numpy>=1.17.3
3-
OMPython>=3.4.0
4-
corrai>=0.3.0
3+
OMPython>=3.5.2
4+
corrai>=0.3.0

setup.cfg

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[flake8]
2-
max-line-length = 88
3-
extend-ignore = E203,B028
4-
51
[bumpversion]
62
current_version = 0.1.0
73
commit = True
@@ -15,4 +11,4 @@ replace = version="{new_version}"
1511

1612
[bumpversion:file:corrai/__init__.py]
1713
search = __version__ = "{current_version}"
18-
replace = __version__ = "{new_version}"
14+
replace = __version__ = "{new_version}"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
"""Modelitool"""
33

4-
from setuptools import setup, find_packages
4+
from setuptools import find_packages, setup
55

66
# Get the long description from the README file
77
with open("README.md", encoding="utf-8") as f:
@@ -31,7 +31,7 @@
3131
install_requires=[
3232
"pandas>=1.5.0",
3333
"numpy>=1.17.3",
34-
"OMPython>=3.4.0",
34+
"OMPython>=3.5.2",
3535
"corrai>=0.3.0",
3636
],
3737
packages=find_packages(exclude=["tests*"]),

0 commit comments

Comments
 (0)