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
f163d832
Unverified
Commit
f163d832
authored
Dec 21, 2024
by
Jakob Görgen
Browse files
symphony/cli: added runners cli sub-command
parent
b1a2af0c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
2 deletions
+85
-2
symphony/cli/simbricks/cli/__main__.py
symphony/cli/simbricks/cli/__main__.py
+2
-1
symphony/cli/simbricks/cli/commands/runners.py
symphony/cli/simbricks/cli/commands/runners.py
+59
-0
symphony/cli/simbricks/cli/state.py
symphony/cli/simbricks/cli/state.py
+8
-1
symphony/cli/simbricks/cli/utils.py
symphony/cli/simbricks/cli/utils.py
+16
-0
No files found.
symphony/cli/simbricks/cli/__main__.py
View file @
f163d832
...
...
@@ -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
,
instantiations
from
simbricks.cli.commands
import
audit
,
admin
,
namespaces
,
runs
,
systems
,
simulations
,
instantiations
,
runners
from
simbricks.cli.state
import
state
from
simbricks.cli.utils
import
async_cli
...
...
@@ -34,6 +34,7 @@ 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
.
add_typer
(
runners
.
app
,
name
=
"runners"
)
@
app
.
callback
()
...
...
symphony/cli/simbricks/cli/commands/runners.py
0 → 100644
View file @
f163d832
# 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
,
print_runner_table
app
=
Typer
(
help
=
"Managing SimBricks runners."
)
@
app
.
command
()
@
async_cli
()
async
def
ls
():
"""List runners."""
runs
=
await
state
.
runner_client
.
list_runners
()
print_runner_table
(
runs
)
@
app
.
command
()
@
async_cli
()
async
def
show
(
runner_id
:
int
):
"""Show individual runner."""
runner
=
await
state
.
runner_client
.
get_runner
(
runner_id
=
runner_id
)
print_runner_table
([
runner
])
@
app
.
command
()
@
async_cli
()
async
def
delete
(
runner_id
:
int
):
"""Delete an individual runner."""
await
state
.
runner_client
.
delete_runner
(
runner_id
=
runner_id
)
@
app
.
command
()
@
async_cli
()
async
def
create
(
label
:
str
,
tags
:
list
[
str
]):
"""Update a runner with the the given label and tags."""
runner
=
await
state
.
runner_client
.
create_runner
(
label
=
label
,
tags
=
tags
)
print_runner_table
([
runner
])
symphony/cli/simbricks/cli/state.py
View file @
f163d832
...
...
@@ -21,7 +21,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
os
from
simbricks.client
import
BaseClient
,
AdminClient
,
NSClient
,
SimBricksClient
from
simbricks.client
import
BaseClient
,
AdminClient
,
NSClient
,
SimBricksClient
,
RunnerClient
class
State
:
...
...
@@ -31,6 +31,7 @@ class State:
self
.
_admin_client
:
AdminClient
=
None
self
.
_ns_client
:
NSClient
|
None
=
None
self
.
_simbricks_client
:
SimBricksClient
|
None
=
None
self
.
_runner_client
:
RunnerClient
|
None
=
None
@
property
def
base_client
(
self
):
...
...
@@ -56,5 +57,11 @@ class State:
self
.
_simbricks_client
=
SimBricksClient
(
self
.
ns_client
)
return
self
.
_simbricks_client
@
property
def
runner_client
(
self
):
if
self
.
_runner_client
is
None
:
self
.
_runner_client
=
RunnerClient
(
self
.
ns_client
,
id
=-
1
)
return
self
.
_runner_client
state
=
State
()
symphony/cli/simbricks/cli/utils.py
View file @
f163d832
...
...
@@ -74,6 +74,7 @@ def print_simulations_table(instantiations):
console
=
Console
()
console
.
print
(
table
)
def
print_instantiations_table
(
instantiations
):
table
=
Table
()
table
.
add_column
(
"Id"
)
...
...
@@ -83,3 +84,18 @@ def print_instantiations_table(instantiations):
console
=
Console
()
console
.
print
(
table
)
def
print_runner_table
(
runners
):
table
=
Table
()
table
.
add_column
(
"Id"
)
table
.
add_column
(
"Label"
)
table
.
add_column
(
"Tags"
)
for
r
in
runners
:
ts
=
[]
for
t
in
r
[
"tags"
]:
ts
.
append
(
t
[
"label"
])
table
.
add_row
(
str
(
r
[
"id"
]),
str
(
r
[
"label"
]),
","
.
join
(
ts
))
console
=
Console
()
console
.
print
(
table
)
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