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
d846082a
Unverified
Commit
d846082a
authored
Dec 09, 2024
by
Jakob Görgen
Browse files
symphony/cli: added clie commands to retreive and delete instantiations
parent
57033c17
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
2 deletions
+69
-2
symphony/cli/simbricks/cli/__main__.py
symphony/cli/simbricks/cli/__main__.py
+2
-1
symphony/cli/simbricks/cli/commands/instantiations.py
symphony/cli/simbricks/cli/commands/instantiations.py
+52
-0
symphony/cli/simbricks/cli/utils.py
symphony/cli/simbricks/cli/utils.py
+10
-0
symphony/client/simbricks/client/client.py
symphony/client/simbricks/client/client.py
+5
-1
No files found.
symphony/cli/simbricks/cli/__main__.py
View file @
d846082a
...
...
@@ -22,7 +22,7 @@
from
typer
import
Typer
,
Option
from
typing_extensions
import
Annotated
from
simbricks.cli.commands
import
audit
,
admin
,
namespaces
,
runs
,
systems
,
simulations
from
simbricks.cli.commands
import
audit
,
admin
,
namespaces
,
runs
,
systems
,
simulations
,
instantiations
from
simbricks.cli.state
import
state
from
simbricks.cli.utils
import
async_cli
...
...
@@ -33,6 +33,7 @@ app.add_typer(audit.app, name="audit")
app
.
add_typer
(
admin
.
app
,
name
=
"admin"
)
app
.
add_typer
(
systems
.
app
,
name
=
"systems"
)
app
.
add_typer
(
simulations
.
app
,
name
=
"sims"
)
app
.
add_typer
(
instantiations
.
app
,
name
=
"insts"
)
@
app
.
callback
()
...
...
symphony/cli/simbricks/cli/commands/instantiations.py
0 → 100644
View file @
d846082a
# Copyright 2024 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from
typer
import
Typer
from
..state
import
state
from
..utils
import
async_cli
from
..utils
import
print_instantiations_table
app
=
Typer
(
help
=
"Managing SimBricks Instantiations."
)
@
app
.
command
()
@
async_cli
()
async
def
ls
():
"""List Instantiations."""
insts
=
await
state
.
simbricks_client
.
get_instantiations
()
print_instantiations_table
(
insts
)
@
app
.
command
()
@
async_cli
()
async
def
show
(
inst_id
:
int
):
"""Show individual Instantiation."""
inst
=
await
state
.
simbricks_client
.
get_instantiation
(
instantiation_id
=
inst_id
)
print_instantiations_table
([
inst
])
@
app
.
command
()
@
async_cli
()
async
def
delete
(
inst_id
:
int
):
"""Delete an individual Instantiation."""
client
=
state
.
simbricks_client
await
client
.
delete_instantiation
(
inst_id
=
inst_id
)
symphony/cli/simbricks/cli/utils.py
View file @
d846082a
...
...
@@ -73,3 +73,13 @@ def print_simulations_table(instantiations):
console
=
Console
()
console
.
print
(
table
)
def
print_instantiations_table
(
instantiations
):
table
=
Table
()
table
.
add_column
(
"Id"
)
table
.
add_column
(
"SimulationId"
)
for
sys
in
instantiations
:
table
.
add_row
(
str
(
sys
[
"id"
]),
str
(
sys
[
"simulation_id"
]))
console
=
Console
()
console
.
print
(
table
)
symphony/client/simbricks/client/client.py
View file @
d846082a
...
...
@@ -292,10 +292,14 @@ class SimBricksClient:
async
with
self
.
_ns_client
.
delete
(
url
=
f
"/instantiations/
{
inst_id
}
"
)
as
resp
:
return
await
resp
.
json
()
async
def
get_instantiation
(
self
,
instantiation_id
:
int
)
->
instantiation
.
Instantiation
:
async
def
get_instantiation
(
self
,
instantiation_id
:
int
)
->
dict
:
async
with
self
.
_ns_client
.
get
(
url
=
f
"/instantiations/
{
instantiation_id
}
"
)
as
resp
:
return
await
resp
.
json
()
async
def
get_instantiations
(
self
)
->
list
[
dict
]:
async
with
self
.
_ns_client
.
get
(
url
=
"/instantiations"
)
as
resp
:
return
await
resp
.
json
()
async
def
create_run
(
self
,
inst_db_id
:
int
)
->
dict
:
json_obj
=
{
"instantiation_id"
:
inst_db_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