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

symphony/cli: added commands to create and retrieve resource groups

parent 35ca047f
...@@ -22,7 +22,17 @@ ...@@ -22,7 +22,17 @@
from typer import Typer, Option from typer import Typer, Option
from typing_extensions import Annotated from typing_extensions import Annotated
from simbricks.cli.commands import audit, admin, namespaces, runs, systems, simulations, instantiations, runners from simbricks.cli.commands import (
audit,
admin,
namespaces,
resource_groups,
runs,
systems,
simulations,
instantiations,
runners,
)
from simbricks.client.provider import client_provider from simbricks.client.provider import client_provider
from simbricks.cli.utils import async_cli from simbricks.cli.utils import async_cli
...@@ -35,6 +45,7 @@ app.add_typer(systems.app, name="systems") ...@@ -35,6 +45,7 @@ app.add_typer(systems.app, name="systems")
app.add_typer(simulations.app, name="sims") app.add_typer(simulations.app, name="sims")
app.add_typer(instantiations.app, name="insts") app.add_typer(instantiations.app, name="insts")
app.add_typer(runners.app, name="runners") app.add_typer(runners.app, name="runners")
app.add_typer(resource_groups.app, name="resource_groups")
@app.callback() @app.callback()
......
from typer import Typer
from simbricks.client.provider import client_provider
from ..utils import async_cli, print_table_generic
app = Typer(help="Managing SimBricks resource groups used by runners.")
@app.command()
@async_cli()
async def create_rg(label: str, available_cores: int, available_memory: int):
"""Create a resource group describing a runners available resources."""
rg = await client_provider.resource_group_client.create_rg(
label=label, available_cores=available_cores, available_memory=available_memory
)
print_table_generic(
"Resource Group", [rg], "id", "label", "available_cores", "available_memory", "cores_left", "memory_left"
)
@app.command()
@async_cli()
async def ls_rg(rg_id: int):
"""List a resource group."""
rg = await client_provider.resource_group_client.get_rg(rg_id=rg_id)
print_table_generic(
"Resource Group", [rg], "id", "label", "available_cores", "available_memory", "cores_left", "memory_left"
)
@app.command()
@async_cli()
async def ls():
"""List available resource groups."""
rgs = await client_provider.resource_group_client.filter_get_rg()
print_table_generic(
"Resource Group", rgs, "id", "label", "available_cores", "available_memory", "cores_left", "memory_left"
)
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