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
801523fc
Unverified
Commit
801523fc
authored
Dec 11, 2024
by
Marvin Meiers
Browse files
symphony: send simulator ouput lines to backend
parent
b41d6b88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
5 deletions
+33
-5
symphony/client/simbricks/client/client.py
symphony/client/simbricks/client/client.py
+20
-0
symphony/runner/simbricks/runner/__main__.py
symphony/runner/simbricks/runner/__main__.py
+13
-5
No files found.
symphony/client/simbricks/client/client.py
View file @
801523fc
...
@@ -428,3 +428,23 @@ class RunnerClient:
...
@@ -428,3 +428,23 @@ class RunnerClient:
}
}
async
with
self
.
put
(
url
=
f
"/update_run/
{
run_id
}
"
,
json
=
obj
)
as
resp
:
async
with
self
.
put
(
url
=
f
"/update_run/
{
run_id
}
"
,
json
=
obj
)
as
resp
:
ret
=
await
resp
.
json
()
ret
=
await
resp
.
json
()
async
def
send_out
(
self
,
run_id
:
int
,
simulator
:
str
,
stderr
:
bool
,
output
:
list
[
str
],
)
->
None
:
objs
=
[]
for
line
in
output
:
obj
=
{
"run_id"
:
run_id
,
"simulator"
:
simulator
,
"stderr"
:
stderr
,
"output"
:
line
,
}
objs
.
append
[
obj
]
async
with
self
.
post
(
url
=
f
"/
{
run_id
}
/console"
,
json
=
objs
)
as
resp
:
ret
=
await
resp
.
json
()
symphony/runner/simbricks/runner/__main__.py
View file @
801523fc
...
@@ -37,17 +37,25 @@ verbose = True
...
@@ -37,17 +37,25 @@ verbose = True
# TODO: FIXME, create a custom listener for the runner to register + create backend endpoint to update the output etc.
# TODO: FIXME, create a custom listener for the runner to register + create backend endpoint to update the output etc.
async
def
periodically_update
(
rc
:
client
.
RunnerClient
,
run_id
:
int
,
async
def
periodically_update
(
rc
:
client
.
RunnerClient
,
run_id
:
int
,
listeners
:
list
[
command_executor
.
LegacyOutputListe
ner
])
->
None
:
listeners
:
list
[
tuple
[
str
,
simulation_executor
.
SimulationSimpleRun
ner
]
]
)
->
None
:
try
:
try
:
while
True
:
while
True
:
all_out
:
list
[
str
]
=
[]
all_out
:
list
[
str
]
=
[]
sim_outs
:
list
[
tuple
[
str
,
bool
,
str
]]
=
[]
for
listener
in
listeners
:
for
listener
in
listeners
:
all_out
.
extend
(
listener
.
merged_output
)
all_out
.
extend
(
listener
[
1
].
merged_output
)
listener
.
merged_output
=
[]
listener
[
1
].
merged_output
=
[]
sim_outs
.
append
((
listener
[
0
],
False
,
listener
[
1
].
stdout
))
sim_outs
.
append
((
listener
[
0
],
True
,
listener
[
1
].
stderr
))
listener
[
1
].
stdout
=
[]
listener
[
1
].
stderr
=
[]
if
len
(
all_out
)
>
0
:
if
len
(
all_out
)
>
0
:
print
(
all_out
)
#
print(all_out)
await
rc
.
update_run
(
run_id
,
"running"
,
json
.
dumps
(
all_out
))
await
rc
.
update_run
(
run_id
,
"running"
,
json
.
dumps
(
all_out
))
for
sim_out
in
sim_outs
:
await
rc
.
send_out
(
run_id
,
sim_out
[
0
],
sim_out
[
1
],
sim_out
[
2
])
await
asyncio
.
sleep
(
0.5
)
await
asyncio
.
sleep
(
0.5
)
...
@@ -66,7 +74,7 @@ async def run_instantiation(sc: client.SimBricksClient, rc: client.RunnerClient,
...
@@ -66,7 +74,7 @@ async def run_instantiation(sc: client.SimBricksClient, rc: client.RunnerClient,
for
sim
in
inst
.
simulation
.
all_simulators
():
for
sim
in
inst
.
simulation
.
all_simulators
():
listener
=
command_executor
.
LegacyOutputListener
()
listener
=
command_executor
.
LegacyOutputListener
()
runner
.
add_listener
(
sim
,
listener
)
runner
.
add_listener
(
sim
,
listener
)
listeners
.
append
(
listener
)
listeners
.
append
(
(
sim
.
name
,
listener
)
)
update_task
=
asyncio
.
create_task
(
periodically_update
(
rc
=
rc
,
run_id
=
run_id
,
listeners
=
listeners
))
update_task
=
asyncio
.
create_task
(
periodically_update
(
rc
=
rc
,
run_id
=
run_id
,
listeners
=
listeners
))
output
=
await
runner
.
run
()
output
=
await
runner
.
run
()
...
...
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