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
84117926
Unverified
Commit
84117926
authored
Jan 06, 2025
by
Jakob Görgen
Browse files
symphony/cli: extended runner commands to create,update,retrieve runner events
parent
f1abfde8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
2 deletions
+63
-2
symphony/cli/simbricks/cli/commands/runners.py
symphony/cli/simbricks/cli/commands/runners.py
+51
-2
symphony/cli/simbricks/cli/utils.py
symphony/cli/simbricks/cli/utils.py
+12
-0
No files found.
symphony/cli/simbricks/cli/commands/runners.py
View file @
84117926
...
@@ -20,9 +20,10 @@
...
@@ -20,9 +20,10 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from
typer
import
Typer
from
typer
import
Typer
,
Option
from
typing_extensions
import
Annotated
from
..state
import
state
from
..state
import
state
from
..utils
import
async_cli
,
print_runner_table
from
..utils
import
async_cli
,
print_runner_table
,
print_table_generic
app
=
Typer
(
help
=
"Managing SimBricks runners."
)
app
=
Typer
(
help
=
"Managing SimBricks runners."
)
...
@@ -57,3 +58,51 @@ async def create(label: str, tags: list[str]):
...
@@ -57,3 +58,51 @@ async def create(label: str, tags: list[str]):
"""Update a runner with the the given label and tags."""
"""Update a runner with the the given label and tags."""
runner
=
await
state
.
runner_client
.
create_runner
(
label
=
label
,
tags
=
tags
)
runner
=
await
state
.
runner_client
.
create_runner
(
label
=
label
,
tags
=
tags
)
print_runner_table
([
runner
])
print_runner_table
([
runner
])
@
app
.
command
()
@
async_cli
()
async
def
create_event
(
runner_id
:
int
,
action
:
str
,
run_id
:
Annotated
[
int
|
None
,
Option
(
"--run"
,
"-r"
,
help
=
"Set event for specific run."
)]
=
None
,
):
"""Send a run related event to a runner (Available actions: kill, heartbeat, simulation_status)."""
event
=
await
state
.
runner_client
.
create_runner_event
(
runner_id
=
runner_id
,
action
=
action
,
run_id
=
run_id
)
print_table_generic
([
event
],
"id"
,
"runner_id"
,
"action"
,
"run_id"
,
"event_status"
)
@
app
.
command
()
@
async_cli
()
async
def
update_event
(
runner_id
:
int
,
event_id
:
int
,
action
:
Annotated
[
str
|
None
,
Option
(
"--action"
,
"-a"
,
help
=
"Action to set (kill, heartbeat, simulation_status)."
)
]
=
None
,
event_status
:
Annotated
[
str
|
None
,
Option
(
"--status"
,
"-s"
,
help
=
"Status to set (pending, completed, cancelled)."
)
]
=
None
,
run_id
:
Annotated
[
int
|
None
,
Option
(
"--run"
,
"-r"
,
help
=
"Run to set."
)]
=
None
,
):
"""Update a runner event."""
event
=
await
state
.
runner_client
.
update_runner_event
(
runner_id
=
runner_id
,
event_id
=
event_id
,
action
=
action
,
event_status
=
event_status
,
run_id
=
run_id
)
print_table_generic
([
event
],
"id"
,
"runner_id"
,
"action"
,
"run_id"
,
"event_status"
)
@
app
.
command
()
@
async_cli
()
async
def
ls_events
(
runner_id
:
int
,
action
:
Annotated
[
str
|
None
,
Option
(
"--action"
,
"-a"
,
help
=
"Filter for action."
)]
=
None
,
event_status
:
Annotated
[
str
|
None
,
Option
(
"--status"
,
"-s"
,
help
=
"Filter for status."
)]
=
None
,
run_id
:
Annotated
[
int
|
None
,
Option
(
"--run"
,
"-r"
,
help
=
"Filter for run."
)]
=
None
,
limit
:
Annotated
[
int
|
None
,
Option
(
"--limit"
,
"-l"
,
help
=
"Limit results."
)]
=
None
,
):
"""List runner related events"""
events
=
await
state
.
runner_client
.
get_events
(
runner_id
=
runner_id
,
action
=
action
,
run_id
=
run_id
,
event_status
=
event_status
,
limit
=
limit
)
print_table_generic
(
events
,
"id"
,
"runner_id"
,
"action"
,
"run_id"
,
"event_status"
)
symphony/cli/simbricks/cli/utils.py
View file @
84117926
...
@@ -41,6 +41,18 @@ def async_cli():
...
@@ -41,6 +41,18 @@ def async_cli():
return
decorator_async_cli
return
decorator_async_cli
def
print_table_generic
(
to_print
,
*
args
):
table
=
Table
()
for
key
in
args
:
table
.
add_column
(
key
)
for
val
in
to_print
:
row
=
[
str
(
val
[
key
])
for
key
in
args
]
table
.
add_row
(
*
row
)
console
=
Console
()
console
.
print
(
table
)
def
print_namespace_table
(
namespaces
)
->
None
:
def
print_namespace_table
(
namespaces
)
->
None
:
table
=
Table
()
table
=
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