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
155eb854
Unverified
Commit
155eb854
authored
Jan 16, 2025
by
Jakob Görgen
Browse files
symphony/client: properly send instantiation to backend when calling create
parent
35a75ec0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
symphony/client/simbricks/client/client.py
symphony/client/simbricks/client/client.py
+8
-5
symphony/client/simbricks/client/opus/base.py
symphony/client/simbricks/client/opus/base.py
+9
-4
No files found.
symphony/client/simbricks/client/client.py
View file @
155eb854
...
...
@@ -24,14 +24,13 @@
import
aiohttp
import
typing
import
contextlib
import
asyncio
import
json
from
simbricks.utils
import
base
as
utils_base
from
rich.console
import
Console
from
.auth
import
TokenProvider
from
.settings
import
client_settings
from
simbricks.orchestration
import
system
from
simbricks.orchestration
import
simulation
from
simbricks.orchestration
import
instantiation
class
BaseClient
:
...
...
@@ -85,6 +84,9 @@ class BaseClient:
await
self
.
_token_provider
.
resource_token
(
ticket
)
async
with
self
.
request
(
meth
,
url
,
data
,
False
,
**
kwargs
)
as
resp
:
yield
resp
elif
resp
.
status
in
[
400
,
402
]:
msg
=
await
resp
.
json
()
raise
Exception
(
f
"Error sending request:
{
msg
}
"
)
else
:
resp
.
raise_for_status
()
# TODO: handel gracefully
yield
resp
...
...
@@ -296,8 +298,8 @@ class SimBricksClient:
async
with
self
.
_ns_client
.
get
(
url
=
"/simulations"
)
as
resp
:
return
await
resp
.
json
()
async
def
create_instantiation
(
self
,
sim_db_id
:
int
,
instantiation
:
simulation
.
Simulation
)
->
simulation
.
Simulation
:
inst_json
=
json
.
dumps
(
{})
# FIXME
async
def
create_instantiation
(
self
,
sim_db_id
:
int
,
instantiation
:
instantiation
.
Instantiation
)
->
dict
:
inst_json
=
json
.
dumps
(
instantiation
.
toJSON
())
json_obj
=
{
"simulation_id"
:
sim_db_id
,
"sb_json"
:
inst_json
}
async
with
self
.
_ns_client
.
post
(
url
=
"/instantiations"
,
json
=
json_obj
)
as
resp
:
return
await
resp
.
json
()
...
...
@@ -539,8 +541,9 @@ class RunnerClient:
"state"
:
state
,
"output"
:
output
,
"id"
:
run_id
,
"instantiation_id"
:
42
,
"instantiation_id"
:
None
,
# TODO: FIXME
}
obj
=
utils_base
.
filter_None_dict
(
to_filter
=
obj
)
async
with
self
.
put
(
url
=
f
"/update_run/
{
run_id
}
"
,
json
=
obj
)
as
resp
:
await
resp
.
json
()
...
...
symphony/client/simbricks/client/opus/base.py
View file @
155eb854
...
...
@@ -88,14 +88,19 @@ async def submit_system(system: system.System) -> int:
async
def
submit_simulation
(
system_id
:
int
,
simulation
:
simulation
.
Simulation
)
->
int
:
simulation
=
await
provider
.
client_provider
.
simbricks_client
.
create_simulation
(
system_id
,
simulation
)
simulation
=
await
provider
.
client_provider
.
simbricks_client
.
create_simulation
(
system_id
,
simulation
)
sim_id
=
int
(
simulation
[
"id"
])
return
sim_id
async
def
submit_instantiation
(
simulation_id
:
int
,
instantiation
:
instantiation
.
Instantiation
)
->
int
:
# TODO: the instantiation itself is currently not used as this is not yet supported
instantiation
=
await
provider
.
client_provider
.
simbricks_client
.
create_instantiation
(
simulation_id
,
None
)
async
def
submit_instantiation
(
simulation_id
:
int
,
instantiation
:
instantiation
.
Instantiation
)
->
int
:
instantiation
=
await
provider
.
client_provider
.
simbricks_client
.
create_instantiation
(
simulation_id
,
instantiation
)
inst_id
=
int
(
instantiation
[
"id"
])
return
inst_id
...
...
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