Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OptiOrch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zizhe Wang
OptiOrch
Commits
e330711b
Commit
e330711b
authored
10 months ago
by
Zizhe Wang
Browse files
Options
Downloads
Patches
Plain Diff
feat load libraries in orchestration workflow
parent
af50fdae
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/orchestration_config.json
+6
-0
6 additions, 0 deletions
src/orchestration_config.json
src/orchestration_wrapper.py
+16
-0
16 additions, 0 deletions
src/orchestration_wrapper.py
with
22 additions
and
0 deletions
src/orchestration_config.json
+
6
−
0
View file @
e330711b
...
...
@@ -45,5 +45,11 @@
"PLOT_TITLE"
:
""
,
"ENABLE_PLOT"
:
false
},
"LIBRARY_CONFIG"
:
{
"LOAD_LIBRARIES"
:
true
,
"LIBRARIES"
:
[
{
"name"
:
"PNlib-3.0.0"
,
"path"
:
"PNlib-3.0.0/PNlib/package.mo"
}
]
},
"N_JOBS"
:
-1
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/orchestration_wrapper.py
+
16
−
0
View file @
e330711b
...
...
@@ -4,6 +4,7 @@
import
json
import
os
from
optimize_main
import
run_optimization
from
OMPython
import
OMCSessionZMQ
class
MOO4ModelicaWrapper
:
def
__init__
(
self
,
orchestration_config_path
,
config_path
):
...
...
@@ -11,6 +12,8 @@ class MOO4ModelicaWrapper:
self
.
config_path
=
config_path
self
.
load_configs
()
self
.
update_config_file
()
self
.
omc
=
OMCSessionZMQ
()
self
.
load_libraries
()
def
load_configs
(
self
):
with
open
(
self
.
orchestration_config_path
,
'
r
'
)
as
f
:
...
...
@@ -29,6 +32,7 @@ class MOO4ModelicaWrapper:
self
.
config
[
'
OBJECTIVES
'
]
=
self
.
orchestration_config
[
'
OBJECTIVES
'
]
self
.
config
[
'
PLOT_CONFIG
'
]
=
self
.
orchestration_config
[
'
PLOT_CONFIG
'
]
self
.
config
[
'
N_JOBS
'
]
=
self
.
orchestration_config
[
'
N_JOBS
'
]
self
.
config
[
'
LIBRARY_CONFIG
'
]
=
self
.
orchestration_config
[
'
LIBRARY_CONFIG
'
]
for
key
,
value
in
self
.
orchestration_config
[
'
OPTIMIZATION_CONFIG
'
].
items
():
self
.
config
[
'
OPTIMIZATION_CONFIG
'
][
key
]
=
value
...
...
@@ -45,6 +49,18 @@ class MOO4ModelicaWrapper:
with
open
(
self
.
config_path
,
'
w
'
)
as
f
:
json
.
dump
(
self
.
config
,
f
,
indent
=
4
)
def
load_libraries
(
self
):
if
self
.
orchestration_config
[
'
LIBRARY_CONFIG
'
][
'
LOAD_LIBRARIES
'
]:
for
lib
in
self
.
orchestration_config
[
'
LIBRARY_CONFIG
'
][
'
LIBRARIES
'
]:
library_path
=
os
.
path
.
join
(
os
.
getcwd
(),
'
models
'
,
lib
[
'
path
'
]).
replace
(
'
\\
'
,
'
/
'
)
print
(
f
"
Loading library:
{
lib
[
'
name
'
]
}
from
{
library_path
}
"
)
load_library_result
=
self
.
omc
.
sendExpression
(
f
'
loadFile(
"
{
library_path
}
"
)
'
)
print
(
f
"
Load library result:
{
load_library_result
}
"
)
if
load_library_result
is
not
True
:
messages
=
self
.
omc
.
sendExpression
(
"
getErrorString()
"
)
print
(
f
"
OpenModelica error messages:
{
messages
}
"
)
raise
RuntimeError
(
f
"
Failed to load library:
{
lib
[
'
name
'
]
}
"
)
def
run_optimization
(
self
):
run_optimization
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment