Skip to content

Commit 0e573be

Browse files
authored
Basemodelica import (#226)
* Revert "Revert basemodelica.jl import (#225)" - Make module juliacall optional - Use shutil.which
1 parent a0cb54d commit 0e573be

21 files changed

+2955
-18
lines changed

.CI/Jenkinsfile

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ pipeline {
1919
booleanParam(name: 'newInst_newBackend', defaultValue: false, description: 'master branch, -d=newInst --newBackend, (ryzen-5950x-1)')
2020
booleanParam(name: 'oldInst', defaultValue: false, description: 'master branch, with -d=nonewInst (ryzen-5950x-2)')
2121

22-
booleanParam(name: 'cpp_v1_24', defaultValue: false, description: 'maintenance/v1.24 branch, with --simCodeTarget=Cpp (ryzen-5950x-2).')
22+
booleanParam(name: 'cpp_v1_24', defaultValue: false, description: 'maintenance/v1.24 branch, with --simCodeTarget=Cpp (ryzen-5950x-2).')
2323
booleanParam(name: 'cpp_v1_25', defaultValue: false, description: 'maintenance/v1.25 branch, with --simCodeTarget=Cpp (ryzen-5950x-2).')
2424
booleanParam(name: 'cpp', defaultValue: false, description: 'master branch, with --simCodeTarget=Cpp (ryzen-5950x-2).')
2525
booleanParam(name: 'report_ryzen_5950x_1', defaultValue: false, description: 'Generate a report for ryzen-5950x-1 without running the tests')
2626
booleanParam(name: 'report_ryzen_5950x_2', defaultValue: false, description: 'Generate a report for ryzen-5950x-2 without running the tests')
2727

28+
booleanParam(name: 'basemodelica_jl_master', defaultValue: false, description: 'OpenModelica master branch with BaseModelica export and BaseModelica.jl import (ryzen-5950x-1)')
29+
2830
booleanParam(name: 'conversion_script', defaultValue: false, description: 'master branch with conversion script from MSL 3 to 4 (ryzen-5950x-1). This is an experimental job that does not run on a fixed schedule.')
2931
booleanParam(name: 'cvode', defaultValue: false, description: 'master branch, with -d=newInst and -s cvode (ryzen-5950x-2). This is an experimental job that does not run on a fixed schedule.')
3032
booleanParam(name: 'gbode', defaultValue: false, description: 'master branch, with -d=newInst and -s gbode (ryzen-5950x-2). This is an experimental job that does not run on a fixed schedule.')
@@ -220,6 +222,24 @@ pipeline {
220222
runRegressiontest('master', 'master-fmi-fmpy', '', 'origin/master', 'ripper2', 'LibraryTestingRipper2DB', false, '', false, false)
221223
}
222224
}
225+
226+
stage('master BaseModelica.jl import') {
227+
agent {
228+
node {
229+
label 'ryzen-5950x-1'
230+
customWorkspace 'ws/OpenModelicaLibraryTestingWork'
231+
}
232+
}
233+
options { skipDefaultCheckout() }
234+
when {
235+
beforeAgent true
236+
expression { params.basemodelica_jl_master }
237+
}
238+
steps {
239+
runRegressiontest('master', 'basemodelica_jl_master', '--basemodelica-mtk-import', 'origin/master', 'ripper1', 'LibraryTestingRipper1DB', false, '', false, false)
240+
}
241+
}
242+
223243
stage('newInst-daeMode') {
224244
agent {
225245
node {
@@ -581,6 +601,7 @@ def runRegressiontest(branch, name, extraFlags, omsHash, dbPrefix, sshConfig, om
581601
fi
582602
'''
583603
FMI_TESTING_FLAG=""
604+
JULIA_TESTTING_FLAG=""
584605
if (!name.contains('fmpy') && omsHash) {
585606
sh """
586607
if ! test -d OMSimulator; then
@@ -615,7 +636,7 @@ def runRegressiontest(branch, name, extraFlags, omsHash, dbPrefix, sshConfig, om
615636
"""
616637
FMI_TESTING_FLAG="--fmi=true --fmisimulator=${env.HOME}/saved_omc/OMSimulator/install/bin/OMSimulator --default=ulimitExe=50"
617638
}
618-
639+
619640
if (name.contains('fmpy')) {
620641
sh """
621642
# update fmpy
@@ -625,6 +646,13 @@ def runRegressiontest(branch, name, extraFlags, omsHash, dbPrefix, sshConfig, om
625646
FMI_TESTING_FLAG="--fmi=true --fmisimulator='python3 -m fmpy' --default=ulimitExe=50"
626647
}
627648

649+
if (name.contains('basemodelica-mtk-import')) {
650+
sh """
651+
julia --project=TestBaseModelica -e 'import Pkg; Pkg.build(verbose=true); Pkg.precompile()'
652+
"""
653+
JULIA_TESTTING_FLAG="--basemodelica-mtk-import --extraflags=\"setCommandLineOptions(\\\"--baseModelica\\\");\""
654+
}
655+
628656
OMCPATH = "${omcompiler ? '../' : './'}OMCompiler"
629657

630658
sh '''
@@ -774,7 +802,7 @@ def runRegressiontest(branch, name, extraFlags, omsHash, dbPrefix, sshConfig, om
774802
775803
cd OpenModelicaLibraryTesting
776804
# Force /usr/bin/omc as being used for generating the mos-files. Ensures consistent behavior among all tested OMC versions
777-
stdbuf -oL -eL time ./test.py --ompython_omhome=/usr ${FMI_TESTING_FLAG} --extraflags='${extraFlags}' --extrasimflags='${extrasimflags}' --branch="${name}" --output="libraries.openmodelica.org:/var/www/libraries.openmodelica.org/branches/${name}/" --libraries='${libraryPath}/.openmodelica/libraries/' --jobs=${jobs} ${libs_config_file} ${params.OLDLIBS ? "configs/conf-old.json configs/conf-nonstandard.json" : ""} || (killall omc ; false) || exit 1
805+
stdbuf -oL -eL time ./test.py --ompython_omhome=/usr ${FMI_TESTING_FLAG} ${JULIA_TESTTING_FLAG} --extraflags='${extraFlags}' --extrasimflags='${extrasimflags}' --branch="${name}" --output="libraries.openmodelica.org:/var/www/libraries.openmodelica.org/branches/${name}/" --libraries='${libraryPath}/.openmodelica/libraries/' --jobs=${jobs} ${libs_config_file} ${params.OLDLIBS ? "configs/conf-old.json configs/conf-nonstandard.json" : ""} || (killall omc ; false) || exit 1
778806
"""
779807
sh 'date'
780808
sh "rm -f OpenModelicaLibraryTesting/${dbPrefix}-sqlite3.db.tmp"
@@ -783,5 +811,5 @@ def runRegressiontest(branch, name, extraFlags, omsHash, dbPrefix, sshConfig, om
783811
sh "cp OpenModelicaLibraryTesting/sqlite3.db ~/TEST_LIBS_BACKUP/${dbPrefix}-sqlite3.db"
784812
sh "rm -f ~/TEST_LIBS_BACKUP/${dbPrefix}-`date +sqlite3.%Y%m%d.db`"
785813

786-
sshPublisher(publishers: [sshPublisherDesc(configName: sshConfig, transfers: [sshTransfer(removePrefix: 'OpenModelicaLibraryTesting', sourceFiles: 'OpenModelicaLibraryTesting/sqlite3.db')])], failOnError: true)
814+
sshPublisher(publishers: [sshPublisherDesc(configName: sshConfig, transfers: [sshTransfer(removePrefix: 'OpenModelicaLibraryTesting', sourceFiles: 'OpenModelicaLibraryTesting/sqlite3.db')])], failOnError: true)
787815
}

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
with:
5050
python-version: ${{ matrix.python-version }}
5151
cache: 'pip' # caching pip dependencies
52+
5253
- name: Install Python dependencies
5354
shell: bash
5455
run: |

.github/workflows/test_julia.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Continuous Integration BaseModelica.jl
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
tags: '*'
9+
10+
jobs:
11+
unittest-testbasemodelica:
12+
name: Unit test TestBaseModelica.jl
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest]
16+
julia-version: [1.11]
17+
fail-fast: false
18+
runs-on: ${{ matrix.os }}
19+
timeout-minutes: 60
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Julia
26+
uses: julia-actions/setup-julia@latest
27+
with:
28+
version: ${{ matrix.julia-version }}
29+
30+
- name: Cache Julia
31+
uses: julia-actions/cache@v2
32+
33+
- name: Build TestBaseModelica
34+
uses: julia-actions/julia-buildpkg@v1
35+
with:
36+
project: TestBaseModelica
37+
38+
- name: Test TestBaseModelica
39+
uses: julia-actions/julia-runtest@v1
40+
with:
41+
project: TestBaseModelica
42+
43+
test-mtk-import:
44+
name: Sanity check TestBaseModelica.jl + test.py
45+
strategy:
46+
matrix:
47+
os: [ubuntu-latest]
48+
julia-version: [1.11]
49+
omc-version: [stable]
50+
python-version: ['3.10']
51+
fail-fast: false
52+
runs-on: ${{ matrix.os }}
53+
timeout-minutes: 60
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Setup Julia
60+
uses: julia-actions/setup-julia@latest
61+
with:
62+
version: ${{ matrix.julia-version }}
63+
64+
- name: Cache Julia
65+
uses: julia-actions/cache@v2
66+
67+
- name: Setup OpenModelica
68+
uses: OpenModelica/setup-openmodelica@v1
69+
with:
70+
version: ${{ matrix.omc-version }}
71+
packages: |
72+
'omc'
73+
libraries: |
74+
'Modelica 4.0.0'
75+
omc-diff: true
76+
77+
- name: Check if .CI/installLibraries.mos works
78+
shell: bash
79+
run: |
80+
if [ "$RUNNER_OS" == "Linux" ]; then
81+
omc .CI/installLibraries.mos
82+
fi
83+
84+
- name: Setup Python3
85+
uses: actions/setup-python@v5
86+
with:
87+
python-version: ${{ matrix.python-version }}
88+
cache: 'pip' # caching pip dependencies
89+
90+
- name: Install Python dependencies
91+
shell: bash
92+
run: |
93+
pip install -r requirements.txt
94+
95+
- name: Run library test
96+
shell: bash
97+
run: |
98+
export MY_SANITY_CHECK_DIRECTORY=sanityCheck
99+
python test.py --branch="${{ matrix.omc-version }}" --basemodelica-mtk-import --no-julia-sys-image --noclean --verbose configs/sanityCheck.json
100+
101+
- name: Generate HTML results
102+
shell: bash
103+
run: python report.py --branches="${{ matrix.omc-version }}" configs/sanityCheck.json
104+
105+
- name: Zip HTML results
106+
shell: bash
107+
run: |
108+
python .github/scripts/archiveResults.py "MyLibrary" "1.0.0" "${{ matrix.omc-version }}" "html/"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
__pycache__
22
!HelloWorld.mo
33
!HelloWorld.mos
4+
/.venv/
5+
/.vscode/
46
/*.files
57
/*.html
68
/*.json

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,17 @@ export MSLREFERENCE="/some/path/to/ReferenceFiles/"
175175
```
176176
177177
For the other libraries just clone the repositories to `/some/path/to/ReferenceFiles/`.
178+
179+
## Examples
180+
181+
### BaseModelica export and BaseModelica.jl import
182+
183+
```bash
184+
export MY_SANITY_CHECK_DIRECTORY=sanityCheck
185+
./test.py --basemodelica-mtk-import --branch=master --noclean --verbose configs/sanityCheck.json
186+
./report.py --branches="${{ matrix.omc-version }}" configs/sanityCheck.json
187+
```
188+
189+
This will create a Julia system image to speedup tests. This can take a lot of
190+
time, but will reduce the Julia startup penalty. To disable add
191+
`--no-julia-sys-image`.

0 commit comments

Comments
 (0)