Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
73 changes: 73 additions & 0 deletions .github/workflows/Test_v400.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test-v4.0.0

on:
workflow_dispatch:

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
# test for:
# * oldest supported version
# * latest available Python version
python-version: ['3.10', '3.14']
# * Linux using ubuntu-latest
# * Windows using windows-latest
os: ['ubuntu-latest', 'windows-latest']
# * OM stable - latest stable version
# * OM nightly - latest nightly build
omc-version: ['stable', 'nightly']

steps:
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'

- name: Install dependencies
run: |
python -m pip install --upgrade pip build setuptools wheel twine
pip install . pytest pytest-md pytest-emoji pre-commit

- name: Set timezone
uses: szenius/set-timezone@v2.0
with:
timezoneLinux: 'Europe/Berlin'

- name: Run pre-commit linters
run: 'pre-commit run --all-files'

- name: "Set up OpenModelica Compiler"
uses: OpenModelica/setup-openmodelica@v1.0.6
with:
version: ${{ matrix.omc-version }}
packages: |
omc
libraries: |
'Modelica 4.0.0'
- run: "omc --version"

- name: Pull OpenModelica docker image
if: runner.os != 'Windows'
run: docker pull openmodelica/openmodelica:v1.25.0-minimal

- name: Build wheel and sdist packages
run: python -m build --wheel --sdist --outdir dist

- name: Check twine
run: python -m twine check dist/*

- name: Run pytest
uses: pavelzw/pytest-action@v2
with:
verbose: true
emoji: true
job-summary: true
custom-arguments: '-v ./tests_v400'
click-to-expand: true
report-title: 'Test Report'
70 changes: 70 additions & 0 deletions .github/workflows/Test_v400_py310.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Test-v4.0.0-py310

on:
workflow_dispatch:

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
# test for:
# * oldest supported version
python-version: ['3.10']
# * Linux using ubuntu-latest
os: ['ubuntu-latest']
# * OM stable - latest stable version
omc-version: ['stable']

steps:
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'

- name: Install dependencies
run: |
python -m pip install --upgrade pip build setuptools wheel twine
pip install . pytest pytest-md pytest-emoji pre-commit

- name: Set timezone
uses: szenius/set-timezone@v2.0
with:
timezoneLinux: 'Europe/Berlin'

- name: Run pre-commit linters
run: 'pre-commit run --all-files'

- name: "Set up OpenModelica Compiler"
uses: OpenModelica/setup-openmodelica@v1.0.6
with:
version: ${{ matrix.omc-version }}
packages: |
omc
libraries: |
'Modelica 4.0.0'
- run: "omc --version"

- name: Pull OpenModelica docker image
if: runner.os != 'Windows'
run: docker pull openmodelica/openmodelica:v1.25.0-minimal

- name: Build wheel and sdist packages
run: python -m build --wheel --sdist --outdir dist

- name: Check twine
run: python -m twine check dist/*

- name: Run pytest
uses: pavelzw/pytest-action@v2
with:
verbose: true
emoji: true
job-summary: true
custom-arguments: '-v ./tests_v400'
click-to-expand: true
report-title: 'Test Report'
73 changes: 73 additions & 0 deletions .github/workflows/Test_v4xx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test-v4.x.x

on:
workflow_dispatch:

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
# test for:
# * oldest supported version
# * latest available Python version
python-version: ['3.10', '3.14']
# * Linux using ubuntu-latest
# * Windows using windows-latest
os: ['ubuntu-latest', 'windows-latest']
# * OM stable - latest stable version
# * OM nightly - latest nightly build
omc-version: ['stable', 'nightly']

steps:
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'

- name: Install dependencies
run: |
python -m pip install --upgrade pip build setuptools wheel twine
pip install . pytest pytest-md pytest-emoji pre-commit

- name: Set timezone
uses: szenius/set-timezone@v2.0
with:
timezoneLinux: 'Europe/Berlin'

- name: Run pre-commit linters
run: 'pre-commit run --all-files'

- name: "Set up OpenModelica Compiler"
uses: OpenModelica/setup-openmodelica@v1.0.6
with:
version: ${{ matrix.omc-version }}
packages: |
omc
libraries: |
'Modelica 4.0.0'
- run: "omc --version"

- name: Pull OpenModelica docker image
if: runner.os != 'Windows'
run: docker pull openmodelica/openmodelica:v1.25.0-minimal

- name: Build wheel and sdist packages
run: python -m build --wheel --sdist --outdir dist

- name: Check twine
run: python -m twine check dist/*

- name: Run pytest
uses: pavelzw/pytest-action@v2
with:
verbose: true
emoji: true
job-summary: true
custom-arguments: '-v ./tests'
click-to-expand: true
report-title: 'Test Report'
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
hooks:
- id: mypy
args: []
exclude: tests/
exclude: 'test|test_v400'
additional_dependencies:
- pyparsing
- types-psutil
Expand Down
2 changes: 2 additions & 0 deletions OMPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
OMPathABC,
OMCPath,

OMSessionABC,
OMSessionRunner,

OMCSessionABC,
Expand Down Expand Up @@ -77,6 +78,7 @@
'OMPathABC',
'OMCPath',

'OMSessionABC',
'OMSessionRunner',

'OMCSessionABC',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_FMIExport.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import shutil
import os
import pathlib
import shutil

import OMPython

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def mscmd_firstorder(model_firstorder):
cmd_local=mod.get_session().model_execution_local,
cmd_windows=mod.get_session().model_execution_windows,
cmd_prefix=mod.get_session().model_execution_prefix(cwd=mod.getWorkDirectory()),
model_name=mod._model_name,
model_name=mod.get_model_name(),
)

return mscmd
Expand Down
6 changes: 3 additions & 3 deletions tests/test_ModelicaDoEOMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ def _run_ModelicaDoEOMC(doe_mod):
f"y[{row['p']}]": float(row['b']),
}

for var in var_dict:
assert var in sol['data']
assert np.isclose(sol['data'][var][-1], var_dict[var])
for key, val in var_dict.items():
assert key in sol['data']
assert np.isclose(sol['data'][key][-1], val)
6 changes: 3 additions & 3 deletions tests/test_ModelicaDoERunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,6 @@ def _check_runner_result(mod, doe_mod):
'b': float(row['b']),
}

for var in var_dict:
assert var in sol['data']
assert np.isclose(sol['data'][var][-1], var_dict[var])
for key, val in var_dict.items():
assert key in sol['data']
assert np.isclose(sol['data'][key][-1], val)
2 changes: 1 addition & 1 deletion tests/test_ModelicaSystemOMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def test_simulate_inputs(tmp_path):
}
mod.setInputs(**inputs)
csv_file = mod._createCSVData()
assert pathlib.Path(csv_file).read_text() == """time,u1,u2,end
assert pathlib.Path(csv_file).read_text(encoding='utf-8') == """time,u1,u2,end
0.0,0.0,0.0,0
0.25,0.25,0.5,0
0.5,0.5,1.0,0
Expand Down
Loading
Loading