Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
3423cf0f
Commit
3423cf0f
authored
Jan 16, 2025
by
Jonas Kaufmann
Browse files
symphony/runtime/simulation_executor.py: add separate callbacks for simulator prepare commands
parent
c2a47003
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
1 deletion
+52
-1
symphony/runtime/simbricks/runtime/command_executor.py
symphony/runtime/simbricks/runtime/command_executor.py
+17
-1
symphony/runtime/simbricks/runtime/runs/local.py
symphony/runtime/simbricks/runtime/runs/local.py
+23
-0
symphony/runtime/simbricks/runtime/simulation_executor.py
symphony/runtime/simbricks/runtime/simulation_executor.py
+12
-0
No files found.
symphony/runtime/simbricks/runtime/command_executor.py
View file @
3423cf0f
...
...
@@ -207,7 +207,23 @@ class CommandExecutorFactory:
async
def
exec_simulator_prepare_cmds
(
self
,
sim
:
sim_base
.
Simulator
,
cmds
:
list
[
str
])
->
None
:
for
cmd
in
cmds
:
executor
=
await
self
.
start_simulator
(
sim
,
cmd
)
async
def
started_cb
()
->
None
:
await
self
.
_sim_exec_cbs
.
simulator_prepare_started
(
sim
,
cmd
)
async
def
exited_cb
(
exit_code
:
int
)
->
None
:
await
self
.
_sim_exec_cbs
.
simulator_prepare_exited
(
sim
,
exit_code
)
async
def
stdout_cb
(
lines
:
list
[
str
])
->
None
:
await
self
.
_sim_exec_cbs
.
simulator_prepare_stdout
(
sim
,
lines
)
async
def
stderr_cb
(
lines
:
list
[
str
])
->
None
:
await
self
.
_sim_exec_cbs
.
simulator_prepare_stderr
(
sim
,
lines
)
executor
=
CommandExecutor
(
cmd
,
sim
.
full_name
(),
started_cb
,
exited_cb
,
stdout_cb
,
stderr_cb
)
await
executor
.
start
()
await
executor
.
wait
()
async
def
start_simulator
(
self
,
sim
:
sim_base
.
Simulator
,
cmd
)
->
CommandExecutor
:
...
...
symphony/runtime/simbricks/runtime/runs/local.py
View file @
3423cf0f
...
...
@@ -67,6 +67,29 @@ class LocalSimulationExecutorCallbacks(sim_exec.SimulationExecutorCallbacks):
# Simulator-related callbacks -
# -----------------------------
async
def
simulator_prepare_started
(
self
,
sim
:
sim_base
.
Simulator
,
cmd
:
str
)
->
None
:
await
super
().
simulator_prepare_started
(
sim
,
cmd
)
self
.
_output
.
set_simulator_cmd
(
sim
,
cmd
)
if
self
.
_verbose
:
print
(
f
"+ [
{
sim
.
full_name
()
}
]
{
cmd
}
"
)
async
def
simulator_prepare_exited
(
self
,
sim
:
sim_base
.
Simulator
,
exit_code
:
int
)
->
None
:
await
super
().
simulator_prepare_exited
(
sim
,
exit_code
)
if
self
.
_verbose
:
print
(
f
"- [
{
sim
.
full_name
()
}
] exited with code
{
exit_code
}
"
)
async
def
simulator_prepare_stdout
(
self
,
sim
:
sim_base
.
Simulator
,
lines
:
list
[
str
])
->
None
:
await
super
().
simulator_prepare_stdout
(
sim
,
lines
)
if
self
.
_verbose
:
for
line
in
lines
:
print
(
f
"[
{
sim
.
full_name
()
}
]
{
line
}
"
)
async
def
simulator_prepare_stderr
(
self
,
sim
:
sim_base
.
Simulator
,
lines
:
list
[
str
])
->
None
:
await
super
().
simulator_prepare_stderr
(
sim
,
lines
)
if
self
.
_verbose
:
for
line
in
lines
:
print
(
f
"[
{
sim
.
full_name
()
}
]
{
line
}
"
)
async
def
simulator_started
(
self
,
sim
:
sim_base
.
Simulator
,
cmd
:
str
)
->
None
:
await
super
().
simulator_started
(
sim
,
cmd
)
if
self
.
_verbose
:
...
...
symphony/runtime/simbricks/runtime/simulation_executor.py
View file @
3423cf0f
...
...
@@ -74,6 +74,18 @@ class SimulationExecutorCallbacks:
# Simulator-related callbacks -
# -----------------------------
async
def
simulator_prepare_started
(
self
,
sim
:
sim_base
.
Simulator
,
cmd
:
str
)
->
None
:
self
.
_output
.
set_simulator_cmd
(
sim
,
cmd
)
async
def
simulator_prepare_exited
(
self
,
sim
:
sim_base
.
Simulator
,
exit_code
:
int
)
->
None
:
pass
async
def
simulator_prepare_stdout
(
self
,
sim
:
sim_base
.
Simulator
,
lines
:
list
[
str
])
->
None
:
self
.
_output
.
append_simulator_stdout
(
sim
,
lines
)
async
def
simulator_prepare_stderr
(
self
,
sim
:
sim_base
.
Simulator
,
lines
:
list
[
str
])
->
None
:
self
.
_output
.
append_simulator_stderr
(
sim
,
lines
)
async
def
simulator_started
(
self
,
sim
:
sim_base
.
Simulator
,
cmd
:
str
)
->
None
:
self
.
_output
.
set_simulator_cmd
(
sim
,
cmd
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment