Unverified Commit ae8dadcd authored by Jakob Görgen's avatar Jakob Görgen
Browse files

symphony/cli: added new commands to deal with runner events + fixed runs commands

parent 01914061
...@@ -63,22 +63,27 @@ async def create(label: str, tags: list[str]): ...@@ -63,22 +63,27 @@ async def create(label: str, tags: list[str]):
@app.command() @app.command()
@async_cli() @async_cli()
async def create_event( async def create_event(
runner_id: int,
action: str, action: str,
run_id: Annotated[int | None, Option("--run", "-r", help="Set event for specific run.")] = None, 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).""" """Send a run related event to a runner (Available actions: kill, heartbeat, simulation_status, start_run)."""
event = await state.runner_client.create_runner_event(runner_id=runner_id, action=action, run_id=run_id) event = await state.runner_client.create_runner_event(action=action, run_id=run_id)
print_table_generic([event], "id", "runner_id", "action", "run_id", "event_status") print_table_generic("Event", [event], "id", "runner_id", "action", "run_id", "event_status")
@app.command()
@async_cli()
async def delete_event(event_id: int):
"""Delete a runner event."""
await state.runner_client.delete_runner_event(event_id=event_id)
@app.command() @app.command()
@async_cli() @async_cli()
async def update_event( async def update_event(
runner_id: int,
event_id: int, event_id: int,
action: Annotated[ action: Annotated[
str | None, Option("--action", "-a", help="Action to set (kill, heartbeat, simulation_status).") str | None, Option("--action", "-a", help="Action to set (kill, heartbeat, simulation_status, start_run).")
] = None, ] = None,
event_status: Annotated[ event_status: Annotated[
str | None, Option("--status", "-s", help="Status to set (pending, completed, cancelled).") str | None, Option("--status", "-s", help="Status to set (pending, completed, cancelled).")
...@@ -87,22 +92,19 @@ async def update_event( ...@@ -87,22 +92,19 @@ async def update_event(
): ):
"""Update a runner event.""" """Update a runner event."""
event = await state.runner_client.update_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 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") print_table_generic("Event", [event], "id", "runner_id", "action", "run_id", "event_status")
@app.command() @app.command()
@async_cli() @async_cli()
async def ls_events( async def ls_events(
runner_id: int,
action: Annotated[str | None, Option("--action", "-a", help="Filter for action.")] = None, 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, 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, run_id: Annotated[int | None, Option("--run", "-r", help="Filter for run.")] = None,
limit: Annotated[int | None, Option("--limit", "-l", help="Limit results.")] = None, limit: Annotated[int | None, Option("--limit", "-l", help="Limit results.")] = None,
): ):
"""List runner related events""" """List runner related events"""
events = await state.runner_client.get_events( events = await state.runner_client.get_events(action=action, run_id=run_id, event_status=event_status, limit=limit)
runner_id=runner_id, action=action, run_id=run_id, event_status=event_status, limit=limit print_table_generic("Events", events, "id", "runner_id", "action", "run_id", "event_status")
)
print_table_generic(events, "id", "runner_id", "action", "run_id", "event_status")
...@@ -117,6 +117,14 @@ async def submit_script( ...@@ -117,6 +117,14 @@ async def submit_script(
input: Annotated[ input: Annotated[
str | None, Option("--input", "-i", help="Specify a tarball file of inputs needed for running the simulation.") str | None, Option("--input", "-i", help="Specify a tarball file of inputs needed for running the simulation.")
] = None, ] = None,
start: Annotated[
bool,
Option(
"--start",
"-s",
help="Immediately create a start event and schedule the run to be executed on the specified runner.",
),
] = False,
): ):
"""Submit a SimBricks python simulation script to run.""" """Submit a SimBricks python simulation script to run."""
...@@ -132,16 +140,10 @@ async def submit_script( ...@@ -132,16 +140,10 @@ async def submit_script(
system = await system_client.create_system(sb_system) system = await system_client.create_system(sb_system)
system_id = int(system["id"]) system_id = int(system["id"])
system = await system_client.get_system(system_id) system = await system_client.get_system(system_id)
# print(system)
systems = await system_client.get_systems()
# print(systems)
simulation = await system_client.create_simulation(system_id, sb_simulation) simulation = await system_client.create_simulation(system_id, sb_simulation)
sim_id = int(simulation["id"]) sim_id = int(simulation["id"])
simulation = await system_client.get_simulation(sim_id) simulation = await system_client.get_simulation(sim_id)
# print(simulation)
simulations = await system_client.get_simulations()
# print(simulations)
instantiation = await system_client.create_instantiation(sim_id, None) instantiation = await system_client.create_instantiation(sim_id, None)
inst_id = int(instantiation["id"]) inst_id = int(instantiation["id"])
...@@ -150,9 +152,9 @@ async def submit_script( ...@@ -150,9 +152,9 @@ async def submit_script(
run_id = run["id"] run_id = run["id"]
if input: if input:
await system_client.set_run_input(run_id, input) await system_client.set_run_input(run_id, input)
await system_client.update_run(run_id, {"state": "pending", "output": ""})
print(run) if start:
await state.runner_client.create_runner_event(action="start_run", run_id=run_id)
if follow: if follow:
await system_client.follow_run(run_id) await system_client.follow_run(run_id)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment